diff --git a/AculCalib/AculCalPars.h b/AculCalib/AculCalPars.h index 6246de32b91533f38d819fe284c8f882966409bf..e451f1de858abe5e6090b14f6c232f3ac1793bb8 100644 --- a/AculCalib/AculCalPars.h +++ b/AculCalib/AculCalPars.h @@ -12,15 +12,11 @@ #include #include -//#include "TObject.h" #include "TString.h" #include "TArrayD.h" #include "TArrayI.h" #include "TCutG.h" -//todo ommit this constant -#define NOCALFILES 5 - using std::cout; using std::endl; using std::vector; @@ -31,6 +27,9 @@ protected: //general TString fParFileName; + + //todo energies used for calibration should be in this class + //CsI parameters // Int_t fNoCrystals; // @@ -63,14 +62,12 @@ public: virtual const char* GetParticleName() {return 0;} virtual Int_t GetNoRawFiles() {return 0;}; virtual const char* GetFileName(Int_t i) {return 0;}; -// const char* GetCutName(Int_t i); virtual Int_t GetNoEPoints() {return 0;} virtual Double_t GetCalEnergy(Int_t i) {return 0.;}; virtual const char* GetCutsFileName() {return 0;} virtual Int_t GetNoCuts() {return 0;} virtual TCutG* GetCut(Int_t i) {return 0;}; virtual TCutG* GetCut(const char* cutName) {return 0;}; -// virtual TCutG* GetCutName(Int_t i) {return 0;}; virtual Int_t GetMinChannel(Int_t energy, Int_t crystal) {return 0;}; virtual Int_t GetMaxChannel(Int_t energy, Int_t crystal) {return 0;}; diff --git a/AculCalib/AculCalParsScint.cpp b/AculCalib/AculCalParsScint.cpp index 1e1da1fe24e6b8113d82d8b4d28d84ddd8de64e9..49bdca5662225030b8f0afb043b210de2d0ec52b 100644 --- a/AculCalib/AculCalParsScint.cpp +++ b/AculCalib/AculCalParsScint.cpp @@ -72,11 +72,14 @@ void AculCalParsScint::SetPars() { if ( line.BeginsWith("files") ) { sscanf(line.Data(), "%*s %d", &i); fNoFiles = i; + fFilePars.resize(fNoFiles); for (Int_t j = 0; j < fNoFiles; j++) { line.ReadLine(infile); sscanf(line, "%s", fname); word = fname; - fFileName.push_back(fname); + fFilePars[j].SetRawFileName(fname); + fFilePars[j].SetNoCrystals(fNoCrystals); + fFilePars[j].Init(); } continue; } @@ -101,17 +104,16 @@ void AculCalParsScint::SetPars() { if ( line.BeginsWith("energy") ) { sscanf(line.Data(), "%*s %lf", &en); - fE.push_back(en); + fFilePars[fEnergyPoints].SetEnergy(en); fEnergyPoints++; - vector newM; - fPeakMin.push_back(newM); - fPeakMax.push_back(newM); continue; } + sscanf(line.Data(), "%d %d %d", &i, &min, &max); - fPeakMin.at(fEnergyPoints-1).push_back(min); - fPeakMax.at(fEnergyPoints-1).push_back(max); + fFilePars.at(fEnergyPoints-1).SetPeakMin(i, min); + fFilePars.at(fEnergyPoints-1).SetPeakMax(i, max); + }//while infile.close(); @@ -124,24 +126,20 @@ void AculCalParsScint::PrintParameters(const char* option) { cout << "Parameters read from file \"" << fParFileName.Data() << "\"." << endl; cout << "\tCalibration of detector \"" << fDetName << "\" with " << fNoCrystals << " crystals." << endl; -// cout << "\tNumber of crystals: " << fNoCrystals << endl; cout << "\tParticle: " << fPartName << endl; cout << "\tInput files with raw data (" << fNoFiles << "):" << endl; - for (Int_t i = 0; i < (Int_t)fFileName.size(); i++) { -// cout << i << endl; - cout << "\t " << fFileName[i] << endl; + for (Int_t i = 0; i < (Int_t)fFilePars.size(); i++) { + cout << "\t " << GetFileName(i) << endl; } cout << "\tInput energies (" << fNoFiles << "):" << endl; - for (Int_t i = 0; i < (Int_t)fE.size(); i++) { - // cout << i << endl; - cout << "\t " << fE[i] << " MeV" << endl; + for (Int_t i = 0; i <= (Int_t)fFilePars.size(); i++) { + cout << "\t " << fFilePars[i].GetEnergy() << " MeV" << endl; } cout << "\tInput file with " << fNoCuts << " cuts: \"" << fCutsFileName << "\"" << endl; if (opt.Contains("all")) { for (Int_t i = 0; i < (Int_t)fCutName.size(); i++) { - // cout << i << endl; cout << "\t cut: \"" << fCutName[i] << "\"" << endl; } } @@ -149,13 +147,10 @@ void AculCalParsScint::PrintParameters(const char* option) { if (!opt.Contains("all")) return; cout << "\tPeak limits for particular channels and energies:" << endl; - for (Int_t k = 0; k < (Int_t)fPeakMin.size(); k++) { - - cout << "\t Set number: " << k << "; energy: " << fE[k] << " MeV" << endl; - - for (Int_t i = 0; i < (Int_t)fPeakMin[k].size(); i++) { - // cout << i << endl; - cout << "\t\t " << fPeakMin[k][i] << "\t" << fPeakMax[k][i] << endl; + for (Int_t k = 0; k < (Int_t)fFilePars.size(); k++) { + cout << "\t Set number: " << k << "; energy: " << fFilePars[k].GetEnergy() << " MeV" << endl; + for (Int_t i = 0; i < (Int_t)fFilePars[k].GetNoCrystals(); i++) { + cout << "\t\t " << fFilePars[k].GetPeakMin(i) << "\t" << fFilePars[k].GetPeakMax(i) << endl; } } @@ -170,29 +165,24 @@ void AculCalParsScint::Reset() { fPartName = ""; fNoFiles = 0; + fFilePars.clear(); fEnergyPoints = 0; - fE.clear(); - fCutsFileName = ""; fNoCuts = 0; //number of cuts - fFileName.clear(); fCutName.clear(); - fPeakMin.clear(); - fPeakMax.clear(); - return; } const char* AculCalParsScint::GetFileName(Int_t i) { - if ( i > (Int_t)fFileName.size()-1 ) { - cerr << "\"AculCalParsScint::GetFileName\" index i cannot be higher than " << fFileName.size() - 1 << endl; + if ( i >= (Int_t)fFilePars.size() ) { + cerr << "\"AculCalParsScint::GetFileName\" index i cannot be higher than " << fFilePars.size() - 1 << endl; return 0; } - return fFileName[i].Data(); + return fFilePars[i].GetRawFileName(); } const char* AculCalParsScint::GetCutName(Int_t i) { @@ -214,11 +204,6 @@ TCutG* AculCalParsScint::GetCut(Int_t i) { TCutG* AculCalParsScint::GetCut(const char* cutName) { -// TClonesArray cutsCol; -// -// for (Int_t i = 0; i < nCuts; i++) { -// cutsCol[i] = (TCutG*)fCuts->Get(cutNames[i]); -// } const TString cName = cutName; for (Int_t i = 0; i <= (Int_t)fCuts.size(); i++) { @@ -232,43 +217,45 @@ TCutG* AculCalParsScint::GetCut(const char* cutName) { Double_t AculCalParsScint::GetCalEnergy(Int_t i) { - if ( i > (Int_t)fE.size()-1 ) { - cerr << "\"AculCalParsScint::GetCalEnergy\" index i cannot be higher than " << fE.size() - 1 << endl; + if ( i >= (Int_t)fFilePars.size() ) { + cerr << "\"AculCalParsScint::GetCalEnergy\" index i cannot be higher than " << fFilePars.size() - 1 << endl; return 0; } - return fE[i]; + return fFilePars[i].GetEnergy(); } Int_t AculCalParsScint::GetMinChannel(Int_t energy, Int_t crystal) { - if ( energy > (Int_t)fPeakMin.size()-1 ) { - cerr << "\"AculCalParsScint::GetMinChannel\" index \"energy\" cannot be higher than " << fPeakMin.size() - 1 << endl; + if ( energy >= (Int_t)fFilePars.size() ) { + cerr << "\"AculCalParsScint::GetMinChannel\" index \"energy\" cannot be higher than " + << fFilePars.size() - 1 << endl; return 0; } - vector v = fPeakMin[energy]; - if ( crystal > (Int_t)v.size()-1 ) { - cerr << "\"AculCalParsScint::GetMinChannel\" index \"crystal\" cannot be higher than " << v.size() - 1 << endl; + if ( crystal >= fFilePars[energy].GetNoCrystals() ) { + cerr << "\"AculCalParsScint::GetMinChannel\" index \"crystal\" cannot be higher than " + << fFilePars[energy].GetNoCrystals() - 1 << endl; return 0; } - return fPeakMin[energy][crystal]; + return fFilePars[energy].GetPeakMin(crystal); } Int_t AculCalParsScint::GetMaxChannel(Int_t energy, Int_t crystal) { - if ( energy > (Int_t)fPeakMax.size()-1 ) { - cerr << "\"AculCalParsScint::GetMinChannel\" index \"energy\" cannot be higher than " << fPeakMax.size() - 1 << endl; + if ( energy >= (Int_t)fFilePars.size() ) { + cerr << "\"AculCalParsScint::GetMinChannel\" index \"energy\" cannot be higher than " + << fFilePars.size() - 1 << endl; return 0; } - vector v = fPeakMax[energy]; - if ( crystal > (Int_t)v.size()-1 ) { - cerr << "\"AculCalParsScint::GetMinChannel\" index \"crystal\" cannot be higher than " << v.size() - 1 << endl; + if ( crystal >= fFilePars[energy].GetNoCrystals() ) { + cerr << "\"AculCalParsScint::GetMinChannel\" index \"crystal\" cannot be higher than " + << fFilePars[energy].GetNoCrystals() - 1 << endl; return 0; } - return fPeakMax[energy][crystal]; + return fFilePars[energy].GetPeakMax(crystal); } void AculCalParsScint::LoadCuts() { diff --git a/AculCalib/AculCalParsScint.h b/AculCalib/AculCalParsScint.h index 4d48574f9508e36e48ba6e6f6fb96760c22689f6..5980e04f1b9ea65ca9c9c3a3262e83491c9f66f7 100644 --- a/AculCalib/AculCalParsScint.h +++ b/AculCalib/AculCalParsScint.h @@ -9,6 +9,7 @@ #define ACULCALIB_ACULCALPARSSCINT_H_ #include "AculCalPars.h" +#include "AculCalParsScintFile.h" //#include "TCutG.h" using std::cerr; @@ -22,19 +23,17 @@ private: TString fPartName; Int_t fNoFiles; - vector fFileName; + vector fFilePars; + //todo following parameters should be probably moved to AculCalParsScintFile + //as far as they are related to each file separately vector fCutName; vector fCuts; Int_t fEnergyPoints; - vector fE; TString fCutsFileName; Int_t fNoCuts; //number of cuts - vector< vector > fPeakMin; - vector< vector > fPeakMax; - public: AculCalParsScint(); AculCalParsScint(const char* parFile); diff --git a/AculCalib/AculCalib.mk b/AculCalib/AculCalib.mk index 12e2d4d447ccc99cf3a5ca2c9c347f5324e0e93b..46a76cbe83f634a43e9e05e6f7502f8440e53dcc 100755 --- a/AculCalib/AculCalib.mk +++ b/AculCalib/AculCalib.mk @@ -10,6 +10,7 @@ $(ACULCALIB)/AculCalib.h \ $(ACULCALIB)/AculCalibScint.h \ $(ACULCALIB)/AculCalPars.h \ $(ACULCALIB)/AculCalParsScint.h \ +$(ACULCALIB)/AculCalParsScintFile.h \ $(ACULCALIB)/linkdef.h ACULCALIBCPP_SRCS += \ @@ -17,6 +18,7 @@ $(ACULCALIB)/AculCalib.cpp \ $(ACULCALIB)/AculCalibScint.cpp \ $(ACULCALIB)/AculCalPars.cpp \ $(ACULCALIB)/AculCalParsScint.cpp \ +$(ACULCALIB)/AculCalParsScintFile.cpp \ $(ACULCALIB)/AculCalibCint.cpp ACULCALIBOBJS += \ @@ -24,6 +26,7 @@ $(ACULCALIB)/AculCalib.o \ $(ACULCALIB)/AculCalibScint.o \ $(ACULCALIB)/AculCalPars.o \ $(ACULCALIB)/AculCalParsScint.o \ +$(ACULCALIB)/AculCalParsScintFile.o \ $(ACULCALIB)/AculCalibCint.o ACULCALIBCPP_DEPS += \ @@ -31,4 +34,5 @@ $(ACULCALIB)/AculCalib.d \ $(ACULCALIB)/AculCalibScint.d \ $(ACULCALIB)/AculCalPars.d \ $(ACULCALIB)/AculCalParsScint.d \ +$(ACULCALIB)/AculCalParsScintFile.d \ $(ACULCALIB)/AculCalibCint.d \ No newline at end of file diff --git a/AculCalib/linkdef.h b/AculCalib/linkdef.h index 6f00713146c7de6e5657c78e225bc4355a1a300f..9743125beff81bfc93ca8a0fa935bbb0b5c0672a 100755 --- a/AculCalib/linkdef.h +++ b/AculCalib/linkdef.h @@ -9,7 +9,7 @@ #pragma link C++ class AculCalibScint; #pragma link C++ class AculCalPars; #pragma link C++ class AculCalParsScint; - +#pragma link C++ class AculCalParsScintFile; #endif diff --git a/macros/myMacros/parTest.cxx b/macros/myMacros/parTest.cxx index 91544144284cc58dcdacca5a278f5e7ce093b620..5e0d20a6f63a612623f3c968cba64144693b272e 100644 --- a/macros/myMacros/parTest.cxx +++ b/macros/myMacros/parTest.cxx @@ -1,13 +1,35 @@ //#include "../../AculCalib/AculCalPars.h" //#include "../../AculCalib/AculCalibScint.h" //#include "TSystem.h" +//#include +// +using std::cout; +using std::endl; void parTest() { gSystem->Load("../../libAculCalib.so"); + AculCalParsScintFile pp; + pp.SetNoCrystals(16); + pp.Init(); +// return; + + cout << "-----------------------" << endl; + AculCalParsScint p; p.SetParFile("SQ13Alpha.par"); + p.Init(); +// cout << p.GetFileName(0) << endl; +// cout << p.GetFileName(1) << endl; +// cout << p.GetFileName(2) << endl; +// cout << p.GetFileName(3) << endl; +// cout << p.GetFileName(4) << endl; + p.PrintParameters("all"); +// return; + p.Reset(); + p.PrintParameters(""); +// return; AculCalibScint c; c.SetParFile("SQ13Alpha.par");