File indexing completed on 2025-07-02 07:54:44
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<<"-i uuu Input file list"<<std::endl;
0037 std::cout<<"-I uuu expanded input file list"<<std::endl;
0038 std::cout<<"-L [1-63]restrict max layer plotting"<<std::endl;
0039 std::cout<<"-o vvv Output file name (mandatory)"<<std::endl;
0040 std::cout<<"-O kkk Output directory name for plots (mandatory)"<<std::endl;
0041 std::cout<<"-r rrr Name of run list file 2024 PS TB [../configs/DataTakingDB_202409_CAEN.csv] "<<std::endl;
0042 std::cout<<"-R Trending plots versus run #"<<std::endl;
0043 std::cout<<"-V Trending plots versus Vop"<<std::endl;
0044
0045 std::cout<<"-h this help"<<std::endl<<std::endl;
0046 std::cout<<"Examples:"<<std::endl;
0047 std::cout<<exe<<" (-f) -o TrendingOutput.root -i input_list.txt (-f to overwrite existing output)"<<std::endl;
0048 std::cout<<exe<<" (-f) -o TrendingOutput.root InputName*.root InputName2.root (-f to overwrite existing output)"<<std::endl;
0049 }
0050
0051
0052 int main(int argc, char* argv[]){
0053 if(argc<4) {
0054 PrintHelp(argv[0]);
0055 return 0;
0056 }
0057 std::vector<std::string> RootRegexp;
0058 std::vector<std::string>::iterator it;
0059 for(int i=1; i<argc; i++){
0060 RootRegexp.push_back(argv[i]);
0061 }
0062 ComparisonCalib CompAnalysis;
0063 int c;
0064 while((c=getopt(argc,argv,"d:e:E:fF:i:I:L:o:O:r:RVth"))!=-1){
0065 switch(c){
0066 case 'd':
0067 std::cout<<"Compare: enable debug " << optarg <<std::endl;
0068 CompAnalysis.EnableDebug(atoi(optarg));
0069 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-d");
0070 RootRegexp.erase(it);
0071 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0072 RootRegexp.erase(it);
0073 break;
0074 case 'e':
0075 std::cout<<"Compare: enabling extended plotting"<<std::endl;
0076 CompAnalysis.SetExtPlotting(atoi(optarg));
0077 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-e");
0078 RootRegexp.erase(it);
0079 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0080 RootRegexp.erase(it);
0081 break;
0082 case 'E':
0083 std::cout<<"Compare: set histo reading option"<<std::endl;
0084 CompAnalysis.ExpandedList(atoi(optarg));
0085 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-E");
0086 RootRegexp.erase(it);
0087 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0088 RootRegexp.erase(it);
0089 break;
0090 case 'f':
0091 std::cout<<"Compare: If output already exists it will be overwritten"<<std::endl;
0092 CompAnalysis.CanOverWrite(true);
0093 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-f");
0094 RootRegexp.erase(it);
0095 break;
0096 case 'F':
0097 std::cout<<"Compare: Set Plot extension to: "<< optarg<<std::endl;
0098 CompAnalysis.SetPlotExtension(optarg);
0099 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-F");
0100 RootRegexp.erase(it);
0101 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0102 RootRegexp.erase(it);
0103 break;
0104 case 'i':
0105 std::cout<<"Compare: Root input file is: "<<optarg<<std::endl;
0106 CompAnalysis.SetInputList(Form("%s",optarg));
0107 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-i");
0108 RootRegexp.erase(it);
0109 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0110 RootRegexp.erase(it);
0111 break;
0112 case 'I':
0113 std::cout<<"Compare: Expanded Root input file is: "<<optarg<<std::endl;
0114 CompAnalysis.SetInputList(Form("%s",optarg));
0115 if (CompAnalysis.GetExpandedList() == 0){
0116 CompAnalysis.ExpandedList(1);
0117 }
0118 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-I");
0119 RootRegexp.erase(it);
0120 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0121 RootRegexp.erase(it);
0122 break;
0123 case 'L':
0124 std::cout<<"Compare: restrict max layer plotting: "<<optarg<<std::endl;
0125 CompAnalysis.SetMaxPlotLayer(atoi(optarg));
0126 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-L");
0127 RootRegexp.erase(it);
0128 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0129 RootRegexp.erase(it);
0130 break;
0131 case 'o':
0132 std::cout<<"Compare: Output to be saved in: "<<optarg<<std::endl;
0133 CompAnalysis.SetRootOutput(Form("%s",optarg));
0134 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-o");
0135 RootRegexp.erase(it);
0136 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0137 RootRegexp.erase(it);
0138 break;
0139 case 'O':
0140 std::cout<<"Compare: Outputdir plots to be saved in: "<<optarg<<std::endl;
0141 CompAnalysis.SetPlotOutputDir(Form("%s",optarg));
0142 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-O");
0143 RootRegexp.erase(it);
0144 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0145 RootRegexp.erase(it);
0146 break;
0147 case 'r':
0148 std::cout<<"Compare: run list file from: "<<optarg<<std::endl;
0149 CompAnalysis.SetRunListInput(Form("%s",optarg));
0150 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-r");
0151 RootRegexp.erase(it);
0152 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0153 RootRegexp.erase(it);
0154 break;
0155 case 'R':
0156 std::cout<<"Compare: Trending plots versus run #"<<std::endl;
0157 CompAnalysis.SetTrendingAxis(0);
0158 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-R");
0159 RootRegexp.erase(it);
0160 break;
0161 case 'V':
0162 std::cout<<"Compare: Trending plots versus Vop"<<std::endl;
0163 CompAnalysis.SetTrendingAxis(1);
0164 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-V");
0165 RootRegexp.erase(it);
0166 break;
0167
0168
0169
0170
0171
0172
0173 case '?':
0174 std::cout<<"Option "<<optarg <<" not supported, will be ignored "<<std::endl;
0175 break;
0176 case 'h':
0177 PrintHelp(argv[0]);
0178 return 0;
0179 }
0180 }
0181 std::cout<<"begin extra list"<<std::endl;
0182 for(it=RootRegexp.begin(); it!=RootRegexp.end(); ++it){
0183 std::cout<<*it<<std::endl;
0184 CompAnalysis.AddInputFile(*it);
0185 }
0186 std::cout<<"end extra list"<<std::endl;
0187 if(!CompAnalysis.CheckAndOpenIO()){
0188 std::cout<<"Check input and configurations, inconsistency or error with I/O detected"<<std::endl;
0189 PrintHelp(argv[0]);
0190 return -1;
0191 }
0192
0193 CompAnalysis.Process();
0194
0195 std::cout<<"Exiting"<<std::endl;
0196
0197 return 0;
0198 }