Included a few more checks for the case, something goes wrong
This commit is contained in:
parent
c16916b563
commit
14dabdef45
@ -5,7 +5,7 @@
|
||||
Author: Bastian M. Wojek
|
||||
e-mail: bastian.wojek@psi.ch
|
||||
|
||||
2008/05/25
|
||||
2008/05/26
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -15,10 +15,10 @@
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
/* USED FOR DEBUGGING -----------------------
|
||||
/* USED FOR DEBUGGING -----------------------*/
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
--------------------------------------------*/
|
||||
/*--------------------------------------------*/
|
||||
|
||||
//------------------
|
||||
// Constructor of the TPofTCalc class - it creates the FFT plan
|
||||
@ -73,7 +73,7 @@ void TPofTCalc::DoFFT(const TPofBCalc &PofB) {
|
||||
double Bmin(PofB.GetBmin());
|
||||
|
||||
char debugfile[50];
|
||||
int n = sprintf (debugfile, "test_PB_%f_%ld.dat", Bmin, seconds);
|
||||
int n = sprintf (debugfile, "test_PB_%ld_%f.dat", seconds, Bmin);
|
||||
|
||||
if (n > 0) {
|
||||
ofstream of(debugfile);
|
||||
|
@ -5,7 +5,7 @@
|
||||
Author: Bastian M. Wojek
|
||||
e-mail: bastian.wojek@psi.ch
|
||||
|
||||
2008/05/25
|
||||
2008/05/26
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -67,6 +67,10 @@ TTrimSPData::TTrimSPData(const string &path, vector<string> &energyVec) {
|
||||
}
|
||||
|
||||
fOrigDataNZ = fDataNZ;
|
||||
|
||||
for(unsigned int i(0); i<fEnergy.size();i++)
|
||||
fIsNormalized.push_back(false);
|
||||
|
||||
}
|
||||
|
||||
//---------------------
|
||||
@ -88,7 +92,8 @@ vector<double> TTrimSPData::DataZ(double e) const {
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// Method returning actual n(z)-vector calculated by trim.SP and potentially altered by the WeightLayers-method for given energy[keV]
|
||||
// Method returning actual n(z)-vector calculated by trim.SP and
|
||||
// potentially altered by the WeightLayers- or the Normalize-method for given energy[keV]
|
||||
//---------------------
|
||||
|
||||
vector<double> TTrimSPData::DataNZ(double e) const {
|
||||
@ -157,6 +162,20 @@ void TTrimSPData::WeightLayers(double e, const vector<double>& interface, const
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int i(0); i<weight.size(); i++) {
|
||||
if(weight[i]-1.0)
|
||||
break;
|
||||
if(i == weight.size() - 1) {
|
||||
for(unsigned int j(0); j<fEnergy.size(); j++) {
|
||||
if(!(fEnergy[j] - e)) {
|
||||
fDataNZ[j] = fOrigDataNZ[j];
|
||||
fIsNormalized[j] = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int i(0); i<fEnergy.size(); i++) {
|
||||
if(!(fEnergy[i] - e)) {
|
||||
unsigned int k(0);
|
||||
@ -172,9 +191,13 @@ void TTrimSPData::WeightLayers(double e, const vector<double>& interface, const
|
||||
else
|
||||
fDataNZ[i][j] = fOrigDataNZ[i][j]*weight[k];
|
||||
}
|
||||
fIsNormalized[i] = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "No implantation profile available for the specified energy... No weighting done." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
//---------------------
|
||||
@ -187,10 +210,14 @@ double TTrimSPData::GetNofZ(double zz, double e) const {
|
||||
|
||||
for(unsigned int i(0); i<fEnergy.size(); i++) {
|
||||
if(!(fEnergy[i] - e)) {
|
||||
z = DataZ(e);
|
||||
nz = DataNZ(e);
|
||||
z = fDataZ[i];
|
||||
nz = fDataNZ[i];
|
||||
break;
|
||||
}
|
||||
if(i == fEnergy.size() - 1) {
|
||||
cout << "No implantation profile available for the specified energy... Quitting!" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
@ -210,3 +237,43 @@ double TTrimSPData::GetNofZ(double zz, double e) const {
|
||||
|
||||
return fabs(nz[i-1]+(nz[i]-nz[i-1])*(10.0*zz-z[i-1])/(z[i]-z[i-1]));
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// Method normalizing the n(z)-vector calculated by trim.SP for a given energy[keV]
|
||||
//---------------------
|
||||
|
||||
void TTrimSPData::Normalize(double e) {
|
||||
|
||||
for(unsigned int i(0); i<fEnergy.size(); i++) {
|
||||
if(!(fEnergy[i] - e)) {
|
||||
double nZsum = 0.0;
|
||||
for (unsigned int j(0); j<fDataZ[i].size(); j++)
|
||||
nZsum += fDataNZ[i][j];
|
||||
nZsum *= (fDataZ[i][1]-fDataZ[i][0]);
|
||||
for (unsigned int j(0); j<fDataZ[i].size(); j++)
|
||||
fDataNZ[i][j] /= nZsum;
|
||||
|
||||
fIsNormalized[i] = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// default
|
||||
cout << "No implantation profile available for the specified energy... No normalization done." << endl;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// Method telling you if the n(z)-vector calculated by trim.SP for a given energy [keV] has been normalized
|
||||
//---------------------
|
||||
|
||||
bool TTrimSPData::IsNormalized(double e) const {
|
||||
for(unsigned int i(0); i<fEnergy.size(); i++) {
|
||||
if(!(fEnergy[i] - e)) {
|
||||
return fIsNormalized[i];
|
||||
}
|
||||
}
|
||||
|
||||
cout << "No implantation profile available for the specified energy... Returning false! Check your code!" << endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
Author: Bastian M. Wojek
|
||||
e-mail: bastian.wojek@psi.ch
|
||||
|
||||
2008/05/25
|
||||
2008/05/26
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -25,8 +25,11 @@ TUserLondon::TUserLondon(const vector<unsigned int> &parNo, const vector<double>
|
||||
fPar.push_back(par[parNo[i]-1]);
|
||||
}
|
||||
|
||||
string rge_path("/home/l_wojek/nt/wojek/g/Bastian/ImplantationDepth/YBCO_PBCO-");
|
||||
string energy_arr[] = {"02_1", "02_5", "03_5", "05_0", "07_5", "10_0", "12_5", "15_0", "17_5", "19_0", "20_0", "22_5", "25_0"};
|
||||
// string rge_path("/home/l_wojek/nt/wojek/g/Bastian/ImplantationDepth/YBCO_PBCO-");
|
||||
// string energy_arr[] = {"02_1", "02_5", "03_5", "05_0", "07_5", "10_0", "12_5", "15_0", "17_5", "19_0", "20_0", "22_5", "25_0"};
|
||||
|
||||
string rge_path("/home/l_wojek/TrimSP/AuYBCO_2005/AuYBCO-500000-");
|
||||
string energy_arr[] = {"04_6", "09_6", "14_6", "18_6", "21_6", "24_6", "28_7"};
|
||||
|
||||
vector<string> energy_vec(energy_arr, energy_arr+(sizeof(energy_arr)/sizeof(energy_arr[0])));
|
||||
|
||||
@ -96,10 +99,11 @@ double TUserLondon::Eval(double t, const vector<double> &par) const {
|
||||
if (par_changed)
|
||||
fCalcNeeded = true;
|
||||
|
||||
// if model parameters have changed, recalculate B(z), P(B) and P(t)
|
||||
|
||||
/* DEBUGGING CODE COMMENTED -- quite a mess... sorry*/
|
||||
|
||||
// if model parameters have changed, recalculate B(z), P(B) and P(t)
|
||||
|
||||
if (fCalcNeeded) {
|
||||
|
||||
vector<double> par_for_PofT;
|
||||
|
@ -5,7 +5,7 @@
|
||||
Author: Bastian M. Wojek
|
||||
e-mail: bastian.wojek@psi.ch
|
||||
|
||||
2008/05/25
|
||||
2008/05/26
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -33,12 +33,15 @@ public:
|
||||
vector<double> OrigDataNZ(double) const;
|
||||
void WeightLayers(double, const vector<double>&, const vector<double>&) const;
|
||||
double GetNofZ(double, double) const;
|
||||
void Normalize(double);
|
||||
bool IsNormalized(double) const;
|
||||
|
||||
private:
|
||||
vector<double> fEnergy;
|
||||
vector< vector<double> > fDataZ;
|
||||
mutable vector< vector<double> > fDataNZ;
|
||||
vector< vector<double> > fOrigDataNZ;
|
||||
mutable vector<bool> fIsNormalized;
|
||||
};
|
||||
|
||||
#endif // _TTrimSPDataHandler_H_
|
||||
|
21
src/external/TFitPofB-lib/test/test.cpp
vendored
21
src/external/TFitPofB-lib/test/test.cpp
vendored
@ -101,8 +101,8 @@ int main(){
|
||||
|
||||
|
||||
*/
|
||||
unsigned int parNo_arr[] = {1, 3, 5, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
|
||||
double par_arr[] = {3.0, 999.0, 0.0, 999.0, 0.01, 999.0, 0.05, 999.0, 25.0, 999.0, 100.0, 10.0, 65.0, 50.0, 75.0, 180.0, 500.0, 1.0, 0.3, 1.0};
|
||||
unsigned int parNo_arr[] = {1, 3, 5, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18};
|
||||
double par_arr[] = {2.0, 999.0, 0.0, 999.0, 0.01, 999.0, 0.01, 999.0, 21.6, 999.0, 100.0, 5.0, 70.0, 75.0, 180.0, 500.0, 1.0, 0.3};
|
||||
|
||||
vector<unsigned int> parNo_vec(parNo_arr, parNo_arr+(sizeof(parNo_arr)/sizeof(parNo_arr[0])));
|
||||
vector<double> par_vec(par_arr, par_arr+(sizeof(par_arr)/sizeof(par_arr[0])));
|
||||
@ -133,7 +133,7 @@ int main(){
|
||||
of01.close();
|
||||
|
||||
par_vec_sub[1] += 10.0;
|
||||
par_vec_sub[11] -= 20.0;
|
||||
par_vec_sub[10] -= 20.0;
|
||||
|
||||
for (double i(0.); i<12.0; i+=0.003) {
|
||||
of02 << i << " " << fitter.Eval(i, par_vec_sub) << endl;
|
||||
@ -141,7 +141,7 @@ int main(){
|
||||
of02.close();
|
||||
|
||||
par_vec_sub[1] += 10.0;
|
||||
par_vec_sub[11] -= 20.0;
|
||||
par_vec_sub[10] -= 20.0;
|
||||
|
||||
for (double i(0.); i<12.0; i+=0.003) {
|
||||
of03 << i << " " << fitter.Eval(i, par_vec_sub) << endl;
|
||||
@ -156,7 +156,7 @@ int main(){
|
||||
of04.close();
|
||||
|
||||
par_vec_sub[1] += 10.0;
|
||||
par_vec_sub[11] -= 20.0;
|
||||
par_vec_sub[10] -= 20.0;
|
||||
|
||||
for (double i(0.); i<12.0; i+=0.003) {
|
||||
of05 << i << " " << fitter.Eval(i, par_vec_sub) << endl;
|
||||
@ -164,7 +164,7 @@ int main(){
|
||||
of05.close();
|
||||
|
||||
par_vec_sub[1] += 10.0;
|
||||
par_vec_sub[11] -= 20.0;
|
||||
par_vec_sub[10] -= 20.0;
|
||||
|
||||
for (double i(0.); i<12.0; i+=0.003) {
|
||||
of06 << i << " " << fitter.Eval(i, par_vec_sub) << endl;
|
||||
@ -185,17 +185,16 @@ int main(){
|
||||
}
|
||||
of08.close();
|
||||
|
||||
par_vec_sub[1] += 10.0;
|
||||
par_vec_sub[11] -= 20.0;
|
||||
par_vec_sub[1] = 0.0;
|
||||
par_vec_sub[10] = 1000.0;
|
||||
|
||||
for (double i(0.); i<12.0; i+=0.003) {
|
||||
of09 << i << " " << fitter.Eval(i, par_vec_sub) << endl;
|
||||
}
|
||||
of09.close();
|
||||
|
||||
par_vec_sub[1] = 0.0;
|
||||
par_vec_sub[11] = 500.0;
|
||||
par_vec_sub[13] = 0.8;
|
||||
par_vec_sub[10] = 500.0;
|
||||
par_vec_sub[12] = 1.0;
|
||||
|
||||
for (double i(0.); i<12.0; i+=0.003) {
|
||||
of10 << i << " " << fitter.Eval(i, par_vec_sub) << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user