| 14 |
// |
// |
| 15 |
void usage(){ |
void usage(){ |
| 16 |
printf("\nUsage:\n"); |
printf("\nUsage:\n"); |
| 17 |
printf("\n YodaProfiler [-v | --verbose] [-h | --help] [--version] -rawFile raw_filename -yodaFile yoda_filename \n"); |
printf("\n YodaProfiler [options] -rawFile raw_filename -yodaFile yoda_filename \n"); |
| 18 |
printf("\n [-host host] [-user username] [-psw password] \n"); |
printf("\n -rawFile full path to the raw file\n"); |
| 19 |
|
printf("\n -yodaFile full path to the YODA file\n"); |
| 20 |
|
printf("\n Options can be: \n"); |
| 21 |
printf("\n --version print informations about compilation and exit\n"); |
printf("\n --version print informations about compilation and exit\n"); |
| 22 |
printf("\n -h | --help print this help and exit \n"); |
printf("\n -h | --help print this help and exit \n"); |
| 23 |
printf("\n -v | --verbose be verbose [default: print nothing on STDOUT]\n"); |
printf("\n -v | --verbose be verbose [default]\n"); |
| 24 |
|
printf("\n -s | --silent default: print nothing on STDOUT\n"); |
| 25 |
printf("\n -g | --debug be very verbose [default: no]\n"); |
printf("\n -g | --debug be very verbose [default: no]\n"); |
|
printf("\n -rawFile full path to the raw file\n"); |
|
|
printf("\n -yodaFile full path to the YODA file\n"); |
|
| 26 |
printf("\n -boot number CPU boot number [default = taken from VarDump]\n"); |
printf("\n -boot number CPU boot number [default = taken from VarDump]\n"); |
| 27 |
printf("\n -tsync number timesync (s) [default = taken from data]\n"); |
printf("\n -tsync number timesync (s) [default = taken from data]\n"); |
| 28 |
printf("\n -obt0 number obt at timesync (ms) [default = taken from data]\n"); |
printf("\n -obt0 number obt at timesync (ms) [default = taken from data]\n"); |
| 29 |
printf("\n -host name for the host [default = mysql://localhost/pamelaprod]\n"); |
printf("\n -clean number number in seconds after which the fragment table\n"); |
| 30 |
printf("\n -user username for the DB [default = anonymous] \n"); |
printf("\n can be cleaned and runs validated [default = -1 do not clean],\n"); |
| 31 |
printf("\n -psw password for the DB [default = \"\"]\n"); |
printf("\n if 0 force cleaning immediatly, if negative do not clean\n"); |
| 32 |
printf("\nExamples: \n"); |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
| 33 |
printf("\n YodaProfiler -rawFile /path/to/raw/files/000_000_00000_cln2.pam -yodaFile /path/to/filesfromyoda/000_000_00000_cln2.root \n\n"); |
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
| 34 |
|
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
| 35 |
|
printf("\n The order of input files and options does not matter. \n"); |
| 36 |
|
printf("\nExample: \n"); |
| 37 |
|
printf("\n YodaProfiler -yodaFile /path/to/raw/files/000_000_00000_cln2.pam -rawFile /path/to/filesfromyoda/000_000_00000_cln2.root -v \n\n"); |
| 38 |
}; |
}; |
| 39 |
// |
// |
| 40 |
int main(int numinp, char *inps[]){ |
int main(int numinp, char *inps[]){ |
| 46 |
UInt_t boot = 0; |
UInt_t boot = 0; |
| 47 |
UInt_t tsync = 0; |
UInt_t tsync = 0; |
| 48 |
UInt_t obt0 = 0; |
UInt_t obt0 = 0; |
| 49 |
|
// Long64_t olderthan = 864000LL; |
| 50 |
|
Long64_t olderthan = -1LL; |
| 51 |
// |
// |
| 52 |
// |
// |
| 53 |
TString filerawname; |
TString filerawname; |
| 54 |
// |
// |
| 55 |
TString host; |
TString host = "mysql://localhost/pamelaprod"; |
| 56 |
TString user; |
TString user = "anonymous"; |
| 57 |
TString password; |
TString password = ""; |
| 58 |
|
// |
| 59 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 60 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 61 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 62 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 63 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 64 |
|
if ( strcmp(pamdbpsw,"") ) password = pamdbpsw; |
| 65 |
// |
// |
| 66 |
TString filerootname; |
TString filerootname; |
| 67 |
// |
// |
| 68 |
Bool_t beverbose = false; |
Bool_t beverbose = true; |
| 69 |
Bool_t debug = false; |
Bool_t debug = false; |
| 70 |
Int_t i = 0; |
Int_t i = 0; |
| 71 |
// |
// |
| 105 |
usage(); |
usage(); |
| 106 |
exit(1); |
exit(1); |
| 107 |
}; |
}; |
| 108 |
tsync = atoi(inps[i+1]); |
tsync = (UInt_t)atoll(inps[i+1]); |
| 109 |
}; |
}; |
| 110 |
if ( !strcmp(inps[i],"-obt0") ) { |
if ( !strcmp(inps[i],"-obt0") ) { |
| 111 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
| 112 |
usage(); |
usage(); |
| 113 |
exit(1); |
exit(1); |
| 114 |
}; |
}; |
| 115 |
obt0 = atoi(inps[i+1]); |
obt0 = (UInt_t)atoll(inps[i+1]); |
| 116 |
|
}; |
| 117 |
|
if ( !strcmp(inps[i],"-clean") ) { |
| 118 |
|
if ( numinp-1 < i+1 ){ |
| 119 |
|
usage(); |
| 120 |
|
exit(1); |
| 121 |
|
}; |
| 122 |
|
olderthan = (Long64_t)atoll(inps[i+1]); |
| 123 |
}; |
}; |
| 124 |
if ( !strcmp(inps[i],"-host") ) { |
if ( !strcmp(inps[i],"-host") ) { |
| 125 |
if ( numinp-1 < i+1 ){ |
if ( numinp-1 < i+1 ){ |
| 145 |
// |
// |
| 146 |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
| 147 |
// |
// |
| 148 |
|
if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ) beverbose = false; |
| 149 |
|
// |
| 150 |
if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true; |
if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true; |
| 151 |
// |
// |
| 152 |
i++; |
i++; |
| 178 |
UInt_t WAR[10]; |
UInt_t WAR[10]; |
| 179 |
memset(WAR, 0, 10*sizeof(UInt_t)); |
memset(WAR, 0, 10*sizeof(UInt_t)); |
| 180 |
// |
// |
| 181 |
printf("\n Welcome to the PAMELA SuperYodaProfiler, version %s \n\n",version); |
printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version); |
| 182 |
try{ |
try{ |
| 183 |
// |
// |
| 184 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
| 185 |
// Create pamDB object and open SQL connection |
// Create pamDB object and open SQL connection |
| 186 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
| 187 |
if ( beverbose ) printf(" 1 => Create pamDB object and open SQL connection \n"); |
if ( beverbose ) printf(" 1 => Initialize and open SQL connection \n"); |
| 188 |
pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug); |
pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug); |
| 189 |
pamDB->CheckFile(); |
pamDB->CheckFile(); |
| 190 |
|
pamDB->SetOlderThan(olderthan); |
| 191 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
| 192 |
// |
// |
| 193 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
| 248 |
WAR[7] = pamDB->insertS4_CALIB(); |
WAR[7] = pamDB->insertS4_CALIB(); |
| 249 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
| 250 |
|
|
| 251 |
|
//------------------------------------------------------------------------------------------- |
| 252 |
|
//Clean the GL_RUN_FRAGMENTS |
| 253 |
|
//------------------------------------------------------------------------------------------- |
| 254 |
|
if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table\n"); |
| 255 |
|
WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS(); |
| 256 |
|
//------------------------------------------------------------------------------------------- |
| 257 |
|
|
| 258 |
|
//------------------------------------------------------------------------------------------- |
| 259 |
|
//Validate runs |
| 260 |
|
//------------------------------------------------------------------------------------------- |
| 261 |
|
if ( beverbose ) printf(" 11 => Validate runs\n"); |
| 262 |
|
WAR[9] = pamDB->ValidateRuns(); |
| 263 |
|
//------------------------------------------------------------------------------------------- |
| 264 |
|
|
| 265 |
} catch (Int_t exc) { |
} catch (Int_t exc) { |
| 266 |
signal = exc; |
signal = exc; |
| 267 |
switch(exc){ |
switch(exc){ |
| 288 |
case -22: message += " No CalibTrk1 tree in Level0 file"; break; |
case -22: message += " No CalibTrk1 tree in Level0 file"; break; |
| 289 |
case -23: message += " No CalibTrk2 tree in Level0 file"; break; |
case -23: message += " No CalibTrk2 tree in Level0 file"; break; |
| 290 |
case -24: message += " No CalibS4 tree in Level0 file"; break; |
case -24: message += " No CalibS4 tree in Level0 file"; break; |
| 291 |
case -97: message += " Missing runheader not recognized by HandleRun method"; break; |
case -25: message += " Cannot find the run just inserted"; break; |
| 292 |
case -99: message += " THIS CASE HAS NOT YET BEEN IMPLEMENTED"; break; |
case -26: message += " Raw file not found looking for VarDump"; break; |
| 293 |
default: message += " Unidentified error"; break; |
default: message += " Unidentified error"; break; |
| 294 |
}; |
}; |
| 295 |
printf("\n"); |
printf("\n"); |
| 309 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 310 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 311 |
if ( bit == 0 ) message += "=> RAW file already inserted\n"; |
if ( bit == 0 ) message += "=> RAW file already inserted\n"; |
| 312 |
else message += "=> Unidentified warning\n"; |
else message += "=> Unidentified insertPamelaRaw warning\n"; |
| 313 |
}; |
}; |
| 314 |
}; |
}; |
| 315 |
}; |
}; |
| 318 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 319 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 320 |
if ( bit == 0 ) message += "=> TIMESYNC already inserted\n"; |
if ( bit == 0 ) message += "=> TIMESYNC already inserted\n"; |
| 321 |
if ( bit == 1 ) message += "=> No mcmd timesync in the file\n"; |
else if ( bit == 1 ) message += "=> No mcmd timesync in the file\n"; |
| 322 |
else message += "=> Unidentified warning\n"; |
else if ( bit == 2 ) message += "=> No runheaders in the file\n"; |
| 323 |
|
else if ( bit == 3 ) message += "=> No runtrailers in the file\n"; |
| 324 |
|
else if ( bit == 4 ) message += "=> No mcmd inclination in the file\n"; |
| 325 |
|
else message += "=> Unidentified insertTimeSync warning\n"; |
| 326 |
}; |
}; |
| 327 |
}; |
}; |
| 328 |
}; |
}; |
| 331 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 332 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 333 |
if ( bit == 0 ) message += "=> ROOT file already inserted\n"; |
if ( bit == 0 ) message += "=> ROOT file already inserted\n"; |
| 334 |
else message += "=> Unidentified warning\n"; |
else message += "=> Unidentified insertPamelaRoot warning\n"; |
| 335 |
}; |
}; |
| 336 |
}; |
}; |
| 337 |
}; |
}; |
| 339 |
if ( j == 3 ){ // assignBOOTnumber warnings |
if ( j == 3 ){ // assignBOOTnumber warnings |
| 340 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 341 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 342 |
if ( bit == 0 ) message += "=> BOOT number already inserted\n"; |
if ( bit == 0 ) message += "=> BOOT number already inserted\n";// |
| 343 |
if ( bit == 1 ) message += "=> VarDump event tree is empty, use the -boot option to override\n"; |
else if ( bit == 1 ) message += "=> VarDump event tree is empty, use the -boot option to override\n";// |
| 344 |
if ( bit == 2 ) message += "=> No BOOT number in VarDump(!), use the -boot option to override\n"; |
else if ( bit == 2 ) message += "=> No BOOT number in VarDump(!), use the -boot option to override\n";// |
| 345 |
if ( bit == 3 ) message += "=> Raw file not found looking for VarDump, use the -boot option to override\n"; |
else if ( bit == 4 ) message += "=> The file is not in the database looking for VarDump, use the -boot option to override\n";// |
| 346 |
if ( bit == 4 ) message += "=> The file is not in the database looking for VarDump, use the -boot option to override\n"; |
else message += "=> Unidentified assignBOOTnumber warning\n"; |
|
else message += "=> Unidentified warning\n"; |
|
| 347 |
}; |
}; |
| 348 |
}; |
}; |
| 349 |
}; |
}; |
| 351 |
if ( j == 4 ){ // insertPamelaRUN |
if ( j == 4 ){ // insertPamelaRUN |
| 352 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 353 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 354 |
if ( bit == 0 ) message += "=> bah already inserted\n"; |
if ( bit == 0 ) message += "=> Inconsistent PKT/OBT sequence\n"; |
| 355 |
else if ( bit == 1 ) message += "=> boh already inserted\n"; |
else if ( bit == 1 ) message += "=> No physics events in the file\n"; |
| 356 |
else message += "=> Unidentified warning\n"; |
else if ( bit == 2 ) message += "=> Less than 2 physics events in the file\n"; |
| 357 |
|
else message += "=> Unidentified insertPamelaRun warning\n"; |
| 358 |
}; |
}; |
| 359 |
}; |
}; |
| 360 |
}; |
}; |
| 362 |
if ( j == 5 ){ // insertCALO_CALIB |
if ( j == 5 ){ // insertCALO_CALIB |
| 363 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 364 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 365 |
if ( bit == 0 ) message += "=> bah already inserted\n"; |
if ( bit == 0 ) message += "=> No calorimeter calibrations in the file\n"; |
| 366 |
else if ( bit == 1 ) message += "=> boh already inserted\n"; |
else message += "=> Unidentified insertCaloCalib warning\n"; |
|
else message += "=> Unidentified warning\n"; |
|
| 367 |
}; |
}; |
| 368 |
}; |
}; |
| 369 |
}; |
}; |
| 372 |
if ( j == 6 ){ // insertTRACKER_CALIB |
if ( j == 6 ){ // insertTRACKER_CALIB |
| 373 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 374 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 375 |
if ( bit == 0 ) message += "=> bah already inserted\n"; |
if ( bit == 0 ) message += "=> No tracker calibrations in the file\n"; |
| 376 |
else if ( bit == 1 ) message += "=> boh already inserted\n"; |
else message += "=> Unidentified insertTrkCalib warning\n"; |
|
else message += "=> Unidentified warning\n"; |
|
| 377 |
}; |
}; |
| 378 |
}; |
}; |
| 379 |
}; |
}; |
| 382 |
if ( j == 7 ){ // insertS4_CALIB |
if ( j == 7 ){ // insertS4_CALIB |
| 383 |
for (UInt_t bit=0; bit<32; bit++){ |
for (UInt_t bit=0; bit<32; bit++){ |
| 384 |
if ( WAR[j] & (1 << bit) ){ |
if ( WAR[j] & (1 << bit) ){ |
| 385 |
if ( bit == 0 ) message += "=> bah already inserted\n"; |
if ( bit == 0 ) message += "=> No s4 calibrations in the file\n"; |
| 386 |
else if ( bit == 1 ) message += "=> boh already inserted\n"; |
else message += "=> Unidentified insertS4calib warning\n"; |
| 387 |
else message += "=> Unidentified warning\n"; |
}; |
| 388 |
|
}; |
| 389 |
|
}; |
| 390 |
|
// |
| 391 |
|
// |
| 392 |
|
if ( j == 8 ){ // CleanGL_RUN_FRAGMENTS |
| 393 |
|
for (UInt_t bit=0; bit<32; bit++){ |
| 394 |
|
if ( WAR[j] & (1 << bit) ){ |
| 395 |
|
if ( bit == 0 ) message += "=> Skip the GL_RUN_FRAGMENTS table cleaning\n"; |
| 396 |
|
else message += "=> Unidentified CleanGL_RUN_FRAGMENTS warning\n"; |
| 397 |
}; |
}; |
| 398 |
}; |
}; |
| 399 |
}; |
}; |
| 400 |
// |
// |
| 401 |
|
if ( j == 9 ){ // ValidateRuns |
| 402 |
|
for (UInt_t bit=0; bit<32; bit++){ |
| 403 |
|
if ( WAR[j] & (1 << bit) ){ |
| 404 |
|
if ( bit == 0 ) message += "=> Skip the run validation \n"; |
| 405 |
|
else message += "=> Unidentified ValidateRuns warning\n"; |
| 406 |
|
}; |
| 407 |
|
}; |
| 408 |
|
}; |
| 409 |
}; |
}; |
| 410 |
}; |
}; |
| 411 |
// |
// |
| 419 |
//--------------------------------------------------------------------------------------- |
//--------------------------------------------------------------------------------------- |
| 420 |
// Close and exit |
// Close and exit |
| 421 |
//--------------------------------------------------------------------------------------- |
//--------------------------------------------------------------------------------------- |
| 422 |
|
if ( beverbose ) printf(" 12 => Free objects and close SQL connection \n"); |
| 423 |
pamDB->Close(); |
pamDB->Close(); |
| 424 |
// |
// |
| 425 |
printf("\n"); |
printf("\n"); |