Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:28:17

0001 #include <iostream>
0002 #include <fstream>
0003 #include <vector>
0004 #include <map>
0005 #include <utility>
0006 #include <string>
0007 #ifdef __APPLE__
0008 #include <unistd.h>
0009 #endif
0010 #include "TString.h"
0011 #include "TFile.h"
0012 #include "TTree.h"
0013 #include "TCanvas.h"
0014 #include "TF1.h"
0015 #include "TH1D.h"
0016 #include "TObjArray.h"
0017 #include "TObjString.h"
0018 
0019 #include "Setup.h"
0020 #include "Calib.h"
0021 #include "Event.h"
0022 #include "Tile.h"
0023 #include "HGCROC.h"
0024 #include "Caen.h"
0025 #include "ComparisonCalib.h"
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<<"-d [0-3] Debugging mode"<<std::endl;
0032   std::cout<<"-e [0-1] extended plotting"<<std::endl;
0033   std::cout<<"-E [1-X] histo reading options for expanded file list"<<std::endl;
0034   std::cout<<"-f       Force to write output if already exist"<<std::endl;
0035   std::cout<<"-F fff   set explicit plot extension explicitly, default is pdf "<<std::endl;
0036   std::cout<<"-H       switch to HGCROC output" << std::endl;
0037   std::cout<<"-i uuu   Input file list"<<std::endl;
0038   std::cout<<"-I uuu   expanded input file list"<<std::endl;
0039   std::cout<<"-L [1-63]restrict max layer plotting"<<std::endl;
0040   std::cout<<"-o vvv   Output file name (mandatory)"<<std::endl;
0041   std::cout<<"-O kkk   Output directory name for plots (mandatory)"<<std::endl;
0042   std::cout<<"-r rrr   Name of run list file  2024 PS TB [../configs/DataTakingDB_202409_CAEN.csv] "<<std::endl;
0043   std::cout<<"-R       Trending plots versus run #"<<std::endl;
0044   std::cout<<"-V       Trending plots versus Vop"<<std::endl;
0045   //std::cout<<"-t       Trending plots versus BoR time"<<std::endl;
0046   std::cout<<"-h       this help"<<std::endl<<std::endl;
0047   std::cout<<"Examples:"<<std::endl;
0048   std::cout<<exe<<" (-f) -o TrendingOutput.root -i input_list.txt (-f to overwrite existing output)"<<std::endl;
0049   std::cout<<exe<<" (-f) -o TrendingOutput.root InputName*.root InputName2.root (-f to overwrite existing output)"<<std::endl;
0050 }
0051   
0052 
0053 int main(int argc, char* argv[]){
0054   if(argc<4) {
0055     PrintHelp(argv[0]);
0056     return 0;
0057   }
0058   std::vector<std::string> RootRegexp;
0059   std::vector<std::string>::iterator it;
0060   for(int i=1; i<argc; i++){
0061     RootRegexp.push_back(argv[i]);
0062   }
0063   ComparisonCalib CompAnalysis;
0064   int c;
0065   while((c=getopt(argc,argv,"d:e:E:fF:Hi:I:L:o:O:r:RVth"))!=-1){
0066     switch(c){
0067     case 'd':
0068       std::cout<<"Compare: enable debug " << optarg <<std::endl;
0069       CompAnalysis.EnableDebug(atoi(optarg));
0070       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-d");
0071       RootRegexp.erase(it);
0072       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0073       RootRegexp.erase(it);
0074       break;
0075     case 'e':
0076       std::cout<<"Compare: enabling extended plotting"<<std::endl;
0077       CompAnalysis.SetExtPlotting(atoi(optarg));
0078       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-e");
0079       RootRegexp.erase(it);
0080       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0081       RootRegexp.erase(it);
0082       break;
0083     case 'E':
0084       std::cout<<"Compare: set histo reading option"<<std::endl;
0085       CompAnalysis.ExpandedList(atoi(optarg));
0086       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-E");
0087       RootRegexp.erase(it);
0088       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0089       RootRegexp.erase(it);
0090       break;
0091     case 'f':
0092       std::cout<<"Compare: If output already exists it will be overwritten"<<std::endl;
0093       CompAnalysis.CanOverWrite(true);
0094       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-f");
0095       RootRegexp.erase(it);
0096       break;
0097     case 'F':
0098       std::cout<<"Compare: Set Plot extension to: "<< optarg<<std::endl;
0099       CompAnalysis.SetPlotExtension(optarg);
0100       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-F");
0101       RootRegexp.erase(it);
0102       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0103       RootRegexp.erase(it);
0104       break;
0105     case 'i':
0106       std::cout<<"Compare: Root input file is: "<<optarg<<std::endl;
0107       CompAnalysis.SetInputList(Form("%s",optarg));
0108       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-i");
0109       RootRegexp.erase(it);
0110       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0111       RootRegexp.erase(it);
0112       break;
0113     case 'I':
0114       std::cout<<"Compare: Expanded Root input file is: "<<optarg<<std::endl;
0115       CompAnalysis.SetInputList(Form("%s",optarg));
0116       if (CompAnalysis.GetExpandedList() == 0){
0117         CompAnalysis.ExpandedList(1);
0118       }
0119       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-I");
0120       RootRegexp.erase(it);
0121       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0122       RootRegexp.erase(it);
0123       break;
0124     case 'H':
0125       std::cout<<"Compare: HGCROC output "<<std::endl;
0126       CompAnalysis.SetIsHGCROC(true);
0127       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-H");
0128       RootRegexp.erase(it);
0129       break;
0130     case 'L':
0131       std::cout<<"Compare: restrict max layer plotting: "<<optarg<<std::endl;
0132       CompAnalysis.SetMaxPlotLayer(atoi(optarg));
0133       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-L");
0134       RootRegexp.erase(it);
0135       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0136       RootRegexp.erase(it);
0137       break;
0138     case 'o':
0139       std::cout<<"Compare: Output to be saved in: "<<optarg<<std::endl;
0140       CompAnalysis.SetRootOutput(Form("%s",optarg));
0141       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-o");
0142       RootRegexp.erase(it);
0143       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0144       RootRegexp.erase(it);
0145       break;
0146     case 'O':
0147       std::cout<<"Compare: Outputdir plots to be saved in: "<<optarg<<std::endl;
0148       CompAnalysis.SetPlotOutputDir(Form("%s",optarg));
0149       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-O");
0150       RootRegexp.erase(it);
0151       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0152       RootRegexp.erase(it);
0153       break;
0154     case 'r':
0155       std::cout<<"Compare: run list file from: "<<optarg<<std::endl;
0156       CompAnalysis.SetRunListInput(Form("%s",optarg));
0157       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-r");
0158       RootRegexp.erase(it);
0159       it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0160       RootRegexp.erase(it);
0161       break;
0162     case 'R':
0163       std::cout<<"Compare: Trending plots versus run #"<<std::endl;
0164       CompAnalysis.SetTrendingAxis(0);
0165       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-R");
0166       RootRegexp.erase(it);
0167       break;
0168     case 'V':
0169       std::cout<<"Compare: Trending plots versus Vop"<<std::endl;
0170       CompAnalysis.SetTrendingAxis(1);
0171       it=std::find(RootRegexp.begin(),RootRegexp.end(),"-V");
0172       RootRegexp.erase(it);
0173       break;
0174     //case 't':
0175     //  std::cout<<"Trending plots versus BoR time"<<std::endl;
0176     //  CompAnalysis.SetTrendingAxis(2);
0177     //  it=std::find(RootRegexp.begin(),RootRegexp.end(),"-t");
0178     //  RootRegexp.erase(it);
0179     //  break;
0180     case '?':
0181       std::cout<<"Option "<<optarg <<" not supported, will be ignored "<<std::endl;
0182       break;
0183     case 'h':
0184       PrintHelp(argv[0]);
0185       return 0;
0186     }
0187   }
0188   std::cout<<"begin extra list"<<std::endl;
0189   for(it=RootRegexp.begin(); it!=RootRegexp.end(); ++it){
0190     std::cout<<*it<<std::endl;
0191     CompAnalysis.AddInputFile(*it);
0192   }
0193   std::cout<<"end extra list"<<std::endl;
0194   if(!CompAnalysis.CheckAndOpenIO()){
0195     std::cout<<"Check input and configurations, inconsistency or error with I/O detected"<<std::endl;
0196     PrintHelp(argv[0]);
0197     return -1;
0198   }
0199 
0200   CompAnalysis.ProcessCalib();
0201   //CompAnalysis.Close();
0202   std::cout<<"Exiting"<<std::endl;
0203   
0204   return 0;
0205 }