/* * AculCalParsScintFile.cpp * * Created on: Oct 25, 2016 * Author: vratik */ #include "AculCalParsScintFile.h" AculCalParsScintFile::AculCalParsScintFile() { // TODO Auto-generated constructor stub // fFileID = 0; fNoCrystals = 0; fE = 0; Init(); } AculCalParsScintFile::~AculCalParsScintFile() { // TODO Auto-generated destructor stub } void AculCalParsScintFile::Init() { // fNoCrystals = 0; // fE = 0; fPeakMin.resize(fNoCrystals); fPeakMax.resize(fNoCrystals); fCutName.resize(0); } const char* AculCalParsScintFile::GetCutName(Int_t i) { if ( i >= (Int_t)fCutName.size() ) { cout << "\"AculCalParsScintFile::GetCutName\" Cut number " << i << " is not available. Maximal i can be set as " << fCutName.size() - 1 << "." << endl; } return fCutName[i].Data(); } TCutG* AculCalParsScintFile::GetCut(Int_t i) { if ( i >= (Int_t)fCut.size() ) { cerr << "\"AculCalParsScintFile::GetCut\" index i cannot be higher than " << fCut.size() - 1 << endl; return 0; } return &fCut[i]; } TCutG* AculCalParsScintFile::GetCut(const char* cutName) { const TString cName = cutName; for (Int_t i = 0; i <= (Int_t)fCut.size(); i++) { if (cName.EqualTo(fCutName[i])) { return &fCut[i]; } } cerr << "\"AculCalParsScint::GetCut\" cut \"" << cutName << "\" was not found." << endl; return 0; } Int_t AculCalParsScintFile::GetPeakMin(Int_t crystalID) { if ( crystalID >= (Int_t)fPeakMin.size() ) { cerr << "\"AculCalParsScintFile::GetPeakMin\" index \"crystal\" cannot be higher than " << fPeakMin.size() - 1 << endl; return 0; } return fPeakMin[crystalID]; } Int_t AculCalParsScintFile::GetPeakMax(Int_t crystalID) { if ( crystalID >= (Int_t)fPeakMax.size() ) { cerr << "\"AculCalParsScintFile::GetPeakMax\" index \"crystal\" cannot be higher than " << fPeakMax.size() - 1 << endl; return 0; } return fPeakMax[crystalID]; } void AculCalParsScintFile::SetRawFileName(const char* filename) { fFileName = filename; // fFileID++; } void AculCalParsScintFile::SetCutFileName(const char* filename) { fCutsFileName = filename; } void AculCalParsScintFile::SetNoCuts(Int_t noCuts) { fCutName.resize(noCuts); } void AculCalParsScintFile::SetCutName(Int_t i, const char* cutname) { if ( i >= (Int_t)fCutName.size() ) { cout << "\"AculCalParsScintFile::SetCutName\" vector for cut names is not enough large. Maximal i can be set as " << fCutName.size() - 1 << "." << endl; } fCutName[i] = cutname; } void AculCalParsScintFile::SetPeakMin(Int_t crystalID, Double_t limit) { if ( crystalID>=(Int_t)fPeakMin.size() ) { cerr << "\"AculCalParsScintFile::SetPeakMin\" maximal allowed crystal ID is " << fPeakMin.size() << "."<< endl; return; } fPeakMin[crystalID] = limit; } void AculCalParsScintFile::SetPeakMax(Int_t crystalID, Double_t limit) { if ( crystalID>=(Int_t)fPeakMax.size() ) { cerr << "\"AculCalParsScintFile::SetPeakMax\" maximal allowed crystal ID is " << fPeakMax.size() << "."<< endl; return; } fPeakMax[crystalID] = limit; } void AculCalParsScintFile::LoadCuts() { if (fCutsFileName.Length() == 0) { printf("AculCalParsScintFile::LoadCuts: Name of file (*.root) with cuts was not provided.\n"); printf("AculCalParsScintFile::LoadCuts: No cuts has been loaded.\n"); return; } TFile cutFile(fCutsFileName.Data(), "READ"); if(!cutFile.IsOpen()) { cerr << "\"AculCalParsScintFile::LoadCuts\" File " << fCutsFileName.Data() << " was not open and no cuts were loaded." << endl; return; } for (Int_t i = 0; i < (Int_t)fCutName.size(); i++) { TCutG *currentCut = (TCutG*)cutFile.Get(fCutName[i]); if (!currentCut) { cout << "\"AculCalParsScintFile::LoadCuts\" Cut \"" << fCutName[i] << "\" was not found in file " << fCutsFileName << "." << endl; continue; } fCut.push_back(*currentCut); } } /*void AculCalParsScintFile::Reset() { }*/