Minor change in reading TrimSP-files

This commit is contained in:
Bastian M. Wojek 2009-11-19 14:52:12 +00:00
parent cc7bfa3071
commit 12d16bab46
5 changed files with 47 additions and 51 deletions

View File

@ -37,6 +37,8 @@
#include <iostream>
using namespace std;
#include <cassert>
#include "TFitPofBStartupHandler.h"
ClassImpQ(TFitPofBStartupHandler)
@ -61,6 +63,8 @@ TFitPofBStartupHandler::~TFitPofBStartupHandler()
{
// clean up
fEnergyList.clear();
fEnergyLabelList.clear();
fEnergies.clear();
}
//--------------------------------------------------------------------------
@ -315,7 +319,7 @@ void TFitPofBStartupHandler::CheckLists()
cout << endl << "TFitPofBStartupHandler::CheckLists: check data path ..." << endl;
if (!fDataPath.size()) {
cout << "TFitPofBStartupHandler::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;
exit(-1);
assert(fDataPath.size());
} else {
if(fDebug)
cout << fDataPath << endl;
@ -325,7 +329,9 @@ void TFitPofBStartupHandler::CheckLists()
if(fDebug)
cout << endl << "TFitPofBStartupHandler::CheckLists: check energy list ..." << endl;
if (fEnergyList.size() != fEnergyLabelList.size()) {
cout << "TFitPofBStartupHandler::CheckLists: The number of energies and energy labels are different! Please fix it!" << endl;
cout << "TFitPofBStartupHandler::CheckLists: The number of energies and energy labels are different! Please fix it!" << endl \
<< "TFitPofBStartupHandler::CheckLists: The program will be terminated now!" << endl;
assert(fEnergyList.size() == fEnergyLabelList.size());
}
if (fEnergyList.empty()) {
cout << "TFitPofBStartupHandler::CheckLists: Energy list empty!" << endl \
@ -344,15 +350,20 @@ void TFitPofBStartupHandler::CheckLists()
fEnergyLabelList.push_back(string(eChar));
}
}
// fill the energies and labels in the pair-vector
fEnergies.clear();
pair<double, string> p;
for(unsigned int i(0); i < fEnergyList.size(); i++) {
p.first = fEnergyList[i];
p.second = fEnergyLabelList[i];
fEnergies.push_back(p);
}
if(fDebug) {
cout << "Energies: ";
for (unsigned int i (0); i < fEnergyList.size(); i++)
cout << fEnergyList[i] << " ";
cout << endl;
cout << "Energy Labels: ";
for (unsigned int i (0); i < fEnergyLabelList.size(); i++)
cout << fEnergyLabelList[i] << " ";
cout << endl;
cout << "Energies and Labels:";
for (unsigned int i (0); i < fEnergies.size(); i++)
cout << fEnergies[i].first << " " << fEnergies[i].second << endl;
}
// check if any number of steps for the theory function is specified

View File

@ -193,8 +193,7 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0); // phase
fParForPofT.push_back(startupHandler->GetDeltat());
@ -207,7 +206,7 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;
@ -355,8 +354,7 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true), fCallCounter(0
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -366,7 +364,7 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true), fCallCounter(0
fParForPofB.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(0.0);
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;
@ -507,8 +505,7 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true), fLastTwoChange
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -518,7 +515,7 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true), fLastTwoChange
fParForPofB.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(0.0);
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;
@ -662,8 +659,7 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -676,7 +672,7 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
fParForPofB.push_back(0.01); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;
@ -829,8 +825,7 @@ TProximity1D1LHSGss::TProximity1D1LHSGss() : fCalcNeeded(true), fFirstCall(true)
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -841,7 +836,7 @@ TProximity1D1LHSGss::TProximity1D1LHSGss() : fCalcNeeded(true), fFirstCall(true)
fParForPofB.push_back(0.0);
// fParForPofB.push_back(0.0);
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;
@ -968,8 +963,7 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true), fLastThreeChan
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -979,7 +973,7 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true), fLastThreeChan
fParForPofB.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(0.0);
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;
@ -1137,8 +1131,7 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true), fLastThreeCh
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -1148,7 +1141,7 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true), fLastThreeCh
fParForPofB.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(0.0);
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;
@ -1289,8 +1282,8 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
//
// fNSteps = startupHandler->GetNSteps();
// fWisdom = startupHandler->GetWisdomFile();
// vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
// string rge_path(startupHandler->GetDataPath());
// vector<string> energy_vec(startupHandler->GetEnergyList());
//
// fParForPofT.push_back(0.0);
// fParForPofT.push_back(startupHandler->GetDeltat());
@ -1458,8 +1451,7 @@ TLondon1D3LSub::TLondon1D3LSub() : fCalcNeeded(true), fFirstCall(true), fWeights
fNSteps = startupHandler->GetNSteps();
fWisdom = startupHandler->GetWisdomFile();
string rge_path(startupHandler->GetDataPath());
vector<string> energy_label_vec(startupHandler->GetEnergyLabelList());
vector<double> energy_vec(startupHandler->GetEnergyList());
vector< pair<double, string> > energy_vec(startupHandler->GetEnergies());
fParForPofT.push_back(0.0);
fParForPofT.push_back(startupHandler->GetDeltat());
@ -1469,7 +1461,7 @@ TLondon1D3LSub::TLondon1D3LSub() : fCalcNeeded(true), fFirstCall(true), fWeights
fParForPofB.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(0.0);
TTrimSPData *x = new TTrimSPData(rge_path, energy_label_vec, energy_vec);
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
fImpProfile = x;
x = 0;

View File

@ -58,25 +58,18 @@ using namespace std;
// Also always use the same format within one energyVec - otherwise sorting of the vector will not work properly!
//--------------------
TTrimSPData::TTrimSPData(const string &path, const vector<string> &energyLabelVec, const vector<double> &energyVec) {
TTrimSPData::TTrimSPData(const string &path, vector< pair<double, string> > &energies) {
// sort the energies in ascending orders - this might be useful for later applications (energy-interpolations etc.)
// Do not do it at the moment until I find a suitable way to sort energy and energy-labels at once.
// sort(energyVec.begin(), energyVec.end());
if (energyLabelVec.size() != energyVec.size()) {
cout << "TTrimSPData::TTrimSPData: The number of energies and labels have to be the same!" << endl;
cout << "TTrimSPData::TTrimSPData: Please fix this problem! The programme will be terminated now!" << endl;
assert(false);
}
// sort the energies in ascending order - this might be useful for later applications (energy-interpolations etc.)
sort(energies.begin(), energies.end());
double zz(0.0), nzz(0.0);
vector<double> vzz, vnzz;
string word, energyStr;
for(unsigned int i(0); i<energyVec.size(); i++) {
for(unsigned int i(0); i<energies.size(); i++) {
energyStr = path + energyLabelVec[i] + ".rge";
energyStr = path + energies[i].second + ".rge";
ifstream *rgeFile = new ifstream(energyStr.c_str());
if(! *rgeFile) {
@ -84,7 +77,7 @@ TTrimSPData::TTrimSPData(const string &path, const vector<string> &energyLabelVe
delete rgeFile;
rgeFile = 0;
} else {
fEnergy.push_back(energyVec[i]);
fEnergy.push_back(energies[i].first);
while(*rgeFile >> word)
if(word == "PARTICLES") break;

View File

@ -60,8 +60,7 @@ class TFitPofBStartupHandler : public TQObject {
virtual void CheckLists();
virtual const string GetDataPath() const { return fDataPath; }
virtual vector<string> GetEnergyLabelList() const { return fEnergyLabelList; }
virtual vector<double> GetEnergyList() const { return fEnergyList; }
virtual vector< pair<double, string> > GetEnergies() const { return fEnergies; }
virtual const double GetDeltat() const { return fDeltat; }
virtual const double GetDeltaB() const { return fDeltaB; }
virtual const string GetWisdomFile() const { return fWisdomFile; }
@ -80,6 +79,7 @@ class TFitPofBStartupHandler : public TQObject {
string fDataPath;
vector<string> fEnergyLabelList;
vector<double> fEnergyList;
vector< pair<double, string> > fEnergies;
double fDeltat;
double fDeltaB;
string fWisdomFile;

View File

@ -40,7 +40,7 @@ class TTrimSPData {
public:
TTrimSPData(const string&, const vector<string>&, const vector<double>&);
TTrimSPData(const string&, vector< pair<double, string> >&);
~TTrimSPData() {
fDataZ.clear();