22 |
#include <S4Core.h> |
#include <S4Core.h> |
23 |
#include <NDCore.h> |
#include <NDCore.h> |
24 |
#include <OrbitalInfoCore.h> |
#include <OrbitalInfoCore.h> |
25 |
|
#include <RunInfo.h> |
26 |
// |
// |
27 |
using namespace std; |
using namespace std; |
28 |
// |
// |
35 |
void usage(){ |
void usage(){ |
36 |
printf("\nUsage:\n"); |
printf("\nUsage:\n"); |
37 |
printf("\n DarthVader [-v | --verbose] [-h | --help] [--version] -idRun ID_RUN [-processFile filename]\n"); |
printf("\n DarthVader [-v | --verbose] [-h | --help] [--version] -idRun ID_RUN [-processFile filename]\n"); |
38 |
printf("\n [-host host] [-user username] [-psw password] [+-all] [+-detector [detector options] ]\n"); |
printf("\n [-host host] [-user username] [-psw password] [+-all] [+-detector [ detector options ] ]\n"); |
39 |
printf("\n --version print informations about compilation and exit\n"); |
printf("\n --version print informations about compilation and exit\n"); |
40 |
printf("\n -h | --help print this help and exit \n"); |
printf("\n -h | --help print this help and exit \n"); |
41 |
printf("\n -v | --verbose be verbose [default: print nothing on STDOUT]\n"); |
printf("\n -v | --verbose be verbose [default]\n"); |
42 |
|
printf("\n -s | --silent print nothing on STDOUT]\n"); |
43 |
printf("\n -idRun ID_RUN: ID number of the run to be processed \n"); |
printf("\n -idRun ID_RUN: ID number of the run to be processed \n"); |
44 |
printf("\n -processFile output filename [default ID_RUN.Level2.root]\n"); |
printf("\n -processFile output filename [default ID_RUN.Level2.root]\n"); |
45 |
printf("\n -processFolder folder for output data but the processFile [default \"calorimeterFolder\"]\n"); |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
46 |
printf("\n -host name for the host [default = mysql://localhost/pamelaprod]\n"); |
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
47 |
printf("\n -user username for the DB [default = anonymous] \n"); |
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
48 |
printf("\n -psw password for the DB [default = \"\"]\n"); |
printf("\n +all | +ALL call all detectors software [default]\n"); |
49 |
printf("\n +all call all detectors software [default]\n"); |
printf("\n -all | -ALL call nothing\n"); |
|
printf("\n -all call nothing\n"); |
|
50 |
printf("\n +detector process detector; detector can be: TOF,TRK,CAL,TRG,ORB,S4,ND,AC,RUN\n"); |
printf("\n +detector process detector; detector can be: TOF,TRK,CAL,TRG,ORB,S4,ND,AC,RUN\n"); |
51 |
printf("\n -detector do not process detector (as above)\n"); |
printf("\n -detector do not process detector (as above)\n"); |
52 |
|
printf("\n detector options must be included in square parenthesis with spaces, for example:\n"); |
53 |
|
printf("\n +CAL [ --verbose -g ] +TRK [ -v --level1 ] \n"); |
54 |
|
|
55 |
printf("\nExamples: \n"); |
printf("\nExamples: \n"); |
56 |
printf("\nStandard call: DarthVader -idRun 1085 \n"); |
printf("\nStandard call: DarthVader -idRun 1085 \n"); |
57 |
printf("\nProcess only RunInfo and Tracker (be verbose for tracker): DarthVader -idRun 1085 -all +RUN +TRK [ --verbose ] \n"); |
printf("\nProcess only RunInfo and Tracker (be verbose for tracker): DarthVader -idRun 1085 -all +RUN +TRK [ --verbose ] \n"); |
79 |
Int_t NDSGN = 0; |
Int_t NDSGN = 0; |
80 |
// |
// |
81 |
Bool_t debug = false; |
Bool_t debug = false; |
82 |
Bool_t beverbose = false; |
Bool_t beverbose = true; |
83 |
Bool_t givenid = false; |
Bool_t givenid = false; |
84 |
Bool_t CAL = true; |
Bool_t CAL = true; |
85 |
Bool_t TRK = true; |
Bool_t TRK = true; |
112 |
// |
// |
113 |
// |
// |
114 |
// |
// |
115 |
ULong64_t run = 0; |
UInt_t run = 0; |
116 |
// |
// |
117 |
TString filename; |
TString filename; |
118 |
TString outDir = gSystem->WorkingDirectory(); |
TString outDir = gSystem->WorkingDirectory(); |
122 |
TString user = "anonymous"; |
TString user = "anonymous"; |
123 |
TString psw = ""; |
TString psw = ""; |
124 |
// |
// |
125 |
|
// |
126 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
127 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
128 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
129 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
130 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
131 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
132 |
|
// |
133 |
|
// |
134 |
TFile *processFile = 0; |
TFile *processFile = 0; |
135 |
// |
// |
136 |
// Checking input parameters |
// Checking input parameters |
139 |
try { |
try { |
140 |
if ( numinp > 1 ){ |
if ( numinp > 1 ){ |
141 |
while ( i < numinp ){ |
while ( i < numinp ){ |
142 |
|
Bool_t found = false; |
143 |
if ( !strcmp(inps[i],"--version") ){ |
if ( !strcmp(inps[i],"--version") ){ |
144 |
DarthVaderInfo(true); |
DarthVaderInfo(true); |
145 |
exit(0); |
exit(0); |
153 |
usage(); |
usage(); |
154 |
throw -3; |
throw -3; |
155 |
}; |
}; |
156 |
|
i++; |
157 |
|
found = true; |
158 |
givenid = true; |
givenid = true; |
159 |
char *pEnd; |
run = atoll(inps[i]); |
|
run = strtoull(inps[i+1],&pEnd,0); |
|
160 |
}; |
}; |
161 |
if ( !strcmp(inps[i],"-processFile") ) { |
if ( !strcmp(inps[i],"-processFile") ) { |
162 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
163 |
usage(); |
usage(); |
164 |
throw -3; |
throw -3; |
165 |
}; |
}; |
166 |
filename = (TString)inps[i+1]; |
i++; |
167 |
|
found = true; |
168 |
|
filename = (TString)inps[i]; |
169 |
}; |
}; |
170 |
if ( !strcmp(inps[i],"-outDir") ) { |
if ( !strcmp(inps[i],"-outDir") ) { |
171 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
172 |
usage(); |
usage(); |
173 |
throw -3; |
throw -3; |
174 |
}; |
}; |
175 |
outDir = (TString)inps[i+1]; |
i++; |
176 |
|
found = true; |
177 |
|
outDir = (TString)inps[i]; |
178 |
}; |
}; |
179 |
if ( !strcmp(inps[i],"-host") ) { |
if ( !strcmp(inps[i],"-host") ) { |
180 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
181 |
usage(); |
usage(); |
182 |
throw -3; |
throw -3; |
183 |
}; |
}; |
184 |
host = (TString)inps[i+1]; |
i++; |
185 |
|
found = true; |
186 |
|
host = (TString)inps[i]; |
187 |
}; |
}; |
188 |
if ( !strcmp(inps[i],"-user") ) { |
if ( !strcmp(inps[i],"-user") ) { |
189 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
190 |
usage(); |
usage(); |
191 |
throw -3; |
throw -3; |
192 |
}; |
}; |
193 |
user = (TString)inps[i+1]; |
i++; |
194 |
|
found = true; |
195 |
|
user = (TString)inps[i]; |
196 |
}; |
}; |
197 |
if ( !strcmp(inps[i],"-psw") ) { |
if ( !strcmp(inps[i],"-psw") ) { |
198 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
199 |
usage(); |
usage(); |
200 |
throw -3; |
throw -3; |
201 |
}; |
}; |
202 |
psw = (TString)inps[i+1]; |
i++; |
203 |
|
found = true; |
204 |
|
psw = (TString)inps[i]; |
205 |
|
}; |
206 |
|
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ){ |
207 |
|
found = true; |
208 |
|
beverbose = true; |
209 |
|
}; |
210 |
|
if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ){ |
211 |
|
found = true; |
212 |
|
beverbose = false; |
213 |
}; |
}; |
|
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
|
214 |
// |
// |
215 |
if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true; |
if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ){ |
216 |
|
debug = true; |
217 |
|
found = true; |
218 |
|
}; |
219 |
// |
// |
220 |
if ( !strcmp(inps[i],"-CAL") ) { |
if ( !strcmp(inps[i],"-CAL") ) { |
221 |
|
found = true; |
222 |
CAL = false; |
CAL = false; |
223 |
}; |
}; |
224 |
if ( !strcmp(inps[i],"-TRK") ) { |
if ( !strcmp(inps[i],"-TRK") ) { |
225 |
|
found = true; |
226 |
TRK = false; |
TRK = false; |
227 |
}; |
}; |
228 |
if ( !strcmp(inps[i],"-TOF") ) { |
if ( !strcmp(inps[i],"-TOF") ) { |
229 |
|
found = true; |
230 |
TOF = false; |
TOF = false; |
231 |
}; |
}; |
232 |
if ( !strcmp(inps[i],"-TRG") ) { |
if ( !strcmp(inps[i],"-TRG") ) { |
233 |
|
found = true; |
234 |
TRG = false; |
TRG = false; |
235 |
}; |
}; |
236 |
if ( !strcmp(inps[i],"-S4") ) { |
if ( !strcmp(inps[i],"-S4") ) { |
237 |
|
found = true; |
238 |
S4 = false; |
S4 = false; |
239 |
}; |
}; |
240 |
if ( !strcmp(inps[i],"-ND") ) { |
if ( !strcmp(inps[i],"-ND") ) { |
241 |
|
found = true; |
242 |
ND = false; |
ND = false; |
243 |
}; |
}; |
244 |
if ( !strcmp(inps[i],"-AC") ) { |
if ( !strcmp(inps[i],"-AC") ) { |
245 |
|
found = true; |
246 |
AC = false; |
AC = false; |
247 |
}; |
}; |
248 |
if ( !strcmp(inps[i],"-RUN") ) { |
if ( !strcmp(inps[i],"-RUN") ) { |
249 |
|
found = true; |
250 |
RUN = false; |
RUN = false; |
251 |
}; |
}; |
252 |
if ( !strcmp(inps[i],"-ORB") ) { |
if ( !strcmp(inps[i],"-ORB") ) { |
253 |
|
found = true; |
254 |
ORB = false; |
ORB = false; |
255 |
}; |
}; |
256 |
// |
// |
257 |
if ( !strcmp(inps[i],"-all") ) { |
if ( !strcmp(inps[i],"-all") || !strcmp(inps[i],"-ALL") ) { |
258 |
CAL = false; |
CAL = false; |
259 |
ORB = false; |
ORB = false; |
260 |
TRK = false; |
TRK = false; |
264 |
ND = false; |
ND = false; |
265 |
AC = false; |
AC = false; |
266 |
RUN = false; |
RUN = false; |
267 |
|
found = true; |
268 |
}; |
}; |
269 |
// |
// |
270 |
if ( !strcmp(inps[i],"+all") ) { |
if ( !strcmp(inps[i],"+all") || !strcmp(inps[i],"+ALL") ) { |
271 |
CAL = true; |
CAL = true; |
272 |
ORB = true; |
ORB = true; |
273 |
TRK = true; |
TRK = true; |
277 |
ND = true; |
ND = true; |
278 |
AC = true; |
AC = true; |
279 |
RUN = true; |
RUN = true; |
280 |
|
found = true; |
281 |
}; |
}; |
282 |
// |
// |
283 |
if ( !strcmp(inps[i],"+CAL") ) { |
if ( !strcmp(inps[i],"+CAL") ) { |
284 |
|
found = true; |
285 |
CAL = true; |
CAL = true; |
286 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
287 |
if ( numinp < i+2 ){ |
if ( numinp < i+2 ){ |
302 |
}; |
}; |
303 |
}; |
}; |
304 |
if ( !strcmp(inps[i],"+TRK") ) { |
if ( !strcmp(inps[i],"+TRK") ) { |
305 |
|
found = true; |
306 |
TRK = true; |
TRK = true; |
307 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
308 |
if ( numinp-1 < i+2 ){ |
if ( numinp-1 < i+2 ){ |
323 |
}; |
}; |
324 |
}; |
}; |
325 |
if ( !strcmp(inps[i],"+TOF") ) { |
if ( !strcmp(inps[i],"+TOF") ) { |
326 |
|
found = true; |
327 |
TOF = true; |
TOF = true; |
328 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
329 |
i += 2; |
i += 2; |
340 |
}; |
}; |
341 |
}; |
}; |
342 |
if ( !strcmp(inps[i],"+TRG") ) { |
if ( !strcmp(inps[i],"+TRG") ) { |
343 |
|
found = true; |
344 |
TRG = true; |
TRG = true; |
345 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
346 |
i += 2; |
i += 2; |
357 |
}; |
}; |
358 |
}; |
}; |
359 |
if ( !strcmp(inps[i],"+ORB") ) { |
if ( !strcmp(inps[i],"+ORB") ) { |
360 |
|
found = true; |
361 |
ORB = true; |
ORB = true; |
362 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
363 |
i += 2; |
i += 2; |
374 |
}; |
}; |
375 |
}; |
}; |
376 |
if ( !strcmp(inps[i],"+RUN") ) { |
if ( !strcmp(inps[i],"+RUN") ) { |
377 |
|
found = true; |
378 |
RUN = true; |
RUN = true; |
379 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
380 |
i += 2; |
i += 2; |
391 |
}; |
}; |
392 |
}; |
}; |
393 |
if ( !strcmp(inps[i],"+AC") ) { |
if ( !strcmp(inps[i],"+AC") ) { |
394 |
|
found = true; |
395 |
AC = true; |
AC = true; |
396 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
397 |
i += 2; |
i += 2; |
408 |
}; |
}; |
409 |
}; |
}; |
410 |
if ( !strcmp(inps[i],"+S4") ) { |
if ( !strcmp(inps[i],"+S4") ) { |
411 |
|
found = true; |
412 |
S4 = true; |
S4 = true; |
413 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
414 |
i += 2; |
i += 2; |
425 |
}; |
}; |
426 |
}; |
}; |
427 |
if ( !strcmp(inps[i],"+ND") ) { |
if ( !strcmp(inps[i],"+ND") ) { |
428 |
|
found = true; |
429 |
ND = true; |
ND = true; |
430 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
431 |
i += 2; |
i += 2; |
442 |
}; |
}; |
443 |
}; |
}; |
444 |
// |
// |
445 |
|
if ( !found && i > 0 ){ |
446 |
|
usage(); |
447 |
|
printf(" Unknown input number %i, that is \"%s\" \n",i,inps[i]); |
448 |
|
throw -22; |
449 |
|
}; |
450 |
|
// |
451 |
i++; |
i++; |
452 |
}; |
}; |
453 |
// |
// |
511 |
RUNSGN = RunInfoCore(run,processFile,dbc,runargc,runargv); |
RUNSGN = RunInfoCore(run,processFile,dbc,runargc,runargv); |
512 |
printf("done\n"); |
printf("done\n"); |
513 |
}; |
}; |
514 |
|
// |
515 |
|
// From the Run Infos extract acq_var_info to determine if detectors are in the acquisition or not |
516 |
|
// |
517 |
|
printf(" Checking if requested detectors are in the acquisition\n"); |
518 |
|
ItoRunInfo *runinfo = new ItoRunInfo(processFile); |
519 |
|
runinfo->Read(run); |
520 |
|
printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO); |
521 |
|
if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ) throw -16; |
522 |
|
if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ) throw -17; |
523 |
|
if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ) throw -18; |
524 |
|
if ( AC && !(runinfo->ACQ_VAR_INFO & (1 << 1)) && !(runinfo->ACQ_VAR_INFO & (1 << 2)) ) throw -19; |
525 |
|
if ( S4 && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ) throw -20; |
526 |
|
if ( ND && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ) throw -21; |
527 |
|
printf(" OK! start processing detector's data. \n"); |
528 |
|
// |
529 |
if ( TRK ) { |
if ( TRK ) { |
530 |
printf(" Calling TrackerLevel2... "); |
printf(" Calling TrackerLevel2... "); |
531 |
TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv); |
TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv); |
580 |
case -8: message += " No Header branch in LEVEL0 Physics tree"; break; |
case -8: message += " No Header branch in LEVEL0 Physics tree"; break; |
581 |
case -9: message += " No Registry branch in LEVEL0 Physics tree"; break; |
case -9: message += " No Registry branch in LEVEL0 Physics tree"; break; |
582 |
case -11: message += " LEVEL0 Physics tree is empty"; break; |
case -11: message += " LEVEL0 Physics tree is empty"; break; |
583 |
case -12: message += " Too few entries in the registry tree"; break; |
case -12: message += " Too few entries in the tree"; break; |
584 |
case -13: message += " Cannot create processFolder directory"; break; |
case -13: message += " Cannot create processFolder directory"; break; |
585 |
case -14: message += " Error querying the DB"; break; |
case -14: message += " Error querying the DB"; break; |
586 |
case -15: message += " Cannot open file for writing"; break; |
case -15: message += " Cannot open file for writing"; break; |
587 |
|
case -16: message += " No tracker in the acquisition (use -TRK to process anyway)"; break; |
588 |
|
case -17: message += " No ToF in the acquisition (use -TOF to process anyway)"; break; |
589 |
|
case -18: message += " No calorimeter in the acquisition (use -CAL to process anyway)"; break; |
590 |
|
case -19: message += " No anticounters in the acquisition (use -AC to process anyway)"; break; |
591 |
|
case -20: message += " No S4 in the acquisition (use -S4 to process anyway)"; break; |
592 |
|
case -21: message += " No neutron detector in the acquisition (use -ND to process anyway)"; break; |
593 |
|
case -22: message += " Unknown input or wrong syntax in input paramters!"; break; |
594 |
// |
// |
595 |
case -50: message += " GLTABLES - No entries matching GL_RUN query"; break; |
case -50: message += " GLTABLES - No entries matching GL_RUN query"; break; |
596 |
case -51: message += " GLTABLES - No entries matching GL_ROOT query"; break; |
case -51: message += " GLTABLES - No entries matching GL_ROOT query"; break; |
657 |
case -803: message += " RUNINFO - Updating but no RunInfo tree in Level2 file"; break; |
case -803: message += " RUNINFO - Updating but no RunInfo tree in Level2 file"; break; |
658 |
case -804: message += " RUNINFO - Unknown detector"; break; |
case -804: message += " RUNINFO - Unknown detector"; break; |
659 |
case -805: message += " RUNINFO - Reprocessing data but no RunInfo tree in Level2 file"; break; |
case -805: message += " RUNINFO - Reprocessing data but no RunInfo tree in Level2 file"; break; |
660 |
|
case -806: message += " RUNINFO - Can not handle more than 500 runs"; break; |
661 |
// |
// |
662 |
default: message += "Unidentified error or warning"; break; |
default: message += "Unidentified error or warning"; break; |
663 |
}; |
}; |
685 |
// |
// |
686 |
if ( error != 0 ) printf("\n\n WARNING: exiting with signal %i \n\n",error); |
if ( error != 0 ) printf("\n\n WARNING: exiting with signal %i \n\n",error); |
687 |
printf("\n"); |
printf("\n"); |
688 |
|
printf("Finished, exiting...\n"); |
689 |
|
printf("\n"); |
690 |
// |
// |
691 |
// Close redirection if the case. |
// Close redirection if the case. |
692 |
// |
// |