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