Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #include <iostream>
0002 #include <fstream>
0003 #include <vector>
0004 #include <map>
0005 #include <utility>
0006 //#include <unistd.h> // Add for use on Mac OS -> Same goes for Analyses.cc
0007 #include "TString.h"
0008 #include "TFile.h"
0009 #include "TTree.h"
0010 #include "TCanvas.h"
0011 #include "TF1.h"
0012 #include "TH1D.h"
0013 #include "TObjArray.h"
0014 #include "TObjString.h"
0015 
0016 #include "Setup.h"
0017 #include "Calib.h"
0018 #include "Event.h"
0019 #include "Tile.h"
0020 #include "HGCROC.h"
0021 #include "Caen.h"
0022 #include "ComparisonCalib.h"
0023 
0024 Setup* Setup::instancePtr=nullptr; // Remove for use on Mac OS -> Add to Setup.cc instead
0025 //Calib* Calib::instancePtr=nullptr;
0026 
0027 void PrintHelp(char* exe){
0028   std::cout<<"Usage:"<<std::endl;
0029   std::cout<<exe<<" [-option (arguments)]"<<std::endl;
0030   std::cout<<"Options:"<<std::endl;
0031   std::cout<<"-i uuu   Input file in root format"<<std::endl;
0032   std::cout<<"-o vvv   Output file name (mandatory)"<<std::endl;
0033   std::cout<<"-O kkk   Output directory name for plots (mandatory)"<<std::endl;
0034   std::cout<<"-f       Force to write output if already exist"<<std::endl;
0035   std::cout<<"-r rrr   Name of run list file  2024 PS TB [../configs/DataTakingDB_202409_CAEN.csv] "<<std::endl;
0036   std::cout<<"-d [0-3] switch on debug info with debug level 0 to 3"<<std::endl;
0037   std::cout<<"-h       this help"<<std::endl<<std::endl;
0038   std::cout<<"Examples:"<<std::endl;
0039   std::cout<<exe<<" -c input.txt -o output.root (Convert ASCII to root)"<<std::endl;
0040   std::cout<<exe<<" -p (-f) -o OutputWithExtractedPedestal.root -i input.root (-f to overwrite existing output)"<<std::endl;
0041   std::cout<<exe<<" -s (-f) -o OutputWithMIPscaling.root -i input.root (-f to overwrite existing output)"<<std::endl;
0042   std::cout<<exe<<" -s (-f) -o OutputWithMIPscaling.root -P PedestalInput.root -i RawInput.root (-f to overwrite existing output)"<<std::endl;
0043   std::cout<<exe<<" -C Calibration.root (-f) -o CalibratedOutput.root -i Input.root (-f to overwrite existing output)"<<std::endl;
0044 }
0045   
0046 
0047 int main(int argc, char* argv[]){
0048   if(argc<4) {
0049     PrintHelp(argv[0]);
0050     return 0;
0051   }
0052   ComparisonCalib CompAnalysis;
0053   int c;
0054   while((c=getopt(argc,argv,"fo:O:d:i:r:h"))!=-1){
0055     switch(c){
0056     case 'f':
0057       std::cout<<"If output already exists it will be overwritten"<<std::endl;
0058       CompAnalysis.CanOverWrite(true);
0059       break;
0060     case 'o':
0061       std::cout<<"Output to be saved in: "<<optarg<<std::endl;
0062       CompAnalysis.SetRootOutput(Form("%s",optarg));
0063       break;
0064     case 'O':
0065       std::cout<<"Outputdir plots to be saved in: "<<optarg<<std::endl;
0066       CompAnalysis.SetPlotOutputDir(Form("%s",optarg));
0067       break;
0068     case 'r':
0069       std::cout<<"run list file from: "<<optarg<<std::endl;
0070       CompAnalysis.SetRunListInput(Form("%s",optarg));
0071       break;
0072     case 'i':
0073       std::cout<<"Root input file is: "<<optarg<<std::endl;
0074       CompAnalysis.SetRootInput(Form("%s",optarg));
0075       break;
0076     case 'd':
0077       std::cout<<"enable debug " << optarg <<std::endl;
0078       CompAnalysis.EnableDebug(atoi(optarg));
0079       break;
0080     case '?':
0081       std::cout<<"Option "<<optarg <<" not supported, will be ignored "<<std::endl;
0082       break;
0083     case 'h':
0084       PrintHelp(argv[0]);
0085       return 0;
0086     }
0087   }
0088   if(!CompAnalysis.CheckAndOpenIO()){
0089     std::cout<<"Check input and configurations, inconsistency or error with I/O detected"<<std::endl;
0090     PrintHelp(argv[0]);
0091     return -1;
0092   }
0093 
0094   CompAnalysis.Process();
0095   std::cout<<"Exiting"<<std::endl;
0096   return 0;
0097 }