Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:44

0001 #include "ComparisonCalib.h"
0002 #include <vector>
0003 #include "TROOT.h"
0004 //#include <unistd.h> // Add for use on Mac OS -> Same goes for Analyse.cc
0005 #include "TF1.h"
0006 #include "TFitResult.h"
0007 #include "TFitResultPtr.h"
0008 #include "TH1D.h"
0009 #include "TH2D.h"
0010 #include "TProfile.h"
0011 #include "TChain.h"
0012 #include "TileSpectra.h"
0013 #include "CommonHelperFunctions.h"
0014 #include "PlottHelper.h"
0015 
0016 bool ComparisonCalib::CheckAndOpenIO(void){
0017   int matchingbranch;
0018   //Need to check first input to get the setup...I do not think it is necessary
0019   if(!InputListName.IsNull()){
0020     //File exist?
0021     
0022     
0023     
0024     RootInput=new TFile(RootInputName.Data(),"READ");
0025     if(RootInput->IsZombie()){
0026       std::cout<<"Error opening '"<<RootInputName<<"', does the file exist?"<<std::endl;
0027       return false;
0028     }
0029 
0030     //Retrieve info, start with setup
0031     TsetupIn = (TTree*) RootInput->Get("Setup");
0032     if(!TsetupIn){
0033       std::cout<<"Could not retrieve the Setup tree, leaving"<<std::endl;
0034       return false;
0035     }
0036     setup=Setup::GetInstance();
0037     std::cout<<"Setup add "<<setup<<std::endl;
0038     //matchingbranch=TsetupIn->SetBranchAddress("setup",&setup);
0039     matchingbranch=TsetupIn->SetBranchAddress("setup",&rswptr);
0040     if(matchingbranch<0){
0041       std::cout<<"Error retrieving Setup info from the tree"<<std::endl;
0042       return false;
0043     }
0044     std::cout<<"Entries "<<TsetupIn->GetEntries()<<std::endl;
0045     TsetupIn->GetEntry(0);
0046     setup->Initialize(*rswptr);
0047     std::cout<<"Reading "<<RootInput->GetName()<<std::endl;
0048     std::cout<<"Setup Info "<<setup->IsInit()<<"  and  "<<setup->GetCellID(0,0)<<std::endl;
0049     //std::cout<<"Setup add now "<<setup<<std::endl;
0050     
0051     //Do I really want this?
0052     TcalibIn = (TTree*) RootInput->Get("Calib");
0053     if(!TcalibIn){
0054       std::cout<<"Could not retrieve Calib tree, leaving"<<std::endl;
0055       //return false;
0056     }
0057     else {
0058       matchingbranch=TcalibIn->SetBranchAddress("calib",&calibptr);
0059       if(matchingbranch<0){
0060         std::cout<<"Error retrieving calibration info from the tree"<<std::endl;
0061         TcalibIn=nullptr;
0062       }
0063     }
0064     //End of do I really want this?
0065   }
0066   
0067   //Setup Output files
0068   if(!RootOutputName.IsNull()){    
0069     TString temp = RootOutputName;
0070     temp         = temp.ReplaceAll(".root","_Hists.root");
0071     SetRootOutputHists(temp);
0072     std::cout << "creating additional histo file: " << RootOutputNameHist.Data() << " tree in : "<< RootOutputName.Data() << std::endl;
0073     
0074     bool sCOF = CreateOutputRootFile();
0075     if (!sCOF) return false;    
0076   } else {
0077     return false;
0078   }
0079   
0080   if(!RootCalibInputName.IsNull()){
0081     RootCalibInput=new TFile(RootCalibInputName.Data(),"READ");
0082     if(RootCalibInput->IsZombie()){
0083       std::cout<<"Error opening '"<<RootCalibInputName<<"', does the file exist?"<<std::endl;
0084       return false;
0085     }
0086     TcalibIn = (TTree*) RootCalibInput->Get("Calib");
0087     if(!TcalibIn){
0088       std::cout<<"Could not retrieve Calib tree, leaving"<<std::endl;
0089       return false;
0090     }
0091     matchingbranch=TcalibIn->SetBranchAddress("calib",&calibptr);
0092     if(matchingbranch<0){
0093       std::cout<<"Error retrieving calibration info from the tree"<<std::endl;
0094       return false;
0095     }
0096     
0097   }
0098 
0099   if(!RootPedestalInputName.IsNull()){
0100     RootPedestalInput = new TFile(RootPedestalInputName.Data(),"READ");
0101     if(RootPedestalInput->IsZombie()){
0102       std::cout<<"Error opening '"<<RootPedestalInputName<<"', does the file exist?"<<std::endl;
0103       return false;
0104     }
0105     TcalibIn = (TTree*) RootPedestalInput->Get("Calib");
0106     if(!TcalibIn){
0107       std::cout<<"Could not retrieve Calib tree, leaving"<<std::endl;
0108       return false;
0109     }
0110     matchingbranch=TcalibIn->SetBranchAddress("calib",&calibptr);
0111     if(matchingbranch<0){
0112       std::cout<<"Error retrieving calibration info from the tree"<<std::endl;
0113       return false;
0114     }
0115     //std::cout<<"Did the address changed? "<<&calib<<std::endl;
0116   }
0117   return true;    
0118 }
0119 
0120 
0121 bool ComparisonCalib::Process(void){
0122   bool status;
0123   ROOT::EnableImplicitMT();
0124   
0125   return status;
0126 }
0127 
0128 
0129 bool ComparisonCalib::CreateOutputRootFile(void){
0130   if(Overwrite){
0131     RootOutput=new TFile(RootOutputName.Data(),"RECREATE");
0132   } else{
0133     RootOutput = new TFile(RootOutputName.Data(),"CREATE");
0134   }
0135   if(RootOutput->IsZombie()){
0136     std::cout<<"Error opening '"<<RootOutput<<"'no reachable path? Exist without force mode to overwrite?..."<<std::endl;
0137     return false;
0138   }
0139   return true;
0140 }
0141 
0142