39 {
40
41 int whichPart = -1;
42 bool saveInfo = false;
43 std::string THR = "THR";
44 std::string THRintime = "THRintime";
45 std::string TOT = "TOT";
46 std::string dpath = "directory_path";
47 std::vector<std::string> sWhichPart = {"Blayer","L1","L2","disk"};
48
50 std::string
aux(argv[i]);
51
52 if(
aux.compare(
"Blayer") == 0) whichPart = 0;
53 else if(
aux.compare(
"L1") == 0) whichPart = 1;
54 else if(
aux.compare(
"L2") == 0) whichPart = 2;
55 else if(
aux.compare(
"disk") == 0) whichPart = 3;
56 else if(
aux.compare(
"saveInfo") == 0) saveInfo =
true;
57 else if(THRintime.compare(
aux.substr(0,
aux.find(
"="))) == 0) THRintime =
aux.substr(
aux.find(
"=")+1);
58 else if(THR.compare(
aux.substr(0,
aux.find(
"="))) == 0) THR =
aux.substr(
aux.find(
"=")+1);
59 else if(TOT.compare(
aux.substr(0,
aux.find(
"="))) == 0) TOT =
aux.substr(
aux.find(
"=")+1);
60 else if(dpath.compare(
aux.substr(0,
aux.find(
"="))) == 0) dpath =
aux.substr(
aux.find(
"=")+1);
61 else{
63 return 1;
64 }
65 }
66
67 printf("%-14s = %s\n","Directory path",dpath.c_str());
68 printf("%-14s = %d - %s\n","Pixel part",whichPart, (whichPart < 0 or whichPart > 3) ? "-1" : sWhichPart.at(whichPart).c_str());
69 printf("%-14s = %s.root\n","THR",THR.c_str());
70 printf("%-14s = %s.root\n","THRintime",THRintime.c_str());
71 printf("%-14s = %s.root\n","TOT",TOT.c_str());
72 printf("%-14s = %s\n\n\n","Save root file",saveInfo ? "True" : "False" );
73
74
75 bool correctArgc = (whichPart < 0 or whichPart > 3) or (THR.compare("THR") == 0) or (THRintime.compare("THRintime") == 0) or (TOT.compare("TOT") == 0) or (dpath.compare("directory_path") == 0);
76
78 printf("Cannot continue, one arguments is incorrect or not filled correctly...\n");
79 printf("Helper below:\n**********************\n\n");
81 return 1;
82 }
83
84 std::string thres_f = dpath+THR+".root";
85 std::string timin_f = dpath+THRintime+".root";
86 std::string totin_f = dpath+TOT+".root";
87
88
89
91
92
93 std::map<unsigned int , std::vector<std::unique_ptr<CalibFrontEndInfo>> > map_values;
94
95 std::unique_ptr<TFile> wFile = std::make_unique<TFile>();
96
98
100
101 printf("Time to calculate threshold calibration\n");
102 std::string moduleName = "";
103 Calib Calibration(whichPart,saveInfo, moduleName);
104 if(!(Calibration.fillThresholds(pixmap ,thres_f ,map_values )) ){
105 printf("Error - The threshold calibration was not properly finished.\n");
106 return 1;
107 }
109 printf("Time taken for threshold calibration:%7.1f seconds\n",double(end - start));
110
111 if(map_values.size() == 0){
112
113
114 if( std::strcmp(moduleName.c_str(), "") != 0 ){
115 printf("main::main: Running only one module: %s - It does not belong to %s\n",moduleName.c_str(), sWhichPart.at(whichPart).c_str());
116 return 0;
117 }
118 printf("main::main: ERROR - Size of filled map is 0. Does the %s exist in the %s file?\n",sWhichPart.at(whichPart).c_str(),thres_f.c_str());
119 return 1;
120 }
121
123
124 printf("Time to take timing calibration\n");
125 if(!(Calibration.fillTiming(pixmap ,timin_f ,map_values )) ){
126 printf("Error - The timing calibration was not properly finished.\n");
127 return 1;
128 }
130 printf("Time taken for timing calibration:%7.1f seconds\n",double(end - start));
131
133
134 printf("Time to take TOT calibration\n");
135 if(!(Calibration.totFitting(pixmap ,totin_f ,map_values )) ){
136 printf("Error - The TOT calibration was not properly finished.\n");
137 return 1;
138 }
140 printf("Time taken for TOT calibration:%7.1f seconds\n",double(end - start));
141
142 std::ofstream
myFile(
"calibration_"+sWhichPart.at(whichPart)+
".txt");
143
144 printf("Total MODs:%4lu\n",map_values.size());
145 for(const auto & [key, MOD] : map_values){
146
147 for(const auto& FE : MOD){
148 std::stringstream sstr = FE->printDBformat();
149 printf("%s\n",sstr.str().c_str());
150 myFile << sstr.str() <<
"\n";
151 }
152 }
153
155
156 printf("********** JOB finished **********\n");
157 return 0;
158}
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
time(flags, cells_name, *args, **kw)