#include "AculCalibScint.h" #include "AculCalParsScint.h" ClassImp(AculCalibScint); AculCalibScint::AculCalibScint() { printf("AculCalibScint::Default constructor called.\n"); fInFiles = 0; fTrees = 0; fCutFile = 0; } AculCalibScint::AculCalibScint(const char* parfile) { printf("AculCalibScint::Constructor called.\n"); SetParFile(parfile); Init(); // cout << "nofiles: " << nofiles << endl; // OpenTrees(); // LoadCuts(); // fr.Print(); // fr.At(0); } AculCalibScint::~AculCalibScint() { printf("AculCalibScint::Destructor called.\n"); } void AculCalibScint::Init() { fPars = new AculCalParsScint(fParFileName.Data()); OpenFiles(); LoadTrees(); // SetPars(); } void AculCalibScint::PrintTrees() { if (!fTrees) { cerr << "\"AculCalibScint::PrintTrees\" Probably no tree was open." << endl; return; } // TTree *curTree = 0; cout << " AculCalibScint::PrintTrees:" << endl; for (Int_t i = 0; i < fPars->GetNoRawFiles(); i++) { // curTree = fTrees[i]; if (fTrees[i]) { printf("\tTree No. %d; File: %s; Name: %s\n", i, fTrees[i]->GetDirectory()->GetName(), fTrees[i]->GetName()); } else { printf("\tTree No. %d was not loaded. Maximal number of trees is %d\n", i, NOCALFILES); } } return; } void AculCalibScint::OpenFiles() { if (!fPars) { cerr << "\"AculCalibScint::OpenFiles\" parameters were not initialized." << endl; return; } fPars->GetNoRawFiles(); fInFiles = new TFile* [fPars->GetNoRawFiles()]; for (Int_t i = 0; i < fPars->GetNoRawFiles(); i++) { fInFiles[i] = new TFile(fPars->GetFileName(i), "READ"); // cout << "\"AculCalibScint::OpenFiles\" File \"" << fInFiles[i]->GetName() << "\" was opened." << endl; } } void AculCalibScint::LoadTrees() { if (!fInFiles) { cerr << "\"AculCalibScint::LoadTrees\" Input files were not open." << endl; return; } fTrees = new TTree* [fPars->GetNoRawFiles()]; for (Int_t i = 0; i < fPars->GetNoRawFiles(); i++) { fTrees[i] = (TTree*)fInFiles[i]->Get("AnalysisxTree"); // cout << "\"AculCalibScint::LoadTrees\" Tree \"" << fTrees[i]->GetName() // << "\" from file \"" << fInFiles[i]->GetName() << "\" was loaded." << endl; } } void AculCalibScint::DrawVariable(const char* variable, Int_t tree, TCanvas *canvas, Int_t lowRange, Int_t upRange) { // if (!canvas) TCanvas *c = new TCanvas(); if (!canvas) return; canvas->Clear(); canvas->Divide(4,4); TString canvasTitle; TString var; TString con; TTree *curTree = 0; curTree = fTrees[tree]; if (!curTree) { printf("AculCalibScint::DrawVariable: Tree No. %d was not found.\n", tree); return; } canvasTitle.Form("variable: %s; tree: %d", variable, tree); canvas->SetTitle(canvasTitle.Data()); for (Int_t i = 0; i < 16; i++) { var.Form("%s[%d]", variable, i); con.Form("%s[%d]>%d && %s[%d]<%d", variable, i, lowRange, variable, i, upRange); canvas->cd(i+1); curTree->Draw(var.Data(), con.Data()); canvas->Update(); } }