more work on Raw -> Smart Pointers for external libs.

This commit is contained in:
suter_a 2023-10-27 23:23:19 +02:00
parent 7691ef2815
commit af13e78c52
16 changed files with 440 additions and 674 deletions

View File

@ -35,6 +35,7 @@
#include <cmath>
#include <vector>
#include <memory>
//-----------------------------------------------------------------------------
/**
@ -88,10 +89,8 @@ inline double T2Integrator::IntegrateFunc(double x1, double x2, const std::vecto
ptrPair.first = (this);
ptrPair.second = &par;
ROOT::Math::GSLIntegrator *integrator = new ROOT::Math::GSLIntegrator(ROOT::Math::Integration::kADAPTIVE,ROOT::Math::Integration::kGAUSS31);
std::unique_ptr<ROOT::Math::GSLIntegrator> integrator = std::make_unique<ROOT::Math::GSLIntegrator>(ROOT::Math::Integration::kADAPTIVE,ROOT::Math::Integration::kGAUSS31);
double value(integrator->Integral(&T2Integrator::FuncAtXgsl, static_cast<void*>(&ptrPair), x1, x2));
delete integrator;
integrator = nullptr;
return value;
}
@ -115,7 +114,7 @@ class TIntegrator {
private:
static double FuncAtXgsl(double, void *);
ROOT::Math::GSLIntegrator *fIntegrator; ///< pointer to the GSL integrator
std::unique_ptr<ROOT::Math::GSLIntegrator> fIntegrator; ///< pointer to the GSL integrator
mutable double (*fFunc)(double, void *); ///< pointer to the integrand function
};
@ -125,7 +124,7 @@ class TIntegrator {
* Allocation of memory for an integration using the adaptive 31 point Gauss-Kronrod rule
*/
inline TIntegrator::TIntegrator() : fFunc(0) {
fIntegrator = new ROOT::Math::GSLIntegrator(ROOT::Math::Integration::kADAPTIVE,ROOT::Math::Integration::kGAUSS31);
fIntegrator = std::make_unique<ROOT::Math::GSLIntegrator>(ROOT::Math::Integration::kADAPTIVE,ROOT::Math::Integration::kGAUSS31);
}
//-----------------------------------------------------------------------------
@ -135,8 +134,6 @@ inline TIntegrator::TIntegrator() : fFunc(0) {
*/
inline TIntegrator::~TIntegrator(){
fPar.clear();
delete fIntegrator;
fIntegrator=nullptr;
fFunc=0;
}
@ -190,7 +187,7 @@ class TMCIntegrator {
private:
static double FuncAtXgsl(double *, size_t, void *);
ROOT::Math::GSLMCIntegrator *fMCIntegrator; ///< pointer to the GSL integrator
std::unique_ptr<ROOT::Math::GSLMCIntegrator> fMCIntegrator; ///< pointer to the GSL integrator
mutable double (*fFunc)(double *, size_t, void *); ///< pointer to the integrand function
};
@ -200,7 +197,7 @@ class TMCIntegrator {
* Allocation of memory for an integration using the MISER algorithm of Press and Farrar
*/
inline TMCIntegrator::TMCIntegrator() : fFunc(0) {
fMCIntegrator = new ROOT::Math::GSLMCIntegrator(ROOT::Math::MCIntegration::kMISER, 1.E-6, 1.E-4, 500000);
fMCIntegrator = std::make_unique<ROOT::Math::GSLMCIntegrator>(ROOT::Math::MCIntegration::kMISER, 1.E-6, 1.E-4, 500000);
}
//-----------------------------------------------------------------------------
@ -210,8 +207,6 @@ inline TMCIntegrator::TMCIntegrator() : fFunc(0) {
*/
inline TMCIntegrator::~TMCIntegrator(){
fPar.clear();
delete fMCIntegrator;
fMCIntegrator=nullptr;
fFunc=0;
}

View File

@ -33,37 +33,33 @@
#include <cmath>
#include <cassert>
#include <algorithm>
using namespace std;
#include <memory>
//--------------------
// Constructor of the TrimSPData class -- reading all available trim.SP-rge-files with a given name into std::vectors
//--------------------
TTrimSPData::TTrimSPData(const string &path, map<double, string> &energies, bool debug, unsigned int highRes) {
TTrimSPData::TTrimSPData(const std::string &path, std::map<double, std::string> &energies, bool debug, unsigned int highRes) {
// sort the energies in ascending order - this might be useful for later applications (energy-interpolations etc.)
// after the change from the vector to the map this is not necessary any more - since maps are always ordered!
// sort(energies.begin(), energies.end());
double zz(0.0), nzz(0.0);
vector<double> vzz, vnzz;
string word, energyStr;
std::vector<double> vzz, vnzz;
std::string word, energyStr;
bool goodFile(false);
for ( map<double, string>::const_iterator iter(energies.begin()); iter != energies.end(); ++iter ) {
for ( std::map<double, std::string>::const_iterator iter(energies.begin()); iter != energies.end(); ++iter ) {
energyStr = path + iter->second + ".rge";
ifstream *rgeFile = new ifstream(energyStr.c_str());
if(! *rgeFile) {
cerr << "TTrimSPData::TTrimSPData: file " << energyStr << " not found! Try next energy..." << endl;
delete rgeFile;
rgeFile = 0;
std::unique_ptr<std::ifstream> rgeFile = std::make_unique<std::ifstream>(energyStr.c_str());
if (rgeFile == nullptr) {
std::cerr << "TTrimSPData::TTrimSPData: file " << energyStr << " not found! Try next energy..." << std::endl;
} else {
while(*rgeFile >> word) {
if(word == "PARTICLES") {
while (*rgeFile >> word) {
if (word == "PARTICLES") {
goodFile = true;
break;
}
@ -73,7 +69,7 @@ TTrimSPData::TTrimSPData(const string &path, map<double, string> &energies, bool
fEnergy.push_back(iter->first);
while(!rgeFile->eof()) {
while (!rgeFile->eof()) {
*rgeFile >> zz >> nzz;
vzz.push_back(zz);
vnzz.push_back(nzz);
@ -92,8 +88,6 @@ TTrimSPData::TTrimSPData(const string &path, map<double, string> &energies, bool
rgeFile->close();
delete rgeFile;
rgeFile = 0;
vzz.clear();
vnzz.clear();
@ -106,14 +100,14 @@ TTrimSPData::TTrimSPData(const string &path, map<double, string> &energies, bool
}
} else {
cerr << "TTrimSPData::TTrimSPData: " << energyStr << " does not seem to be a valid unmodified TRIM.SP output file!" << endl;
std::cerr << "TTrimSPData::TTrimSPData: " << energyStr << " does not seem to be a valid unmodified TRIM.SP output file!" << std::endl;
continue;
}
}
}
if (debug)
cout << "TTrimSPData::TTrimSPData: Read in " << fDataNZ.size() << " implantation profiles in total." << endl;
std::cout << "TTrimSPData::TTrimSPData: Read in " << fDataNZ.size() << " implantation profiles in total." << std::endl;
fOrigDataNZ = fDataNZ;
@ -126,8 +120,8 @@ TTrimSPData::TTrimSPData(const string &path, map<double, string> &energies, bool
// If it is not found the energy iterator will point to the end() of the energy vector.
void TTrimSPData::FindEnergy(double e) const {
for(fEnergyIter = fEnergy.begin(); fEnergyIter != fEnergy.end(); ++fEnergyIter) {
if(fabs(*fEnergyIter - e) < 0.05)
for (fEnergyIter = fEnergy.begin(); fEnergyIter != fEnergy.end(); ++fEnergyIter) {
if (fabs(*fEnergyIter - e) < 0.05)
return;
}
return;
@ -137,11 +131,11 @@ void TTrimSPData::UseHighResolution(double e) {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
vector<double> vecZ;
vector<double> vecNZ;
for(double zz(1.); zz<2100.; zz+=1.) {
std::vector<double> vecZ;
std::vector<double> vecNZ;
for (double zz(1.); zz<2100.; zz+=1.) {
vecZ.push_back(zz);
vecNZ.push_back(GetNofZ(zz/10.0, e));
}
@ -153,7 +147,7 @@ void TTrimSPData::UseHighResolution(double e) {
return;
}
cout << "TTrimSPData::DataZ: No implantation profile available for the specified energy... Nothing happens." << endl;
std::cout << "TTrimSPData::DataZ: No implantation profile available for the specified energy... Nothing happens." << std::endl;
return;
}
@ -161,16 +155,16 @@ void TTrimSPData::UseHighResolution(double e) {
// Method returning z-vector calculated by trim.SP for given energy[keV]
//---------------------
vector<double> TTrimSPData::DataZ(double e) const {
std::vector<double> TTrimSPData::DataZ(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
return fDataZ[i];
}
// default
cout << "TTrimSPData::DataZ: No implantation profile available for the specified energy... You get back the first one." << endl;
std::cout << "TTrimSPData::DataZ: No implantation profile available for the specified energy... You get back the first one." << std::endl;
return fDataZ[0];
}
@ -179,50 +173,50 @@ vector<double> TTrimSPData::DataZ(double e) const {
// potentially altered by the WeightLayers- or the Normalize-method for given energy[keV]
//---------------------
vector<double> TTrimSPData::DataNZ(double e) const {
std::vector<double> TTrimSPData::DataNZ(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
return fDataNZ[i];
}
// default
cout << "TTrimSPData::DataNZ: No implantation profile available for the specified energy... You get back the first one." << endl;
return fDataNZ[0];
std::cout << "TTrimSPData::DataNZ: No implantation profile available for the specified energy... You get back the first one." << std::endl;
return fDataNZ[0];
}
//---------------------
// Method returning original n(z)-vector calculated by trim.SP for given energy[keV]
//---------------------
vector<double> TTrimSPData::OrigDataNZ(double e) const {
std::vector<double> TTrimSPData::OrigDataNZ(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
return fOrigDataNZ[i];
}
// default
cout << "TTrimSPData::OrigDataNZ: No implantation profile available for the specified energy... You get back the first one." << endl;
return fOrigDataNZ[0];
std::cout << "TTrimSPData::OrigDataNZ: No implantation profile available for the specified energy... You get back the first one." << std::endl;
return fOrigDataNZ[0];
}
double TTrimSPData::DataDZ(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
return fDZ[i];
}
// default
cout << "TTrimSPData::DataDZ: No implantation profile available for the specified energy... The resolution will be zero!" << endl;
return 0.0;
std::cout << "TTrimSPData::DataDZ: No implantation profile available for the specified energy... The resolution will be zero!" << std::endl;
return 0.0;
}
//---------------------
@ -230,10 +224,10 @@ double TTrimSPData::DataDZ(double e) const {
// Parameters: Energy[keV], LayerNumber[1], Interfaces[nm]
//---------------------
double TTrimSPData::LayerFraction(double e, unsigned int layno, const vector<double>& interface) const {
double TTrimSPData::LayerFraction(double e, unsigned int layno, const std::vector<double>& interface) const {
if(layno < 1 && layno > (interface.size()+1)) {
cout << "TTrimSPData::LayerFraction: No such layer available according to your specified interfaces... Returning 0.0!" << endl;
if (layno < 1 && layno > (interface.size()+1)) {
std::cout << "TTrimSPData::LayerFraction: No such layer available according to your specified interfaces... Returning 0.0!" << std::endl;
return 0.0;
}
@ -244,21 +238,21 @@ double TTrimSPData::LayerFraction(double e, unsigned int layno, const vector<dou
// Because we do not know if the implantation profile is normalized or not, do not care about this and calculate the fraction from the beginning
// Total "number of muons"
double totalNumber(0.0);
for(unsigned int j(0); j<fDataZ[i].size(); j++)
for (unsigned int j(0); j<fDataZ[i].size(); j++)
totalNumber += fDataNZ[i][j];
// "number of muons" in layer layno
double layerNumber(0.0);
if(!(layno-1)){
for(unsigned int j(0); j<fDataZ[i].size(); j++)
if(fDataZ[i][j] < interface[0]*10.0)
if (!(layno-1)){
for (unsigned int j(0); j<fDataZ[i].size(); j++)
if (fDataZ[i][j] < interface[0]*10.0)
layerNumber += fDataNZ[i][j];
} else if(!(layno-interface.size()-1)){
for(unsigned int j(0); j<fDataZ[i].size(); j++)
if(fDataZ[i][j] >= *(interface.end()-1)*10.0)
} else if (!(layno-interface.size()-1)) {
for (unsigned int j(0); j<fDataZ[i].size(); j++)
if (fDataZ[i][j] >= *(interface.end()-1)*10.0)
layerNumber += fDataNZ[i][j];
} else {
for(unsigned int j(0); j<fDataZ[i].size(); j++)
if(fDataZ[i][j] >= interface[layno-2]*10.0 && fDataZ[i][j] < interface[layno-1]*10.0)
for (unsigned int j(0); j<fDataZ[i].size(); j++)
if (fDataZ[i][j] >= interface[layno-2]*10.0 && fDataZ[i][j] < interface[layno-1]*10.0)
layerNumber += fDataNZ[i][j];
}
// fraction of muons in layer layno
@ -267,9 +261,9 @@ double TTrimSPData::LayerFraction(double e, unsigned int layno, const vector<dou
}
// default
cout << "TTrimSPData::LayerFraction: No implantation profile available for the specified energy " << e << " keV... Returning 0.0" << endl;
return 0.0;
std::cout << "TTrimSPData::LayerFraction: No implantation profile available for the specified energy " << e << " keV... Returning 0.0" << std::endl;
return 0.0;
}
//---------------------
@ -280,30 +274,30 @@ double TTrimSPData::LayerFraction(double e, unsigned int layno, const vector<dou
// the first and last layers get the full n(z), where only one third of the muons in the second layer will be taken into account
//---------------------
void TTrimSPData::WeightLayers(double e, const vector<double>& interface, const vector<double>& weight) const {
void TTrimSPData::WeightLayers(double e, const std::vector<double>& interface, const std::vector<double>& weight) const {
if(weight.size()-interface.size()-1) {
cout << "TTrimSPData::WeightLayers: For the weighting the number of interfaces has to be one less than the number of weights!" << endl;
cout << "TTrimSPData::WeightLayers: No weighting of the implantation profile will be done unless you take care of that!" << endl;
if (weight.size()-interface.size()-1) {
std::cout << "TTrimSPData::WeightLayers: For the weighting the number of interfaces has to be one less than the number of weights!" << std::endl;
std::cout << "TTrimSPData::WeightLayers: No weighting of the implantation profile will be done unless you take care of that!" << std::endl;
return;
}
for(unsigned int i(0); i<interface.size(); i++) {
for (unsigned int i(0); i<interface.size(); i++) {
if (interface[i]<0.0) {
cout << "TTrimSPData::WeightLayers: One of your layer interfaces has a negative coordinate! - No weighting will be done!" << endl;
std::cout << "TTrimSPData::WeightLayers: One of your layer interfaces has a negative coordinate! - No weighting will be done!" << std::endl;
return;
}
else if (i>1) {
if (interface[i]<interface[i-1]) {
cout << "TTrimSPData::WeightLayers: The specified interfaces appear to be not in ascending order! - No weighting will be done!" << endl;
std::cout << "TTrimSPData::WeightLayers: The specified interfaces appear to be not in ascending order! - No weighting will be done!" << std::endl;
return;
}
}
}
for(unsigned int i(0); i<weight.size(); i++) {
for (unsigned int i(0); i<weight.size(); i++) {
if (weight[i]>1.0 || weight[i]<0.0) {
cout << "TTrimSPData::WeightLayers: At least one of the specified weights is out of range - no weighting will be done!" << endl;
std::cout << "TTrimSPData::WeightLayers: At least one of the specified weights is out of range - no weighting will be done!" << std::endl;
return;
}
}
@ -311,11 +305,11 @@ void TTrimSPData::WeightLayers(double e, const vector<double>& interface, const
FindEnergy(e);
// If all weights are equal to one, use the original n(z) vector
for(unsigned int i(0); i<weight.size(); i++) {
if(weight[i]-1.0)
for (unsigned int i(0); i<weight.size(); i++) {
if (weight[i]-1.0)
break;
if(i == weight.size() - 1) {
if(fEnergyIter != fEnergy.end()) {
if (i == weight.size() - 1) {
if (fEnergyIter != fEnergy.end()) {
unsigned int j(fEnergyIter - fEnergy.begin());
fDataNZ[j] = fOrigDataNZ[j];
fIsNormalized[j] = false;
@ -324,12 +318,12 @@ void TTrimSPData::WeightLayers(double e, const vector<double>& interface, const
}
}
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
unsigned int k(0);
for(unsigned int j(0); j<fDataZ[i].size(); j++) {
if(k<interface.size()) {
if(fDataZ[i][j] < interface[k]*10.0)
for (unsigned int j(0); j<fDataZ[i].size(); j++) {
if (k<interface.size()) {
if (fDataZ[i][j] < interface[k]*10.0)
fDataNZ[i][j] = fOrigDataNZ[i][j]*weight[k];
else {
k++;
@ -339,11 +333,11 @@ void TTrimSPData::WeightLayers(double e, const vector<double>& interface, const
else
fDataNZ[i][j] = fOrigDataNZ[i][j]*weight[k];
}
fIsNormalized[i] = false;
return;
fIsNormalized[i] = false;
return;
}
cout << "TTrimSPData::WeightLayers: No implantation profile available for the specified energy... No weighting done." << endl;
std::cout << "TTrimSPData::WeightLayers: No implantation profile available for the specified energy... No weighting done." << std::endl;
return;
}
@ -353,20 +347,20 @@ void TTrimSPData::WeightLayers(double e, const vector<double>& interface, const
double TTrimSPData::GetNofZ(double zz, double e) const {
vector<double> z, nz;
std::vector<double> z, nz;
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
z = fDataZ[i];
nz = fDataNZ[i];
} else {
cout << "TTrimSPData::GetNofZ: No implantation profile available for the specified energy " << e << " keV... Quitting!" << endl;
std::cout << "TTrimSPData::GetNofZ: No implantation profile available for the specified energy " << e << " keV... Quitting!" << std::endl;
exit(-1);
}
if(zz < 0)
if (zz < 0)
return 0.0;
bool found = false;
@ -395,7 +389,7 @@ void TTrimSPData::Normalize(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
double nZsum = 0.0;
for (unsigned int j(0); j<fDataZ[i].size(); j++)
@ -408,9 +402,9 @@ void TTrimSPData::Normalize(double e) const {
return;
}
// default
cout << "TTrimSPData::Normalize: No implantation profile available for the specified energy... No normalization done." << endl;
return;
std::cout << "TTrimSPData::Normalize: No implantation profile available for the specified energy... No normalization done." << std::endl;
return;
}
//---------------------
@ -420,12 +414,12 @@ void TTrimSPData::Normalize(double e) const {
bool TTrimSPData::IsNormalized(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
return fIsNormalized[i];
}
cout << "TTrimSPData::IsNormalized: No implantation profile available for the specified energy... Returning false! Check your code!" << endl;
std::cout << "TTrimSPData::IsNormalized: No implantation profile available for the specified energy... Returning false! Check your code!" << std::endl;
return false;
}
@ -436,19 +430,19 @@ bool TTrimSPData::IsNormalized(double e) const {
double TTrimSPData::MeanRange(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
if (!fIsNormalized[i])
Normalize(e);
double mean(0.0);
for(unsigned int j(0); j<fDataNZ[i].size(); j++){
for (unsigned int j(0); j<fDataNZ[i].size(); j++){
mean += fDataNZ[i][j]*fDataZ[i][j];
}
mean *= fDZ[i]/10.0;
return mean;
}
cout << "TTrimSPData::MeanRange: No implantation profile available for the specified energy... Returning -1! Check your code!" << endl;
std::cout << "TTrimSPData::MeanRange: No implantation profile available for the specified energy... Returning -1! Check your code!" << std::endl;
return -1.;
}
@ -460,21 +454,21 @@ double TTrimSPData::PeakRange(double e) const {
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
vector<double>::const_iterator nziter;
std::vector<double>::const_iterator nziter;
nziter = max_element(fDataNZ[i].begin(),fDataNZ[i].end());
if(nziter != fDataNZ[i].end()){
if (nziter != fDataNZ[i].end()){
unsigned int j(nziter - fDataNZ[i].begin());
return fDataZ[i][j]/10.0;
}
cout << "TTrimSPData::PeakRange: No maximum found in the implantation profile... Returning -1! Please check the profile!" << endl;
std::cout << "TTrimSPData::PeakRange: No maximum found in the implantation profile... Returning -1! Please check the profile!" << std::endl;
return -1.;
}
cout << "TTrimSPData::PeakRange: No implantation profile available for the specified energy... Returning -1! Check your code!" << endl;
std::cout << "TTrimSPData::PeakRange: No implantation profile available for the specified energy... Returning -1! Check your code!" << std::endl;
return -1.;
}
@ -484,26 +478,26 @@ double TTrimSPData::PeakRange(double e) const {
//---------------------
void TTrimSPData::ConvolveGss(double w, double e) const {
if(!w)
if (!w)
return;
vector<double> z, nz, gss;
std::vector<double> z, nz, gss;
double nn;
FindEnergy(e);
if(fEnergyIter != fEnergy.end()) {
if (fEnergyIter != fEnergy.end()) {
unsigned int i(fEnergyIter - fEnergy.begin());
z = fDataZ[i];
nz = fDataNZ[i];
for(unsigned int k(0); k<z.size(); k++) {
for (unsigned int k(0); k<z.size(); k++) {
gss.push_back(exp(-z[k]*z[k]/200.0/w/w));
}
for(unsigned int k(0); k<nz.size(); k++) {
for (unsigned int k(0); k<nz.size(); k++) {
nn = 0.0;
for(unsigned int j(0); j<nz.size(); j++) {
for (unsigned int j(0); j<nz.size(); j++) {
nn += nz[j]*gss[abs(int(k)-int(j))];
}
fDataNZ[i][k] = nn;
@ -514,6 +508,6 @@ void TTrimSPData::ConvolveGss(double w, double e) const {
return;
}
cout << "TTrimSPData::ConvolveGss: No implantation profile available for the specified energy... No convolution done!" << endl;
std::cout << "TTrimSPData::ConvolveGss: No implantation profile available for the specified energy... No convolution done!" << std::endl;
return;
}

View File

@ -32,7 +32,6 @@
#include <vector>
#include <string>
#include <map>
using namespace std;
/**
* <p>Class used to handle a set of low energy muon implantation profiles
@ -41,7 +40,7 @@ class TTrimSPData {
public:
TTrimSPData(const string&, map<double, string>&, bool debug = false, unsigned int highRes = 0);
TTrimSPData(const std::string&, std::map<double, std::string>&, bool debug = false, unsigned int highRes = 0);
~TTrimSPData() {
fDataZ.clear();
@ -52,15 +51,15 @@ public:
fIsNormalized.clear();
}
vector<double> Energy() const {return fEnergy;}
vector<double> DataZ(double) const;
vector<double> DataNZ(double) const;
vector<double> OrigDataNZ(double) const;
std::vector<double> Energy() const {return fEnergy;}
std::vector<double> DataZ(double) const;
std::vector<double> DataNZ(double) const;
std::vector<double> OrigDataNZ(double) const;
double DataDZ(double) const;
void UseHighResolution(double);
void SetOriginal() {fOrigDataNZ = fDataNZ;}
void WeightLayers(double, const vector<double>&, const vector<double>&) const;
double LayerFraction(double, unsigned int, const vector<double>&) const;
void WeightLayers(double, const std::vector<double>&, const std::vector<double>&) const;
double LayerFraction(double, unsigned int, const std::vector<double>&) const;
double GetNofZ(double, double) const;
void Normalize(double) const;
bool IsNormalized(double) const;
@ -71,13 +70,13 @@ public:
private:
void FindEnergy(double) const;
vector<double> fEnergy; ///< vector holding all available muon energies
vector<double> fDZ; ///< vector holding the spatial resolution of the TRIM.SP output for all energies
vector< vector<double> > fDataZ; ///< discrete points in real space for which n(z) has been calculated for all energies
mutable vector< vector<double> > fDataNZ; ///< n(z) for all energies
vector< vector<double> > fOrigDataNZ; ///< original (unmodified) implantation profiles for all energies as read in from rge-files
mutable vector<bool> fIsNormalized; ///< tag indicating if the implantation profiles are normalized (for each energy separately)
mutable vector<double>::const_iterator fEnergyIter; ///< iterator traversing the vector of available energies
std::vector<double> fEnergy; ///< vector holding all available muon energies
std::vector<double> fDZ; ///< vector holding the spatial resolution of the TRIM.SP output for all energies
std::vector< std::vector<double> > fDataZ; ///< discrete points in real space for which n(z) has been calculated for all energies
mutable std::vector< std::vector<double> > fDataNZ; ///< n(z) for all energies
std::vector< std::vector<double> > fOrigDataNZ; ///< original (unmodified) implantation profiles for all energies as read in from rge-files
mutable std::vector<bool> fIsNormalized; ///< tag indicating if the implantation profiles are normalized (for each energy separately)
mutable std::vector<double>::const_iterator fEnergyIter; ///< iterator traversing the vector of available energies
};
#endif // _TTrimSPDataHandler_H_

View File

@ -59,14 +59,14 @@ PMagProximityFitterGlobal::PMagProximityFitterGlobal()
// read XML startup file
char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser();
PMPStartupHandler *fStartupHandler = new PMPStartupHandler();
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
fStartupHandler = std::make_unique<PMPStartupHandler>();
strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data());
saxParser->ConnectToHandler("PMPStartupHandler", fStartupHandler);
saxParser->ConnectToHandler("PMPStartupHandler", fStartupHandler.get());
//Int_t status = saxParser->ParseFile(startup_path_name);
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
Int_t status = parseXmlFile(saxParser, startup_path_name);
Int_t status = parseXmlFile(saxParser.get(), startup_path_name);
// check for parse errors
if (status) { // error
std::cout << std::endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal: **WARNING** Reading/parsing mag_proximity_startup.xml failed.";
@ -74,12 +74,6 @@ PMagProximityFitterGlobal::PMagProximityFitterGlobal()
fValid = false;
}
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
// check if everything went fine with the startup handler
if (!fStartupHandler->IsValid()) {
std::cout << std::endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal **PANIC ERROR**";
@ -89,7 +83,7 @@ PMagProximityFitterGlobal::PMagProximityFitterGlobal()
}
// load all the TRIM.SP rge-files
fRgeHandler = new PRgeHandler();
fRgeHandler = std::make_unique<PRgeHandler>();
if (!fRgeHandler->IsValid()) {
std::cout << std::endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal **PANIC ERROR**";
std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry.";
@ -109,15 +103,6 @@ PMagProximityFitterGlobal::~PMagProximityFitterGlobal()
fPreviousParam.clear();
fField.clear();
if (fRgeHandler) {
delete fRgeHandler;
fRgeHandler = nullptr;
}
if (fStartupHandler) {
delete fStartupHandler;
fStartupHandler = nullptr;
}
}
//--------------------------------------------------------------------------

View File

@ -30,6 +30,8 @@
#ifndef _PMAGPROXIMITYFITTER_H_
#define _PMAGPROXIMITYFITTER_H_
#include <memory>
#include "PUserFcnBase.h"
#include "PMPStartupHandler.h"
#include "PRgeHandler.h"
@ -49,8 +51,8 @@ class PMagProximityFitterGlobal
private:
Bool_t fValid;
PMPStartupHandler *fStartupHandler;
PRgeHandler *fRgeHandler;
std::unique_ptr<PMPStartupHandler> fStartupHandler;
std::unique_ptr<PRgeHandler> fRgeHandler;
mutable std::vector<Double_t> fPreviousParam;

View File

@ -1507,7 +1507,7 @@ bool TMusrRunHeader::UpdateFolder(TObject *treeObj, TString path)
if (!obj) { // required object not present, create it
TObjArray *oarray = new TObjArray();
if (!oarray) {
if (oarray == nullptr) {
std::cerr << std::endl << ">> TMusrRunHeader::UpdateFolder(): **ERROR** couldn't create header structure!!" << std::endl;
return false;
}

View File

@ -50,33 +50,22 @@ TMeanFieldsForScHalfSpace::TMeanFieldsForScHalfSpace() {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
int status (saxParser->ParseFile(startup_path_name.c_str()));
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
std::string rge_path(startupHandler->GetDataPath());
map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug());
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = std::make_unique<TTrimSPData>(rge_path, energy_vec, startupHandler->GetDebug());
}
// Operator-method that returns the mean field for a given implantation energy
@ -141,33 +130,22 @@ TMeanFieldsForScSingleLayer::TMeanFieldsForScSingleLayer() {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
int status (saxParser->ParseFile(startup_path_name.c_str()));
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
std::string rge_path(startupHandler->GetDataPath());
map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug());
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = std::make_unique<TTrimSPData>(rge_path, energy_vec, startupHandler->GetDebug());
}
// Operator-method that returns the mean field for a given implantation energy
@ -240,33 +218,22 @@ TMeanFieldsForScBilayer::TMeanFieldsForScBilayer() {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
int status (saxParser->ParseFile(startup_path_name.c_str()));
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
std::string rge_path(startupHandler->GetDataPath());
map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug(), 1);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = std::make_unique<TTrimSPData>(rge_path, energy_vec, startupHandler->GetDebug(), 1);
}
// Operator-method that returns the mean field for a given implantation energy
@ -335,10 +302,10 @@ double TMeanFieldsForScBilayer::CalcMeanB (double E, const std::vector<double>&
std::vector<double> nz(fImpProfile->DataNZ(E));
double dz(fImpProfile->DataDZ(E));
if (E==20.0){
ofstream of("Implantation-profile-normal.dat");
if (E==20.0) {
std::ofstream of("Implantation-profile-normal.dat");
for (unsigned int i(0); i<z.size(); i++) {
of << z[i] << " " << nz[i] << endl;
of << z[i] << " " << nz[i] << std::endl;
}
of.close();
}
@ -359,33 +326,22 @@ TMeanFieldsForScTrilayer::TMeanFieldsForScTrilayer() {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
int status (saxParser->ParseFile(startup_path_name.c_str()));
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
std::string rge_path(startupHandler->GetDataPath());
map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug());
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = std::make_unique<TTrimSPData>(rge_path, energy_vec, startupHandler->GetDebug());
}
// Operator-method that returns the mean field for a given implantation energy
@ -464,33 +420,22 @@ TMeanFieldsForScTrilayerWithInsulator::TMeanFieldsForScTrilayerWithInsulator() {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
int status (saxParser->ParseFile(startup_path_name.c_str()));
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
std::string rge_path(startupHandler->GetDataPath());
map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = new TTrimSPData(rge_path, energy_vec, startupHandler->GetDebug());
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fImpProfile = std::make_unique<TTrimSPData>(rge_path, energy_vec, startupHandler->GetDebug());
}
// Operator-method that returns the mean field for a given implantation energy

View File

@ -29,6 +29,8 @@
#ifndef _TCalcMeanFieldsLEM_H_
#define _TCalcMeanFieldsLEM_H_
#include <memory>
#include "TLondon1D.h"
class TMeanFieldsForScHalfSpace : public PUserFcnBase {
@ -36,13 +38,12 @@ class TMeanFieldsForScHalfSpace : public PUserFcnBase {
public:
// default constructor
TMeanFieldsForScHalfSpace();
~TMeanFieldsForScHalfSpace() {delete fImpProfile; fImpProfile = 0;}
double operator()(double, const std::vector<double>&) const;
double CalcMeanB (double, const TLondon1D_HS&) const;
private:
TTrimSPData *fImpProfile;
std::unique_ptr<TTrimSPData> fImpProfile;
ClassDef(TMeanFieldsForScHalfSpace,1)
};
@ -52,13 +53,12 @@ class TMeanFieldsForScSingleLayer : public PUserFcnBase {
public:
// default constructor
TMeanFieldsForScSingleLayer();
~TMeanFieldsForScSingleLayer() {delete fImpProfile; fImpProfile = 0;}
double operator()(double, const std::vector<double>&) const;
double CalcMeanB (double, const std::vector<double>&, const std::vector<double>&, const TLondon1D_1L&) const;
private:
TTrimSPData *fImpProfile;
std::unique_ptr<TTrimSPData> fImpProfile;
ClassDef(TMeanFieldsForScSingleLayer,1)
};
@ -68,13 +68,12 @@ class TMeanFieldsForScBilayer : public PUserFcnBase {
public:
// default constructor
TMeanFieldsForScBilayer();
~TMeanFieldsForScBilayer() {delete fImpProfile; fImpProfile = 0;}
double operator()(double, const std::vector<double>&) const;
double CalcMeanB (double, const std::vector<double>&, const std::vector<double>&, const TLondon1D_2L&, double) const;
private:
TTrimSPData *fImpProfile;
std::unique_ptr<TTrimSPData> fImpProfile;
ClassDef(TMeanFieldsForScBilayer,1)
};
@ -84,13 +83,12 @@ class TMeanFieldsForScTrilayer : public PUserFcnBase {
public:
// default constructor
TMeanFieldsForScTrilayer();
~TMeanFieldsForScTrilayer() {delete fImpProfile; fImpProfile = 0;}
double operator()(double, const std::vector<double>&) const;
double CalcMeanB (double, const std::vector<double>&, const std::vector<double>&, const TLondon1D_3L&) const;
private:
TTrimSPData *fImpProfile;
std::unique_ptr<TTrimSPData> fImpProfile;
ClassDef(TMeanFieldsForScTrilayer,1)
};
@ -100,13 +98,12 @@ class TMeanFieldsForScTrilayerWithInsulator : public PUserFcnBase {
public:
// default constructor
TMeanFieldsForScTrilayerWithInsulator();
~TMeanFieldsForScTrilayerWithInsulator() {delete fImpProfile; fImpProfile = 0;}
double operator()(double, const std::vector<double>&) const;
double CalcMeanB (double, const std::vector<double>&, const std::vector<double>&, const TLondon1D_3LwInsulator&) const;
private:
TTrimSPData *fImpProfile;
std::unique_ptr<TTrimSPData> fImpProfile;
ClassDef(TMeanFieldsForScTrilayerWithInsulator,1)
};

View File

@ -147,7 +147,7 @@ TLondon1D3LS::~TLondon1D3LS() {
TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("BMW_startup.xml");
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
@ -158,16 +158,16 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
int status = parseXmlFile(saxParser, startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
map<double, string> energy_vec(startupHandler->GetEnergies());
std::string rge_path(startupHandler->GetDataPath());
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0); // phase
fParForPofT.push_back(startupHandler->GetDeltat());
@ -203,18 +203,18 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
// Parameters: all the parameters for the function to be fitted through TLondon1DHS
//------------------
double TLondon1DHS::operator()(double t, const vector<double> &par) const {
double TLondon1DHS::operator()(double t, const std::vector<double> &par) const {
assert(par.size() == 5);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
bool dead_layer_changed(false);
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(2); i<fPar.size(); i++){
@ -230,7 +230,7 @@ double TLondon1DHS::operator()(double t, const vector<double> &par) const {
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
@ -253,7 +253,7 @@ double TLondon1DHS::operator()(double t, const vector<double> &par) const {
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// std::cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
@ -264,8 +264,8 @@ double TLondon1DHS::operator()(double t, const vector<double> &par) const {
fParForPofB[3] = par[2]; // Bkg-Field
//fParForPofB[4] = 0.005; // Bkg-width (in principle zero)
if(dead_layer_changed){
vector<double> interfaces;
if (dead_layer_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]);// dead layer
fParForPofB[5] = fImpProfile->LayerFraction(par[1], 1, interfaces); // Fraction of muons in the deadlayer
interfaces.clear();
@ -286,7 +286,6 @@ double TLondon1DHS::operator()(double t, const vector<double> &par) const {
}
return fPofT->Eval(t);
}
@ -298,7 +297,7 @@ double TLondon1DHS::operator()(double t, const vector<double> &par) const {
TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("BMW_startup.xml");
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
@ -309,16 +308,16 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) {
int status = parseXmlFile(saxParser, startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
map<double, string> energy_vec(startupHandler->GetEnergies());
std::string rge_path(startupHandler->GetDataPath());
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -354,7 +353,7 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) {
// Parameters: all the parameters for the function to be fitted through TLondon1D1L
//------------------
double TLondon1D1L::operator()(double t, const vector<double> &par) const {
double TLondon1D1L::operator()(double t, const std::vector<double> &par) const {
assert(par.size() == 6 || par.size() == 8);
@ -362,7 +361,7 @@ double TLondon1D1L::operator()(double t, const vector<double> &par) const {
// Count the number of function calls
// fCallCounter++;
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
bool bkg_fraction_changed(false);
@ -370,7 +369,7 @@ double TLondon1D1L::operator()(double t, const vector<double> &par) const {
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(2); i<fPar.size(); i++){
@ -389,7 +388,7 @@ double TLondon1D1L::operator()(double t, const vector<double> &par) const {
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
@ -413,7 +412,7 @@ double TLondon1D1L::operator()(double t, const vector<double> &par) const {
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// std::cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
@ -424,12 +423,12 @@ double TLondon1D1L::operator()(double t, const vector<double> &par) const {
fParForPofB[3] = par[2]; // Bkg-Field
//fParForPofB[4] = 0.005; // Bkg-width (in principle zero)
if(weights_changed) {
vector<double> interfaces;
if (weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]+par[4]);
vector<double> weights;
for(unsigned int i(6); i<8; i++)
std::vector<double> weights;
for (unsigned int i(6); i<8; i++)
weights.push_back(par[i]);
// std::cout << "Weighting has changed, re-calculating n(z) now..." << std::endl;
@ -439,8 +438,8 @@ double TLondon1D1L::operator()(double t, const vector<double> &par) const {
weights.clear();
}
if(bkg_fraction_changed || weights_changed) {
vector<double> interfaces;
if (bkg_fraction_changed || weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]);// dead layer
interfaces.push_back(par[3] + par[4]);// dead layer + first layer
fParForPofB[5] = fImpProfile->LayerFraction(par[1], 1, interfaces) + // Fraction of muons in the deadlayer
@ -484,7 +483,7 @@ double TLondon1D1L::operator()(double t, const vector<double> &par) const {
TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("BMW_startup.xml");
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
@ -495,16 +494,16 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) {
int status = parseXmlFile(saxParser, startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
map<double, string> energy_vec(startupHandler->GetEnergies());
std::string rge_path(startupHandler->GetDataPath());
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -540,11 +539,11 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) {
// Parameters: all the parameters for the function to be fitted through TLondon1D2L
//------------------
double TLondon1D2L::operator()(double t, const vector<double> &par) const {
double TLondon1D2L::operator()(double t, const std::vector<double> &par) const {
assert(par.size() == 8 || par.size() == 11);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
bool bkg_fraction_changed(false);
@ -552,7 +551,7 @@ double TLondon1D2L::operator()(double t, const vector<double> &par) const {
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(2); i<fPar.size(); i++){
@ -570,7 +569,7 @@ double TLondon1D2L::operator()(double t, const vector<double> &par) const {
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
@ -594,7 +593,7 @@ double TLondon1D2L::operator()(double t, const vector<double> &par) const {
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// std::cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
@ -605,13 +604,13 @@ double TLondon1D2L::operator()(double t, const vector<double> &par) const {
fParForPofB[3] = par[2]; // Bkg-Field
//fParForPofB[4] = 0.005; // Bkg-width (in principle zero)
if(weights_changed) {
vector<double> interfaces;
if (weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]+par[4]);
interfaces.push_back(par[3]+par[4]+par[5]);
vector<double> weights;
for(unsigned int i(8); i<11; i++)
std::vector<double> weights;
for (unsigned int i(8); i<11; i++)
weights.push_back(par[i]);
// std::cout << "Weighting has changed, re-calculating n(z) now..." << std::endl;
@ -621,8 +620,8 @@ double TLondon1D2L::operator()(double t, const vector<double> &par) const {
weights.clear();
}
if(bkg_fraction_changed || weights_changed) {
vector<double> interfaces;
if (bkg_fraction_changed || weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]);// dead layer
interfaces.push_back(par[3] + par[4] + par[5]);// dead layer + first layer + second layer
fParForPofB[5] = fImpProfile->LayerFraction(par[1], 1, interfaces) + // Fraction of muons in the deadlayer
@ -646,7 +645,6 @@ double TLondon1D2L::operator()(double t, const vector<double> &par) const {
}
return fPofT->Eval(t);
}
//------------------
@ -657,7 +655,7 @@ double TLondon1D2L::operator()(double t, const vector<double> &par) const {
TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("BMW_startup.xml");
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
@ -668,16 +666,16 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
int status = parseXmlFile(saxParser, startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
map<double, string> energy_vec(startupHandler->GetEnergies());
std::string rge_path(startupHandler->GetDataPath());
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -713,18 +711,18 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
// Parameters: all the parameters for the function to be fitted through TProximity1D1LHS
//------------------
double TProximity1D1LHS::operator()(double t, const vector<double> &par) const {
double TProximity1D1LHS::operator()(double t, const std::vector<double> &par) const {
assert(par.size() == 7);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
// check if the function is called the first time and if yes, read in parameters
bool dead_layer_changed(false);
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(2); i<fPar.size(); i++){
@ -740,14 +738,14 @@ double TProximity1D1LHS::operator()(double t, const vector<double> &par) const {
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
only_phase_changed = true;
} else {
only_phase_changed = false;
if (i == 4){
if (i == 4) {
dead_layer_changed = true;
}
}
@ -763,7 +761,7 @@ double TProximity1D1LHS::operator()(double t, const vector<double> &par) const {
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// std::cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
@ -774,8 +772,8 @@ double TProximity1D1LHS::operator()(double t, const vector<double> &par) const {
fParForPofB[3] = par[2]; // Bkg-Field
//fParForPofB[4] = 0.005; // Bkg-width (in principle zero)
if(dead_layer_changed){
vector<double> interfaces;
if (dead_layer_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[4]);// dead layer
fParForPofB[5] = fImpProfile->LayerFraction(par[1], 1, interfaces); // Fraction of muons in the deadlayer
interfaces.clear();
@ -797,7 +795,6 @@ double TProximity1D1LHS::operator()(double t, const vector<double> &par) const {
}
return fPofT->Eval(t);
}
//------------------
@ -807,7 +804,7 @@ double TProximity1D1LHS::operator()(double t, const vector<double> &par) const {
TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("BMW_startup.xml");
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
@ -818,16 +815,16 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) {
int status = parseXmlFile(saxParser, startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
map<double, string> energy_vec(startupHandler->GetEnergies());
std::string rge_path(startupHandler->GetDataPath());
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -863,11 +860,11 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) {
// Parameters: all the parameters for the function to be fitted through TLondon1D3L
//------------------
double TLondon1D3L::operator()(double t, const vector<double> &par) const {
double TLondon1D3L::operator()(double t, const std::vector<double> &par) const {
assert(par.size() == 10 || par.size() == 14);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
bool bkg_fraction_changed(false);
@ -875,7 +872,7 @@ double TLondon1D3L::operator()(double t, const vector<double> &par) const {
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(2); i<fPar.size(); i++){
@ -893,7 +890,7 @@ double TLondon1D3L::operator()(double t, const vector<double> &par) const {
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
@ -917,7 +914,7 @@ double TLondon1D3L::operator()(double t, const vector<double> &par) const {
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// std::cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
@ -928,14 +925,14 @@ double TLondon1D3L::operator()(double t, const vector<double> &par) const {
fParForPofB[3] = par[2]; // Bkg-Field
//fParForPofB[4] = 0.005; // Bkg-width (in principle zero)
if(weights_changed) {
vector<double> interfaces;
if (weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]+par[4]);
interfaces.push_back(par[3]+par[4]+par[5]);
interfaces.push_back(par[3]+par[4]+par[5]+par[6]);
vector<double> weights;
for(unsigned int i(10); i<14; i++)
std::vector<double> weights;
for (unsigned int i(10); i<14; i++)
weights.push_back(par[i]);
// std::cout << "Weighting has changed, re-calculating n(z) now..." << std::endl;
@ -945,8 +942,8 @@ double TLondon1D3L::operator()(double t, const vector<double> &par) const {
weights.clear();
}
if(bkg_fraction_changed || weights_changed) {
vector<double> interfaces;
if (bkg_fraction_changed || weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]);// dead layer
interfaces.push_back(par[3] + par[4] + par[5] + par[6]);// dead layer + first layer + second layer + third layer
fParForPofB[5] = fImpProfile->LayerFraction(par[1], 1, interfaces) + // Fraction of muons in the deadlayer
@ -969,7 +966,6 @@ double TLondon1D3L::operator()(double t, const vector<double> &par) const {
}
return fPofT->Eval(t);
}
//------------------
@ -979,7 +975,7 @@ double TLondon1D3L::operator()(double t, const vector<double> &par) const {
TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("BMW_startup.xml");
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
@ -990,16 +986,16 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) {
int status = parseXmlFile(saxParser, startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
map<double, string> energy_vec(startupHandler->GetEnergies());
std::string rge_path(startupHandler->GetDataPath());
std::map<double, std::string> energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -1035,11 +1031,11 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) {
// Parameters: all the parameters for the function to be fitted through TLondon1D3LS
//------------------
double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
double TLondon1D3LS::operator()(double t, const std::vector<double> &par) const {
assert(par.size() == 9 || par.size() == 13);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
bool bkg_fraction_changed(false);
@ -1047,7 +1043,7 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(2); i<fPar.size(); i++){
@ -1065,7 +1061,7 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
@ -1089,7 +1085,7 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// std::cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
@ -1100,14 +1096,14 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
fParForPofB[3] = par[2]; // Bkg-Field
//fParForPofB[4] = 0.005; // Bkg-width (in principle zero)
if(weights_changed) {
vector<double> interfaces;
if (weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]+par[4]);
interfaces.push_back(par[3]+par[4]+par[5]);
interfaces.push_back(par[3]+par[4]+par[5]+par[6]);
vector<double> weights;
for(unsigned int i(9); i<13; i++)
std::vector<double> weights;
for (unsigned int i(9); i<13; i++)
weights.push_back(par[i]);
// std::cout << "Weighting has changed, re-calculating n(z) now..." << std::endl;
@ -1117,8 +1113,8 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
weights.clear();
}
if(bkg_fraction_changed || weights_changed) {
vector<double> interfaces;
if (bkg_fraction_changed || weights_changed) {
std::vector<double> interfaces;
interfaces.push_back(par[3]);// dead layer
interfaces.push_back(par[3] + par[4] + par[5] + par[6]);// dead layer + first layer + second layer + third layer
fParForPofB[5] = fImpProfile->LayerFraction(par[1], 1, interfaces) + // Fraction of muons in the deadlayer
@ -1141,7 +1137,6 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
}
return fPofT->Eval(t);
}
// //------------------

View File

@ -553,7 +553,7 @@ void TPofBCalc::Calculate(const TBulkVortexFieldCalc *vortexLattice, const std::
if (fill_index < fPBSize) {
fPB[fill_index] += 1.0;
} else {
cout << "Field over the limit..." << endl;
std::cout << "Field over the limit..." << std::endl;
}
}
// of << endl;

View File

@ -217,7 +217,7 @@ double TPofTCalc::Eval(double t) const {
// Parameters: output filename, par(dt, dB, timeres, channels, asyms, phases, t0s, N0s, bgs) optPar(field, energy)
//---------------------
void TPofTCalc::FakeData(const string &rootOutputFileName, const std::vector<double> &par, const std::vector<double> *optPar = 0) {
void TPofTCalc::FakeData(const std::string &rootOutputFileName, const std::vector<double> &par, const std::vector<double> *optPar = 0) {
//determine the number of histograms to be built
unsigned int numHist(0);

View File

@ -64,9 +64,9 @@ TSkewedGss::TSkewedGss() : fCalcNeeded(true), fFirstCall(true) {
int status (saxParser->ParseFile(startup_path_name.c_str()));
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}

View File

@ -52,12 +52,6 @@ ClassImp(TBulkAnisotropicTriVortexAGL)
//------------------
TBulkTriVortexLondon::~TBulkTriVortexLondon() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -69,12 +63,6 @@ TBulkTriVortexLondon::~TBulkTriVortexLondon() {
//------------------
TBulkSqVortexLondon::~TBulkSqVortexLondon() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -86,12 +74,6 @@ TBulkSqVortexLondon::~TBulkSqVortexLondon() {
//------------------
TBulkTriVortexML::~TBulkTriVortexML() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -103,12 +85,6 @@ TBulkTriVortexML::~TBulkTriVortexML() {
//------------------
TBulkTriVortexAGL::~TBulkTriVortexAGL() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -120,12 +96,6 @@ TBulkTriVortexAGL::~TBulkTriVortexAGL() {
//------------------
TBulkTriVortexAGLII::~TBulkTriVortexAGLII() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -137,12 +107,6 @@ TBulkTriVortexAGLII::~TBulkTriVortexAGLII() {
//------------------
TBulkTriVortexNGL::~TBulkTriVortexNGL() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -159,18 +123,18 @@ TBulkTriVortexLondon::TBulkTriVortexLondon() : fCalcNeeded(true), fFirstCall(tru
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -192,21 +156,11 @@ TBulkTriVortexLondon::TBulkTriVortexLondon() : fCalcNeeded(true), fFirstCall(tru
fParForPofB.push_back(0.0); // vortex-weighting || antiferromagnetic field
fParForPofB.push_back(0.0); // vortex-weighting: 0.0 homogeneous, 1.0 Gaussian, 2.0 Lorentzian || 3.0 antiferromagnetic vortex-cores
fVortex = new TBulkTriVortexLondonFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkTriVortexLondonFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
//------------------
@ -219,18 +173,18 @@ TBulkSqVortexLondon::TBulkSqVortexLondon() : fCalcNeeded(true), fFirstCall(true)
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -250,21 +204,11 @@ TBulkSqVortexLondon::TBulkSqVortexLondon() : fCalcNeeded(true), fFirstCall(true)
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
fVortex = new TBulkSqVortexLondonFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkSqVortexLondonFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
//------------------
@ -277,12 +221,12 @@ double TBulkTriVortexLondon::operator()(double t, const std::vector<double> &par
assert(par.size() == 4 || par.size() == 5 || par.size() == 7 || par.size() == 8); // normal, +BkgWeight, +VortexWeighting, +AFfield
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 3; i++) {
@ -342,7 +286,7 @@ double TBulkTriVortexLondon::operator()(double t, const std::vector<double> &par
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
@ -422,7 +366,7 @@ double TBulkSqVortexLondon::operator()(double t, const std::vector<double> &par)
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
@ -449,18 +393,18 @@ TBulkTriVortexML::TBulkTriVortexML() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -480,21 +424,11 @@ TBulkTriVortexML::TBulkTriVortexML() : fCalcNeeded(true), fFirstCall(true) {
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
fVortex = new TBulkTriVortexMLFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkTriVortexMLFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
//------------------
@ -507,12 +441,12 @@ double TBulkTriVortexML::operator()(double t, const std::vector<double> &par) co
assert(par.size() == 4 || par.size() == 5);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 3; i++) {
@ -547,7 +481,7 @@ double TBulkTriVortexML::operator()(double t, const std::vector<double> &par) co
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
@ -561,7 +495,7 @@ double TBulkTriVortexML::operator()(double t, const std::vector<double> &par) co
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
@ -574,7 +508,6 @@ double TBulkTriVortexML::operator()(double t, const std::vector<double> &par) co
}
return fPofT->Eval(t);
}
@ -588,18 +521,18 @@ TBulkTriVortexAGL::TBulkTriVortexAGL() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -619,21 +552,11 @@ TBulkTriVortexAGL::TBulkTriVortexAGL() : fCalcNeeded(true), fFirstCall(true) {
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
fVortex = new TBulkTriVortexAGLFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkTriVortexAGLFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
//------------------
@ -646,12 +569,12 @@ double TBulkTriVortexAGL::operator()(double t, const std::vector<double> &par) c
assert(par.size() == 4 || par.size() == 5);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 3; i++) {
@ -686,7 +609,7 @@ double TBulkTriVortexAGL::operator()(double t, const std::vector<double> &par) c
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
@ -700,7 +623,7 @@ double TBulkTriVortexAGL::operator()(double t, const std::vector<double> &par) c
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
@ -713,7 +636,6 @@ double TBulkTriVortexAGL::operator()(double t, const std::vector<double> &par) c
}
return fPofT->Eval(t);
}
//------------------
@ -726,18 +648,18 @@ TBulkTriVortexAGLII::TBulkTriVortexAGLII() : fCalcNeeded(true), fFirstCall(true)
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -759,21 +681,11 @@ TBulkTriVortexAGLII::TBulkTriVortexAGLII() : fCalcNeeded(true), fFirstCall(true)
fParForPofB.push_back(0.0); // vortex-weighting || antiferromagnetic field
fParForPofB.push_back(0.0); // vortex-weighting: 0.0 homogeneous, 1.0 Gaussian, 2.0 Lorentzian || 3.0 antiferromagnetic vortex-cores
fVortex = new TBulkTriVortexAGLIIFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkTriVortexAGLIIFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
//------------------
@ -786,12 +698,12 @@ double TBulkTriVortexAGLII::operator()(double t, const std::vector<double> &par)
assert(par.size() == 4 || par.size() == 5 || par.size() == 7 || par.size() == 8);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 3; i++) {
@ -826,7 +738,7 @@ double TBulkTriVortexAGLII::operator()(double t, const std::vector<double> &par)
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
@ -851,7 +763,7 @@ double TBulkTriVortexAGLII::operator()(double t, const std::vector<double> &par)
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
@ -864,7 +776,6 @@ double TBulkTriVortexAGLII::operator()(double t, const std::vector<double> &par)
}
return fPofT->Eval(t);
}
//------------------
@ -877,18 +788,18 @@ TBulkTriVortexNGL::TBulkTriVortexNGL() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -908,21 +819,11 @@ TBulkTriVortexNGL::TBulkTriVortexNGL() : fCalcNeeded(true), fFirstCall(true) {
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
fVortex = new TBulkTriVortexNGLFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkTriVortexNGLFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
//------------------
@ -935,12 +836,12 @@ double TBulkTriVortexNGL::operator()(double t, const std::vector<double> &par) c
assert(par.size() == 4 || par.size() == 5);
if(t<0.0)
if (t<0.0)
return cos(par[0]*0.017453293);
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 3; i++) {
@ -975,7 +876,7 @@ double TBulkTriVortexNGL::operator()(double t, const std::vector<double> &par) c
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
@ -989,7 +890,7 @@ double TBulkTriVortexNGL::operator()(double t, const std::vector<double> &par) c
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
@ -1002,7 +903,6 @@ double TBulkTriVortexNGL::operator()(double t, const std::vector<double> &par) c
}
return fPofT->Eval(t);
}
//------------------
@ -1010,12 +910,6 @@ double TBulkTriVortexNGL::operator()(double t, const std::vector<double> &par) c
//------------------
TBulkAnisotropicTriVortexLondonGlobal::~TBulkAnisotropicTriVortexLondonGlobal() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -1032,18 +926,18 @@ TBulkAnisotropicTriVortexLondonGlobal::TBulkAnisotropicTriVortexLondonGlobal() :
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -1063,21 +957,11 @@ TBulkAnisotropicTriVortexLondonGlobal::TBulkAnisotropicTriVortexLondonGlobal() :
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
fVortex = new TBulkAnisotropicTriVortexLondonFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkAnisotropicTriVortexLondonFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
void TBulkAnisotropicTriVortexLondonGlobal::Calc(const std::vector<double> &par) const {
@ -1090,7 +974,7 @@ void TBulkAnisotropicTriVortexLondonGlobal::Calc(const std::vector<double> &par)
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 5; i++) {
@ -1127,7 +1011,7 @@ void TBulkAnisotropicTriVortexLondonGlobal::Calc(const std::vector<double> &par)
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
@ -1141,7 +1025,7 @@ void TBulkAnisotropicTriVortexLondonGlobal::Calc(const std::vector<double> &par)
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
@ -1198,7 +1082,7 @@ void TBulkAnisotropicTriVortexLondon::SetGlobalPart(std::vector<void *> &globalP
fGlobalUserFcn = new TBulkAnisotropicTriVortexLondonGlobal();
if (fGlobalUserFcn == 0) { // global user function object couldn't be invoked -> error
fValid = false;
cerr << endl << ">> TBulkAnisotropicTriVortexLondon::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << endl;
std::cerr << std::endl << ">> TBulkAnisotropicTriVortexLondon::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl;
} else { // global user function object could be invoked -> resize to global user function vector and keep the pointer to the corresponding object
globalPart.resize(fIdxGlobal+1);
globalPart[fIdxGlobal] = dynamic_cast<TBulkAnisotropicTriVortexLondonGlobal*>(fGlobalUserFcn);
@ -1238,7 +1122,7 @@ double TBulkAnisotropicTriVortexLondon::operator()(double t, const std::vector<d
assert(param.size() == 6);
assert(fGlobalUserFcn);
if(t<0.0)
if (t<0.0)
return cos(param[0]*0.017453293);
// call the global user function object
@ -1252,12 +1136,6 @@ double TBulkAnisotropicTriVortexLondon::operator()(double t, const std::vector<d
//------------------
TBulkAnisotropicTriVortexMLGlobal::~TBulkAnisotropicTriVortexMLGlobal() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -1274,18 +1152,18 @@ TBulkAnisotropicTriVortexMLGlobal::TBulkAnisotropicTriVortexMLGlobal() : fCalcNe
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -1305,21 +1183,11 @@ TBulkAnisotropicTriVortexMLGlobal::TBulkAnisotropicTriVortexMLGlobal() : fCalcNe
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
fVortex = new TBulkAnisotropicTriVortexMLFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkAnisotropicTriVortexMLFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
void TBulkAnisotropicTriVortexMLGlobal::Calc(const std::vector<double> &par) const {
@ -1332,7 +1200,7 @@ void TBulkAnisotropicTriVortexMLGlobal::Calc(const std::vector<double> &par) con
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 5; i++) {
@ -1347,7 +1215,7 @@ void TBulkAnisotropicTriVortexMLGlobal::Calc(const std::vector<double> &par) con
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
@ -1369,9 +1237,9 @@ void TBulkAnisotropicTriVortexMLGlobal::Calc(const std::vector<double> &par) con
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
for (unsigned int i(0); i < 5; i++) {
fParForVortex[i] = par[i+1];
@ -1383,11 +1251,11 @@ void TBulkAnisotropicTriVortexMLGlobal::Calc(const std::vector<double> &par) con
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << endl;
cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << std::endl;
}*/
fPofT->CalcPol(fParForPofT);
@ -1440,7 +1308,7 @@ void TBulkAnisotropicTriVortexML::SetGlobalPart(std::vector<void *> &globalPart,
fGlobalUserFcn = new TBulkAnisotropicTriVortexMLGlobal();
if (fGlobalUserFcn == 0) { // global user function object couldn't be invoked -> error
fValid = false;
cerr << endl << ">> TBulkAnisotropicTriVortexML::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << endl;
std::cerr << std::endl << ">> TBulkAnisotropicTriVortexML::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl;
} else { // global user function object could be invoked -> resize to global user function vector and keep the pointer to the corresponding object
globalPart.resize(fIdxGlobal+1);
globalPart[fIdxGlobal] = dynamic_cast<TBulkAnisotropicTriVortexMLGlobal*>(fGlobalUserFcn);
@ -1480,7 +1348,7 @@ double TBulkAnisotropicTriVortexML::operator()(double t, const std::vector<doubl
assert(param.size() == 6);
assert(fGlobalUserFcn);
if(t<0.0)
if (t<0.0)
return cos(param[0]*0.017453293);
// call the global user function object
@ -1494,12 +1362,6 @@ double TBulkAnisotropicTriVortexML::operator()(double t, const std::vector<doubl
//------------------
TBulkAnisotropicTriVortexAGLGlobal::~TBulkAnisotropicTriVortexAGLGlobal() {
delete fPofT;
fPofT = 0;
delete fPofB;
fPofT = 0;
delete fVortex;
fVortex = 0;
fPar.clear();
fParForVortex.clear();
fParForPofB.clear();
@ -1516,18 +1378,18 @@ TBulkAnisotropicTriVortexAGLGlobal::TBulkAnisotropicTriVortexAGLGlobal() : fCalc
// read startup file
std::string startup_path_name("BMW_startup.xml");
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
std::unique_ptr<BMWStartupHandler> startupHandler = std::make_unique<BMWStartupHandler>();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler.get());
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments;
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
int status = parseXmlFile(saxParser, startup_path_name.c_str());
int status = parseXmlFile(saxParser.get(), startup_path_name.c_str());
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< endl;
std::cerr << std::endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
<< std::endl << "**ERROR** Please make sure that the file exists in the local directory and it is set up correctly!" \
<< std::endl;
assert(false);
}
@ -1547,21 +1409,11 @@ TBulkAnisotropicTriVortexAGLGlobal::TBulkAnisotropicTriVortexAGLGlobal() : fCalc
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
fVortex = new TBulkAnisotropicTriVortexAGLFieldCalc(fWisdom, fGridSteps);
fVortex = std::make_unique<TBulkAnisotropicTriVortexAGLFieldCalc>(fWisdom, fGridSteps);
fPofB = new TPofBCalc(fParForPofB);
fPofB = std::make_unique<TPofBCalc>(fParForPofB);
fPofT = new TPofTCalc(fPofB, fWisdom, fParForPofT);
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
fPofT = std::make_unique<TPofTCalc>(fPofB.get(), fWisdom, fParForPofT);
}
void TBulkAnisotropicTriVortexAGLGlobal::Calc(const std::vector<double> &par) const {
@ -1574,7 +1426,7 @@ void TBulkAnisotropicTriVortexAGLGlobal::Calc(const std::vector<double> &par) co
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
if (fFirstCall) {
fPar = par;
for (unsigned int i(0); i < 5; i++) {
@ -1589,7 +1441,7 @@ void TBulkAnisotropicTriVortexAGLGlobal::Calc(const std::vector<double> &par) co
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
if ( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
@ -1611,9 +1463,9 @@ void TBulkAnisotropicTriVortexAGLGlobal::Calc(const std::vector<double> &par) co
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
if (!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << std::endl;
for (unsigned int i(0); i < 5; i++) {
fParForVortex[i] = par[i+1];
@ -1625,11 +1477,11 @@ void TBulkAnisotropicTriVortexAGLGlobal::Calc(const std::vector<double> &par) co
fVortex->SetParameters(fParForVortex);
fVortex->CalculateGrid();
fPofB->UnsetPBExists();
fPofB->Calculate(fVortex, fParForPofB);
fPofB->Calculate(fVortex.get(), fParForPofB);
fPofT->DoFFT();
}/* else {
cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << endl;
cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << std::endl;
}*/
fPofT->CalcPol(fParForPofT);
@ -1683,7 +1535,7 @@ void TBulkAnisotropicTriVortexAGL::SetGlobalPart(std::vector<void *> &globalPart
fGlobalUserFcn = new TBulkAnisotropicTriVortexAGLGlobal();
if (fGlobalUserFcn == 0) { // global user function object couldn't be invoked -> error
fValid = false;
cerr << endl << ">> TBulkAnisotropicTriVortexAGL::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << endl;
std::cerr << std::endl << ">> TBulkAnisotropicTriVortexAGL::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl;
} else { // global user function object could be invoked -> resize to global user function vector and keep the pointer to the corresponding object
globalPart.resize(fIdxGlobal+1);
globalPart[fIdxGlobal] = dynamic_cast<TBulkAnisotropicTriVortexAGLGlobal*>(fGlobalUserFcn);
@ -1723,7 +1575,7 @@ double TBulkAnisotropicTriVortexAGL::operator()(double t, const std::vector<doub
assert(param.size() == 6);
assert(fGlobalUserFcn);
if(t<0.0)
if (t<0.0)
return cos(param[0]*0.017453293);
// call the global user function object

View File

@ -52,10 +52,10 @@ private:
TPofTCalc *fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable vector<double> fParForPofT; ///< parameters for the calculation of p(t)
mutable vector<double> fParForBofZ; ///< parameters for the calculation of B(z)
mutable vector<double> fParForPofB; ///< parameters for the calculation of P(B)
string fWisdom; ///< file name of the FFTW wisdom file
mutable std::vector<double> fParForPofT; ///< parameters for the calculation of p(t)
mutable std::vector<double> fParForBofZ; ///< parameters for the calculation of B(z)
mutable std::vector<double> fParForPofB; ///< parameters for the calculation of P(B)
std::string fWisdom; ///< file name of the FFTW wisdom file
unsigned int fNSteps; ///< number of points for which B(z) is calculated
ClassDef(TLondon1DHS,1)

View File

@ -66,7 +66,7 @@ private:
double *fPT; ///< array containing the discrete values of the polarization p(t)
double fTBin; ///< time resolution
int fNFFT; ///< length of the discrete 1D Fourier transform
const string fWisdom; ///< file name of the FFTW wisdom file
const std::string fWisdom; ///< file name of the FFTW wisdom file
bool fUseWisdom; ///< tag determining if a FFTW wisdom file is used
};

View File

@ -29,6 +29,8 @@
#ifndef _TVortex_H_
#define _TVortex_H_
#include <memory>
#include "PUserFcnBase.h"
#include "TPofTCalc.h"
@ -47,9 +49,9 @@ public:
private:
mutable std::vector<double> fPar; ///< parameters of the model
TBulkTriVortexLondonFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkTriVortexLondonFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -76,9 +78,9 @@ public:
private:
mutable std::vector<double> fPar; ///< parameters of the model
TBulkSqVortexLondonFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkSqVortexLondonFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -105,9 +107,9 @@ public:
private:
mutable std::vector<double> fPar; ///< parameters of the model
TBulkTriVortexMLFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkTriVortexMLFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -134,9 +136,9 @@ public:
private:
mutable std::vector<double> fPar; ///< parameters of the model
TBulkTriVortexAGLFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkTriVortexAGLFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -163,9 +165,9 @@ public:
private:
mutable std::vector<double> fPar; ///< parameters of the model
TBulkTriVortexAGLIIFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkTriVortexAGLIIFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -192,9 +194,9 @@ public:
private:
mutable std::vector<double> fPar; ///< parameters of the model
TBulkTriVortexNGLFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkTriVortexNGLFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -223,14 +225,14 @@ public:
void Calc(const std::vector<double>&) const;
const TPofTCalc* GetPolarizationPointer() const { return fPofT; }
const TPofTCalc* GetPolarizationPointer() const { return fPofT.get(); }
private:
mutable bool fValid; ///< tag indicating if the global part has been calculated
mutable std::vector<double> fPar; ///< parameter vector
TBulkAnisotropicTriVortexLondonFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkAnisotropicTriVortexLondonFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -287,14 +289,14 @@ public:
void Calc(const std::vector<double>&) const;
const TPofTCalc* GetPolarizationPointer() const { return fPofT; }
const TPofTCalc* GetPolarizationPointer() const { return fPofT.get(); }
private:
mutable bool fValid; ///< tag indicating if the global part has been calculated
mutable std::vector<double> fPar; ///< parameter vector
TBulkAnisotropicTriVortexMLFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkAnisotropicTriVortexMLFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)
@ -351,14 +353,14 @@ public:
void Calc(const std::vector<double>&) const;
const TPofTCalc* GetPolarizationPointer() const { return fPofT; }
const TPofTCalc* GetPolarizationPointer() const { return fPofT.get(); }
private:
mutable bool fValid; ///< tag indicating if the global part has been calculated
mutable std::vector<double> fPar; ///< parameter vector
TBulkAnisotropicTriVortexAGLFieldCalc *fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
TPofBCalc *fPofB; ///< static field distribution P(B)
TPofTCalc *fPofT; ///< muon spin polarization p(t)
std::unique_ptr<TBulkAnisotropicTriVortexAGLFieldCalc> fVortex; ///< spatial field distribution B(x,y) within the vortex lattice
std::unique_ptr<TPofBCalc> fPofB; ///< static field distribution P(B)
std::unique_ptr<TPofTCalc> fPofT; ///< muon spin polarization p(t)
mutable bool fCalcNeeded; ///< tag needed to avoid unnecessary calculations if the core parameters were unchanged
mutable bool fFirstCall; ///< tag for checking if the function operator is called the first time
mutable std::vector<double> fParForVortex; ///< parameters for the calculation of B(x,y)