File indexing completed on 2025-02-22 09:39:20
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 "Analyses.h"
0023
0024 void PrintHelp(char* exe){
0025 std::cout<<"Usage:"<<std::endl;
0026 std::cout<<exe<<" [-option (arguments)]"<<std::endl;
0027 std::cout<<"Options:"<<std::endl;
0028 std::cout<<"-a printing calib object to file (using name of output root or calib root file ending in txt)"<<std::endl;
0029 std::cout<<"-c xxx Convert ASCII input file xxx into root format output"<<std::endl;
0030 std::cout<<"-w Run HGCROC data convserion. Omit to process CAEN data"<<std::endl;
0031 std::cout<<"-d [0-n] switch on debug info with debug level 0 to n"<<std::endl;
0032 std::cout<<"-f Force to write output if already exist"<<std::endl;
0033 std::cout<<"-i uuu Input file in root format"<<std::endl;
0034 std::cout<<"-m www Name of mapping file 2024 PS TB [../configs/mappingFile_202409_CAEN.txt] "<<std::endl;
0035 std::cout<<"-o vvv Output file name (mandatory)"<<std::endl;
0036 std::cout<<"-O kkk Output directory name for plots (mandatory)"<<std::endl;
0037 std::cout<<"-r rrr Name of run list file 2024 PS TB [../configs/DataTakingDB_202409_CAEN.csv] "<<std::endl;
0038 std::cout<<"-y yyyy setting year externally to narrow parameters"<<std::endl;
0039 std::cout<<"-h this help"<<std::endl<<std::endl;
0040 std::cout<<"Examples:"<<std::endl;
0041 std::cout<<exe<<" -c (-f) input.txt -o output.root (Convert ASCII to root) (-f to overwrite existing output)"<<std::endl;
0042 }
0043
0044
0045 int main(int argc, char* argv[]){
0046 if(argc<4) {
0047 PrintHelp(argv[0]);
0048 return 0;
0049 }
0050 Analyses AnAnalysis;
0051 int c;
0052 while((c=getopt(argc,argv,"ac:wd:fi:m:o:O:r:y:h"))!=-1){
0053 switch(c){
0054 case 'a':
0055 std::cout<<"Convert: printing calib object to file"<<std::endl;
0056 AnAnalysis.IsCalibSaveToFile(true);
0057 break;
0058 case 'c':
0059 std::cout<<"Convert: Convert ASCII input '"<<optarg<<"' to root format"<<std::endl;
0060 AnAnalysis.SetASCIIinput(Form("%s",optarg));
0061 AnAnalysis.IsToConvert(true);
0062 break;
0063 case 'w':
0064 std::cout<<"Convert HGCROC data"<<std::endl;
0065 AnAnalysis.IsHGCROC(true);
0066 break;
0067 case 'd':
0068 std::cout<<"Convert: enable debug " << optarg <<std::endl;
0069 AnAnalysis.EnableDebug(atoi(optarg));
0070 break;
0071 case 'f':
0072 std::cout<<"Convert: If output already exists it will be overwritten"<<std::endl;
0073 AnAnalysis.CanOverWrite(true);
0074 break;
0075 case 'i':
0076 std::cout<<"Convert: Root input file is: "<<optarg<<std::endl;
0077 AnAnalysis.SetRootInput(Form("%s",optarg));
0078 break;
0079 case 'm':
0080 std::cout<<"Convert: Mapping file from: "<<optarg<<std::endl;
0081 AnAnalysis.SetMapInput(Form("%s",optarg));
0082 break;
0083 case 'o':
0084 std::cout<<"Convert: Output to be saved in: "<<optarg<<std::endl;
0085 AnAnalysis.SetRootOutput(Form("%s",optarg));
0086 break;
0087 case 'O':
0088 std::cout<<"Convert: Outputdir plots to be saved in: "<<optarg<<std::endl;
0089 AnAnalysis.SetPlotOutputDir(Form("%s",optarg));
0090 break;
0091 case 'r':
0092 std::cout<<"Convert: run list file from: "<<optarg<<std::endl;
0093 AnAnalysis.SetRunListInput(Form("%s",optarg));
0094 break;
0095 case 'y':
0096 std::cout<<"Convert: Setting year externally: "<<optarg<<std::endl;
0097 AnAnalysis.SetYear(atoi(optarg));
0098 break;
0099 case '?':
0100 std::cout<<"Convert: Option "<<optarg <<" not supported, will be ignored "<<std::endl;
0101 break;
0102 case 'h':
0103 PrintHelp(argv[0]);
0104 return 0;
0105 }
0106 }
0107 if(!AnAnalysis.CheckAndOpenIO()){
0108 std::cout<<"Check input and configurations, inconsistency or error with I/O detected"<<std::endl;
0109 PrintHelp(argv[0]);
0110 return -1;
0111 }
0112
0113 AnAnalysis.Process();
0114 std::cout<<"Exiting"<<std::endl;
0115 return 0;
0116 }