modernized code to C++11 and newer.

This allows to analyze the code by external code analyzers. Since a lot is adopted,
the version is changed to 1.4.3
This commit is contained in:
2019-04-16 15:34:49 +02:00
parent e6d424e900
commit 795cd75b1e
136 changed files with 6870 additions and 7085 deletions

View File

@@ -36,8 +36,6 @@
#include <cmath>
#include <vector>
using namespace std;
/**
* <p>Alternative base class for 1D integrations using the GNU Scientific Library integrator.
* The difference to the other class is that here the integration parameters have to be supplied directly to the IntegrateFunc method.
@@ -67,7 +65,7 @@ class T2Integrator {
*/
inline double T2Integrator::FuncAtXgsl(double x, void *ptrPair)
{
pair<T2Integrator*, const vector<double>*> *pairOfPointers = static_cast<pair<T2Integrator*, const vector<double>*>*>(ptrPair);
std::pair<T2Integrator*, const std::vector<double>*> *pairOfPointers = static_cast<std::pair<T2Integrator*, const std::vector<double>*>*>(ptrPair);
return pairOfPointers->first->FuncAtX(x, *(pairOfPointers->second));
}
@@ -83,14 +81,14 @@ inline double T2Integrator::FuncAtXgsl(double x, void *ptrPair)
*/
inline double T2Integrator::IntegrateFunc(double x1, double x2, const std::vector<double> &par)
{
pair<T2Integrator*, const vector<double>*> ptrPair;
std::pair<T2Integrator*, const std::vector<double>*> ptrPair;
ptrPair.first = (this);
ptrPair.second = &par;
ROOT::Math::GSLIntegrator *integrator = new 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 = 0;
integrator = nullptr;
return value;
}
@@ -123,7 +121,7 @@ class TIntegrator {
double IntegrateFunc(double, double);
protected:
mutable vector<double> fPar; ///< parameters of the integrand
mutable std::vector<double> fPar; ///< parameters of the integrand
private:
static double FuncAtXgsl(double, void *);
@@ -146,7 +144,7 @@ inline TIntegrator::TIntegrator() : fFunc(0) {
inline TIntegrator::~TIntegrator(){
fPar.clear();
delete fIntegrator;
fIntegrator=0;
fIntegrator=nullptr;
fFunc=0;
}
@@ -193,7 +191,7 @@ class TMCIntegrator {
double IntegrateFunc(size_t, double *, double *);
protected:
mutable vector<double> fPar; ///< parameters of the integrand
mutable std::vector<double> fPar; ///< parameters of the integrand
private:
static double FuncAtXgsl(double *, size_t, void *);
@@ -216,7 +214,7 @@ inline TMCIntegrator::TMCIntegrator() : fFunc(0) {
inline TMCIntegrator::~TMCIntegrator(){
fPar.clear();
delete fMCIntegrator;
fMCIntegrator=0;
fMCIntegrator=nullptr;
fFunc=0;
}
@@ -265,7 +263,7 @@ class TDWaveGapIntegralCuhre {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -284,7 +282,7 @@ class TCosSqDWaveGapIntegralCuhre {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -303,7 +301,7 @@ class TSinSqDWaveGapIntegralCuhre {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -321,7 +319,7 @@ class TAnSWaveGapIntegralCuhre {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -339,7 +337,7 @@ class TAnSWaveGapIntegralDivonne {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -357,7 +355,7 @@ class TAnSWaveGapIntegralSuave {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -375,7 +373,7 @@ class TNonMonDWave1GapIntegralCuhre {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -393,7 +391,7 @@ class TNonMonDWave2GapIntegralCuhre {
double IntegrateFunc();
protected:
static vector<double> fPar; ///< parameters of the integrand
static std::vector<double> fPar; ///< parameters of the integrand
unsigned int fNDim; ///< dimension of the integral
};
@@ -485,7 +483,7 @@ class TIntBesselJ0Exp : public T2Integrator {
~TIntBesselJ0Exp() {}
private:
double FuncAtX(double, const vector<double>&) const;
double FuncAtX(double, const std::vector<double>&) const;
};
/**
@@ -496,7 +494,7 @@ class TIntBesselJ0Exp : public T2Integrator {
*
* \param x point where the function should be evaluated
*/
inline double TIntBesselJ0Exp::FuncAtX(double x, const vector<double> &par) const
inline double TIntBesselJ0Exp::FuncAtX(double x, const std::vector<double> &par) const
{
double w0t(TMath::TwoPi()*par[0]*x);
double j0;
@@ -518,7 +516,7 @@ class TIntSinGss : public T2Integrator {
~TIntSinGss() {}
private:
double FuncAtX(double, const vector<double>&) const;
double FuncAtX(double, const std::vector<double>&) const;
};
/**
@@ -529,7 +527,7 @@ class TIntSinGss : public T2Integrator {
*
* \param x point where the function should be evaluated
*/
inline double TIntSinGss::FuncAtX(double x, const vector<double> &par) const
inline double TIntSinGss::FuncAtX(double x, const std::vector<double> &par) const
{
return TMath::Sin(TMath::TwoPi()*par[0]*x) * TMath::Exp(-0.5*par[1]*par[1]*x*x);
}
@@ -546,7 +544,7 @@ class TIntSGInterpolation : public T2Integrator {
~TIntSGInterpolation() {}
private:
double FuncAtX(double, const vector<double>&) const;
double FuncAtX(double, const std::vector<double>&) const;
};
/**
@@ -557,7 +555,7 @@ class TIntSGInterpolation : public T2Integrator {
*
* \param x point where the function should be evaluated
*/
inline double TIntSGInterpolation::FuncAtX(double x, const vector<double> &par) const
inline double TIntSGInterpolation::FuncAtX(double x, const std::vector<double> &par) const
{
// Parameters: nu_L [MHz], a [1/us], lambda [1/us], beta [1], t [us]
double wt(TMath::TwoPi()*par[0]*x);
@@ -600,7 +598,7 @@ class TFirstUniaxialGssKTIntegral : public T2Integrator {
virtual ~TFirstUniaxialGssKTIntegral() {}
private:
virtual double FuncAtX(double, const vector<double>&) const; // variable: x
virtual double FuncAtX(double, const std::vector<double>&) const; // variable: x
};
/**
@@ -611,7 +609,7 @@ class TFirstUniaxialGssKTIntegral : public T2Integrator {
*
* \param x point where the function should be evaluated
*/
inline double TFirstUniaxialGssKTIntegral::FuncAtX(double x, const vector<double> &par) const
inline double TFirstUniaxialGssKTIntegral::FuncAtX(double x, const std::vector<double> &par) const
{
double eps(par[0]*par[0]/(par[1]*par[1]) - 1.0);
double p(1.0 + eps*x*x);
@@ -630,7 +628,7 @@ class TSecondUniaxialGssKTIntegral : public T2Integrator {
virtual ~TSecondUniaxialGssKTIntegral() {}
private:
virtual double FuncAtX(double, const vector<double>&) const; // variable: x
virtual double FuncAtX(double, const std::vector<double>&) const; // variable: x
};
/**
@@ -641,7 +639,7 @@ class TSecondUniaxialGssKTIntegral : public T2Integrator {
*
* \param x point where the function should be evaluated
*/
inline double TSecondUniaxialGssKTIntegral::FuncAtX(double x, const vector<double> &par) const
inline double TSecondUniaxialGssKTIntegral::FuncAtX(double x, const std::vector<double> &par) const
{
double eps(par[0]*par[0]/(par[1]*par[1]) - 1.0);
double p(1.0 + eps*x*x);

View File

@@ -32,7 +32,6 @@
#include <cstdlib>
#include <iostream>
using namespace std;
#include <cassert>
@@ -245,8 +244,8 @@ void BMWStartupHandler::OnComment(const char *str)
*/
void BMWStartupHandler::OnWarning(const char *str)
{
cerr << endl << "BMWStartupHandler::OnWarning: BMWStartupHandler **WARNING** " << str;
cerr << endl;
std::cerr << std::endl << "BMWStartupHandler::OnWarning: BMWStartupHandler **WARNING** " << str;
std::cerr << std::endl;
}
//--------------------------------------------------------------------------
@@ -259,8 +258,8 @@ void BMWStartupHandler::OnWarning(const char *str)
*/
void BMWStartupHandler::OnError(const char *str)
{
cerr << endl << "BMWStartupHandler::OnError: BMWStartupHandler **ERROR** " << str;
cerr << endl;
std::cerr << std::endl << "BMWStartupHandler::OnError: BMWStartupHandler **ERROR** " << str;
std::cerr << std::endl;
}
//--------------------------------------------------------------------------
@@ -273,8 +272,8 @@ void BMWStartupHandler::OnError(const char *str)
*/
void BMWStartupHandler::OnFatalError(const char *str)
{
cerr << endl << "BMWStartupHandler::OnFatalError: BMWStartupHandler **FATAL ERROR** " << str;
cerr << endl;
std::cerr << std::endl << "BMWStartupHandler::OnFatalError: BMWStartupHandler **FATAL ERROR** " << str;
std::cerr << std::endl;
}
//--------------------------------------------------------------------------
@@ -305,107 +304,107 @@ void BMWStartupHandler::CheckLists()
if(fLF) {
// check if delta_t_LF is given, if not set default
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check specified LF time resolution for the Laplace transform ... " << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check specified LF time resolution for the Laplace transform ... " << std::endl;
if(!fDeltatLF) {
cout << "BMWStartupHandler::CheckLists: You did not specify the LF time resolution. Setting the default (0.04 ns)." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify the LF time resolution. Setting the default (0.04 ns)." << std::endl;
fDeltatLF = 0.00004;
} else {
if(fDebug)
cout << fDeltatLF << " us" << endl;
std::cout << fDeltatLF << " us" << std::endl;
}
// check if N_LF is given, if not set default
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check length of the Laplace transform ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check length of the Laplace transform ..." << std::endl;
if (!fNStepsLF) {
cout << "BMWStartupHandler::CheckLists: You did not specify the length of the Laplace transform. Setting the default (524288)." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify the length of the Laplace transform. Setting the default (524288)." << std::endl;
fNStepsLF = 524288;
} else {
if(fDebug)
cout << fNStepsLF << endl;
std::cout << fNStepsLF << std::endl;
}
} else {
// check if delta_t is given, if not set default
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check specified time resolution ... " << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check specified time resolution ... " << std::endl;
if(!fDeltat) {
cout << "BMWStartupHandler::CheckLists: You did not specify the time resolution. Setting the default (10 ns)." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify the time resolution. Setting the default (10 ns)." << std::endl;
fDeltat = 0.01;
} else {
if(fDebug)
cout << fDeltat << " us" << endl;
std::cout << fDeltat << " us" << std::endl;
}
// check if delta_B is given, if not set default
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check specified field resolution ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check specified field resolution ..." << std::endl;
if(!fDeltaB) {
cout << "BMWStartupHandler::CheckLists: You did not specify the field resolution. Setting the default (0.1 G)." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify the field resolution. Setting the default (0.1 G)." << std::endl;
fDeltaB = 0.1;
} else {
if(fDebug)
cout << fDeltaB << " G" << endl;
std::cout << fDeltaB << " G" << std::endl;
}
}
// check if any wisdom-file is specified
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check wisdom file ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check wisdom file ..." << std::endl;
if (!fWisdomFile.size()) {
cout << "BMWStartupHandler::CheckLists: You did not specify a wisdom file. No FFTW plans will be loaded or saved." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify a wisdom file. No FFTW plans will be loaded or saved." << std::endl;
fWisdomFile = "";
} else {
if(fDebug)
cout << fWisdomFile << endl;
std::cout << fWisdomFile << std::endl;
}
// check if any float-wisdom-file is specified
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check float-wisdom file ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check float-wisdom file ..." << std::endl;
if (!fWisdomFile.size()) {
cout << "BMWStartupHandler::CheckLists: You did not specify a float-wisdom file. No FFTW plans will be loaded or saved." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify a float-wisdom file. No FFTW plans will be loaded or saved." << std::endl;
fWisdomFileFloat = "";
} else {
if(fDebug)
cout << fWisdomFileFloat << endl;
std::cout << fWisdomFileFloat << std::endl;
}
if (fLEM) {
// check if any data path is given
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check data path ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check data path ..." << std::endl;
if (fDataPath.empty()) {
cerr << "BMWStartupHandler::CheckLists: This is not going to work, you have to set a valid data path where to find the rge-files in the xml-file!" << endl;
std::cerr << "BMWStartupHandler::CheckLists: This is not going to work, you have to set a valid data path where to find the rge-files in the xml-file!" << std::endl;
assert(!fDataPath.empty());
} else {
if(fDebug)
cout << fDataPath << endl;
std::cout << fDataPath << std::endl;
}
// check if any energies are given
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check energy list ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check energy list ..." << std::endl;
if (fEnergyList.size() != fEnergyLabelList.size()) {
cerr << "BMWStartupHandler::CheckLists: The number of energies and energy labels are different! Please fix it!" << endl \
<< "BMWStartupHandler::CheckLists: The program will be terminated now!" << endl;
std::cerr << "BMWStartupHandler::CheckLists: The number of energies and energy labels are different! Please fix it!" << std::endl \
<< "BMWStartupHandler::CheckLists: The program will be terminated now!" << std::endl;
assert(fEnergyList.size() == fEnergyLabelList.size());
}
if (fEnergyList.empty()) {
cerr << "BMWStartupHandler::CheckLists: Energy list empty!" << endl \
<< "BMWStartupHandler::CheckLists: Trying to use the standard energies: 0.0 to 35.0 keV in 0.1 keV steps" << endl;
std::cerr << "BMWStartupHandler::CheckLists: Energy list empty!" << std::endl \
<< "BMWStartupHandler::CheckLists: Trying to use the standard energies: 0.0 to 35.0 keV in 0.1 keV steps" << std::endl;
for (double x(0.0); x<= 35.0; x+=0.1) {
fEnergyList.push_back(x);
}
}
if (fEnergyLabelList.empty()) {
cerr << "BMWStartupHandler::CheckLists: Energy label list empty!" << endl \
<< "BMWStartupHandler::CheckLists: Trying to use the specified energies as labels in the format %02.1f..." << endl \
<< "BMWStartupHandler::CheckLists: Most probably this will go wrong and should therefore be fixed in the xml-file!" << endl;
std::cerr << "BMWStartupHandler::CheckLists: Energy label list empty!" << std::endl \
<< "BMWStartupHandler::CheckLists: Trying to use the specified energies as labels in the format %02.1f..." << std::endl \
<< "BMWStartupHandler::CheckLists: Most probably this will go wrong and should therefore be fixed in the xml-file!" << std::endl;
char eChar[5];
for(unsigned int i(0); i<fEnergyList.size(); i++) {
sprintf(eChar, "%02.1f", fEnergyList[i]);
fEnergyLabelList.push_back(string(eChar));
fEnergyLabelList.push_back(std::string(eChar));
}
}
@@ -416,33 +415,33 @@ void BMWStartupHandler::CheckLists()
}
if(fDebug) {
cout << "Energies and Labels:" << endl;
for ( map<double, string>::const_iterator iter(fEnergies.begin()); iter != fEnergies.end(); ++iter )
cout << iter->first << " " << iter->second << endl;
std::cout << "Energies and Labels:" << std::endl;
for ( std::map<double, std::string>::const_iterator iter(fEnergies.begin()); iter != fEnergies.end(); ++iter )
std::cout << iter->first << " " << iter->second << std::endl;
}
// check if any number of steps for the theory function is specified
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check number of steps for theory ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check number of steps for theory ..." << std::endl;
if (!fNSteps) {
cout << "BMWStartupHandler::CheckLists: You did not specify the number of steps for the theory. Setting the default (3000)." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify the number of steps for the theory. Setting the default (3000)." << std::endl;
fNSteps = 3000;
} else {
if(fDebug)
cout << fNSteps << endl;
std::cout << fNSteps << std::endl;
}
}
if (fVortex) {
// check if any number of steps for the theory function is specified
if(fDebug)
cout << endl << "BMWStartupHandler::CheckLists: check number of steps for Vortex grid ..." << endl;
std::cout << std::endl << "BMWStartupHandler::CheckLists: check number of steps for Vortex grid ..." << std::endl;
if (!fGridSteps) {
cout << "BMWStartupHandler::CheckLists: You did not specify the number of steps for the grid. Setting the default (256)." << endl;
std::cout << "BMWStartupHandler::CheckLists: You did not specify the number of steps for the grid. Setting the default (256)." << std::endl;
fGridSteps = 256;
} else {
if(fDebug)
cout << fGridSteps << endl;
std::cout << fGridSteps << std::endl;
}
}
}

View File

@@ -11,7 +11,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2014 by Andreas Suter, Bastian M. Wojek *
* Copyright (C) 2007-2019 by Andreas Suter, Bastian M. Wojek *
* *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -67,12 +67,12 @@ class BMWStartupHandler : public TQObject {
virtual void CheckLists();
virtual const string GetDataPath() const { return fDataPath; } ///< returns the path to TRIM.SP files
virtual map<double, string> GetEnergies() const { return fEnergies; } ///< returns energies and file labels of available TRIM.SP files
virtual const std::string GetDataPath() const { return fDataPath; } ///< returns the path to TRIM.SP files
virtual std::map<double, std::string> GetEnergies() const { return fEnergies; } ///< returns energies and file labels of available TRIM.SP files
virtual const double GetDeltat() const { return fDeltat; } ///< returns the time resolution of P(t) when using Fourier transforms
virtual const double GetDeltaB() const { return fDeltaB; } ///< returns the field resolution of p(B) when using Fourier transforms
virtual const string GetWisdomFile() const { return fWisdomFile; } ///< returns the path to the FFTW3 double-wisdom file
virtual const string GetWisdomFileFloat() const { return fWisdomFileFloat; } ///< returns the path to the FFTW3 float-wisdom file
virtual const std::string GetWisdomFile() const { return fWisdomFile; } ///< returns the path to the FFTW3 double-wisdom file
virtual const std::string GetWisdomFileFloat() const { return fWisdomFileFloat; } ///< returns the path to the FFTW3 float-wisdom file
virtual const unsigned int GetNSteps() const { return fNSteps; } ///< returns the number of steps in one-dimensional theory functions
virtual const unsigned int GetGridSteps() const { return fGridSteps; } ///< returns the number of steps in each direction when calculating two-dimensional spatial field distributions
virtual const double GetDeltatLF() const { return fDeltatLF; } ///< returns the time resolution of P(t) when using Laplace transforms for the calculation of LF-relaxation functions
@@ -90,14 +90,14 @@ class BMWStartupHandler : public TQObject {
bool fLEM; ///< low-energy muSR flag
bool fVortex; ///< vortex-lattice flag
bool fLF; ///< longitudinal-field flag
string fDataPath; ///< path to TRIM.SP files
vector<string> fEnergyLabelList; ///< file labels of the TRIM.SP files
vector<double> fEnergyList; ///< muon implantation energies of the TRIM.SP files
map<double, string> fEnergies; ///< muon implantation energies and file labels of the TRIM.SP files
std::string fDataPath; ///< path to TRIM.SP files
std::vector<std::string> fEnergyLabelList; ///< file labels of the TRIM.SP files
std::vector<double> fEnergyList; ///< muon implantation energies of the TRIM.SP files
std::map<double, std::string> fEnergies; ///< muon implantation energies and file labels of the TRIM.SP files
double fDeltat; ///< time resolution of P(t) when using Fourier transforms
double fDeltaB; ///< field resolution of p(B) when using Fourier transforms
string fWisdomFile; ///< FFTW3 double-wisdom file
string fWisdomFileFloat; ///< FFTW3 float-wisdom file
std::string fWisdomFile; ///< FFTW3 double-wisdom file
std::string fWisdomFileFloat; ///< FFTW3 float-wisdom file
unsigned int fNSteps; ///< number of steps in one-dimensional theory functions
unsigned int fGridSteps; ///< number of steps in each direction when calculating two-dimensional spatial field distributions
double fDeltatLF; ///< time resolution of P(t) when using Laplace transforms for the calculation of LF-relaxation functions