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