more work on Raw -> Smart Pointers for external libs.
This commit is contained in:
17
src/external/BMWtools/BMWIntegrator.h
vendored
17
src/external/BMWtools/BMWIntegrator.h
vendored
@@ -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 = ∥
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
190
src/external/BMWtools/TTrimSPDataHandler.cpp
vendored
190
src/external/BMWtools/TTrimSPDataHandler.cpp
vendored
@@ -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;
|
||||
}
|
||||
|
||||
29
src/external/BMWtools/TTrimSPDataHandler.h
vendored
29
src/external/BMWtools/TTrimSPDataHandler.h
vendored
@@ -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_
|
||||
|
||||
Reference in New Issue
Block a user