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]\n"); |
printf("\n -v | --verbose be verbose [default]\n"); |
42 |
printf("\n -s | --silent print nothing on STDOUT]\n"); |
printf("\n -s | --silent print nothing on STDOUT\n"); |
43 |
|
printf("\n -c | --clean remove file if exiting with errors\n"); |
44 |
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"); |
45 |
printf("\n -processFile output filename [default ID_RUN.Level2.root]\n"); |
printf("\n -processFile output filename [default ID_RUN.Level2.root]\n"); |
46 |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
80 |
Int_t NDSGN = 0; |
Int_t NDSGN = 0; |
81 |
Int_t DVSGN = 0; |
Int_t DVSGN = 0; |
82 |
// |
// |
83 |
|
Bool_t remfile = false; |
84 |
Bool_t debug = false; |
Bool_t debug = false; |
85 |
Bool_t beverbose = true; |
Bool_t beverbose = true; |
86 |
Bool_t givenid = false; |
Bool_t givenid = false; |
213 |
found = true; |
found = true; |
214 |
beverbose = true; |
beverbose = true; |
215 |
}; |
}; |
216 |
|
if ( !strcmp(inps[i],"-c") || !strcmp(inps[i],"--clean")){ |
217 |
|
found = true; |
218 |
|
remfile = true; |
219 |
|
}; |
220 |
if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ){ |
if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ){ |
221 |
found = true; |
found = true; |
222 |
beverbose = false; |
beverbose = false; |
480 |
// |
// |
481 |
if ( !givenid ) throw -1; |
if ( !givenid ) throw -1; |
482 |
// |
// |
483 |
char *version = DarthVaderInfo(false); |
TString version = DarthVaderInfo(false); |
484 |
// |
// |
485 |
// Start: |
// Start: |
486 |
// |
// |
487 |
printf("\n Welcome to the PAMELA LEVEL2 flight software, version %s \n\n",version); |
printf("\n Welcome to the PAMELA LEVEL2 flight software, version %s \n\n",version.Data()); |
488 |
// |
// |
489 |
// Connect to the DB |
// Connect to the DB |
490 |
// |
// |
499 |
// |
// |
500 |
if ( debug ) printf("...connected! \n\n"); |
if ( debug ) printf("...connected! \n\n"); |
501 |
// |
// |
502 |
|
// Use UTC in the DB |
503 |
|
// |
504 |
|
stringstream myquery; |
505 |
|
myquery.str(""); |
506 |
|
myquery << "SET time_zone='+0:00'"; |
507 |
|
dbc->Query(myquery.str().c_str()); |
508 |
|
// |
509 |
|
// |
510 |
// Create LEVEL2 filename and open it in update mode |
// Create LEVEL2 filename and open it in update mode |
511 |
// |
// |
512 |
if ( filename.IsNull() ){ |
if ( filename.IsNull() ){ |
518 |
filename += strun.str(); |
filename += strun.str(); |
519 |
filename += ".Level2.root"; |
filename += ".Level2.root"; |
520 |
}; |
}; |
|
// filename = outDir + "/" + filename; |
|
521 |
processFile = new TFile(filename.Data(),"UPDATE"); |
processFile = new TFile(filename.Data(),"UPDATE"); |
522 |
if ( !processFile->IsOpen() ) throw -15; |
if ( !processFile->IsOpen() ) throw -15; |
523 |
// |
// |
524 |
// Run the core program, put any output error in the "error" variable |
// Run the core program, put any output error in the "error" variable |
525 |
// |
// |
526 |
|
printf("\n\n Pre-processing:\n\n"); |
527 |
|
// |
528 |
if ( RUN ) { |
if ( RUN ) { |
529 |
printf(" Calling RunInfo... "); |
printf(" Retrieve, if the case, the RUN informations from the DB...\n"); |
530 |
RUNSGN = RunInfoCore(run,processFile,dbc,runargc,runargv); |
printf(" RunInfo called\n"); |
531 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start RunInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
532 |
|
RUNSGN = RunInfoCore(run,processFile,dbc,version,runargc,runargv); |
533 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end RunInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
534 |
|
printf(" ...done\n"); |
535 |
}; |
}; |
536 |
// |
// |
537 |
// From the Run Infos extract acq_var_info to determine if detectors are in the acquisition or not |
// From the Run Infos extract acq_var_info to determine if detectors are in the acquisition or not |
538 |
// |
// |
539 |
printf(" Checking if requested detectors are in the acquisition\n"); |
printf(" Checking if requested detectors are in the acquisition\n"); |
540 |
ItoRunInfo *runinfo = new ItoRunInfo(processFile); |
ItoRunInfo *runinfo = new ItoRunInfo(processFile); |
541 |
runinfo->Read(run); |
Int_t sgnl = runinfo->Read(run); |
542 |
|
if ( sgnl != 0 ) throw -17; |
543 |
printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO); |
printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO); |
544 |
if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ) DVSGN = 16; |
if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ) DVSGN += 1; |
545 |
if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ) DVSGN = 17; |
if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ) DVSGN += 2; |
546 |
if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ) DVSGN = 18; |
if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ) DVSGN += 4; |
547 |
if ( AC && !(runinfo->ACQ_VAR_INFO & (1 << 1)) && !(runinfo->ACQ_VAR_INFO & (1 << 2)) ) DVSGN = 19; |
if ( AC && (!(runinfo->ACQ_VAR_INFO & (1 << 1)) || !(runinfo->ACQ_VAR_INFO & (1 << 2))) ) DVSGN += 8; |
548 |
if ( S4 && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ) DVSGN = 20; |
if ( S4 && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ) DVSGN += 16; |
549 |
if ( ND && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ) DVSGN = 21; |
if ( ND && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ) DVSGN += 32; |
550 |
printf(" OK! start processing detector's data. \n"); |
// |
551 |
|
if ( !DVSGN ){ |
552 |
|
printf(" OK! Start processing detector's data. \n"); |
553 |
|
} else { |
554 |
|
printf(" WARNING! missing detector(s)! Start anyway processing detector's data. \n"); |
555 |
|
}; |
556 |
|
printf("\n End pre-processing \n\n"); |
557 |
// |
// |
558 |
if ( TRK ) { |
if ( TRK ) { |
559 |
printf(" Calling TrackerLevel2... "); |
printf(" TrackerLevel2 called\n"); |
560 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start TrkCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
561 |
TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv); |
TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv); |
562 |
gSystem->Unlink("TrackerFolder"); //patch |
gSystem->Unlink("TrackerFolder"); //patch |
563 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end TrkCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
564 |
}; |
}; |
565 |
if ( TOF ) { |
if ( TOF ) { |
566 |
printf(" Calling ToFLevel2... "); |
printf(" ToFLevel2 called\n"); |
567 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start ToFCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
568 |
TOFSGN = ToFCore(run,processFile,dbc,tofargc,tofargv); |
TOFSGN = ToFCore(run,processFile,dbc,tofargc,tofargv); |
569 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end ToFCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
570 |
}; |
}; |
571 |
if ( CAL ) { |
if ( CAL ) { |
572 |
printf(" Calling CalorimeterLevel2... "); |
printf(" CalorimeterLevel2 called\n"); |
573 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start CaloCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
574 |
CALSGN = CaloCore(run,processFile,dbc,calargc,calargv); |
CALSGN = CaloCore(run,processFile,dbc,calargc,calargv); |
575 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end CaloCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
576 |
}; |
}; |
577 |
if ( TRG ) { |
if ( TRG ) { |
578 |
printf(" Calling TriggerLevel2... "); |
printf(" TriggerLevel2 called\n"); |
579 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start TrigCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
580 |
TRGSGN = TrigCore(run,processFile,dbc,trgargc,trgargv); |
TRGSGN = TrigCore(run,processFile,dbc,trgargc,trgargv); |
581 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end TrigCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
582 |
}; |
}; |
583 |
if ( AC ) { |
if ( AC ) { |
584 |
printf(" Calling AnticounterLevel2... "); |
printf(" AnticounterLevel2 called\n"); |
585 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start AcCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
586 |
ACSGN = AcCore(run,processFile,dbc,acargc,acargv); |
ACSGN = AcCore(run,processFile,dbc,acargc,acargv); |
587 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end AcCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
588 |
}; |
}; |
589 |
if ( S4 ) { |
if ( S4 ) { |
590 |
printf(" Calling S4Level2 ... "); |
printf(" S4Level2 called\n"); |
591 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start S4Core STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
592 |
S4SGN = S4Core(run,processFile,dbc,s4argc,s4argv); |
S4SGN = S4Core(run,processFile,dbc,s4argc,s4argv); |
593 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end S4Core STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
594 |
}; |
}; |
595 |
if ( ND ) { |
if ( ND ) { |
596 |
printf(" Calling NDLevel2... "); |
printf(" NDLevel2 called\n"); |
597 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start NDCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
598 |
NDSGN = NDCore(run,processFile,dbc,ndargc,ndargv); |
NDSGN = NDCore(run,processFile,dbc,ndargc,ndargv); |
599 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end NDCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
600 |
}; |
}; |
601 |
if ( ORB ) { |
if ( ORB ) { |
602 |
printf(" Calling OrbitalInfo... "); |
printf(" OrbitalInfo called\n"); |
603 |
|
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start OrbitalInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
604 |
ORBSGN = OrbitalInfoCore(run,processFile,dbc,orbargc,orbargv); |
ORBSGN = OrbitalInfoCore(run,processFile,dbc,orbargc,orbargv); |
605 |
printf("done\n"); |
if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end OrbitalInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n"); |
606 |
}; |
}; |
607 |
// |
// |
608 |
} catch(Int_t signal) { |
} catch(Int_t signal) { |
622 |
case -13: message += " Cannot create processFolder directory"; break; |
case -13: message += " Cannot create processFolder directory"; break; |
623 |
case -14: message += " Error querying the DB"; break; |
case -14: message += " Error querying the DB"; break; |
624 |
case -15: message += " Cannot open file for writing"; break; |
case -15: message += " Cannot open file for writing"; break; |
625 |
|
case -17: message += " Error during pre-processing"; break; |
626 |
case -22: message += " Unknown input or wrong syntax in input paramters!"; break; |
case -22: message += " Unknown input or wrong syntax in input paramters!"; break; |
627 |
// |
// |
628 |
case -50: message += " GLTABLES - No entries matching GL_RUN query"; break; |
case -50: message += " GLTABLES - No entries matching GL_RUN query"; break; |
698 |
if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl; |
if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl; |
699 |
} |
} |
700 |
// |
// |
701 |
switch(DVSGN){ // change message with printf!! |
// Warnings from XCore routines and from DV: |
702 |
case 16: message += " No tracker in the acquisition\n"; break; |
// |
703 |
case 17: message += " No ToF in the acquisition\n"; break; |
if ( debug && DVSGN ) printf(" DVSGN = %i \n",DVSGN); |
704 |
case 18: message += " No calorimeter in the acquisition\n"; break; |
if ( DVSGN ) printf("\n WARNING DarthVader: \n"); |
705 |
case 19: message += " No anticounters in the acquisition\n"; break; |
if ( DVSGN & (1 << 0) ) printf(" - No tracker in the acquisition\n"); |
706 |
case 20: message += " No S4 in the acquisition\n"; break; |
if ( DVSGN & (1 << 1) ) printf(" - No ToF in the acquisition\n"); |
707 |
case 21: message += " No neutron detector in the acquisition\n"; break; |
if ( DVSGN & (1 << 2) ) printf(" - No calorimeter in the acquisition\n"); |
708 |
}; |
if ( DVSGN & (1 << 3) ) printf(" - No anticounters in the acquisition\n"); |
709 |
|
if ( DVSGN & (1 << 4) ) printf(" - No S4 in the acquisition\n"); |
710 |
|
if ( DVSGN & (1 << 5) ) printf(" - No neutron detector in the acquisition\n"); |
711 |
|
// |
712 |
|
// CaloCore: |
713 |
// |
// |
|
// switch(RUNSGN){ |
|
|
// }; |
|
714 |
switch(CALSGN){ |
switch(CALSGN){ |
715 |
case 100: printf("\n WARNING CALORIMETER - Data with no associated calibration\n"); break; |
case 100: printf("\n WARNING CALORIMETER - Data with no associated calibration\n"); |
716 |
case 101: printf("\n WARNING CALORIMETER - No tracks or good events in this run\n"); break; |
case 101: printf("\n WARNING CALORIMETER - No tracks or good events in this run\n"); |
717 |
}; |
}; |
718 |
// |
// |
719 |
|
// no other at the moment |
720 |
|
// |
721 |
|
// |
722 |
// Close the DB connection |
// Close the DB connection |
723 |
// |
// |
724 |
if ( dbc ){ |
if ( dbc ){ |
732 |
}; |
}; |
733 |
// |
// |
734 |
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); |
735 |
printf("\n"); |
// |
736 |
printf("Finished, exiting...\n"); |
// |
737 |
printf("\n"); |
// |
738 |
|
if ( remfile && error < 0 ){ |
739 |
|
printf(" -c or --clean option used, deleting file %s \n\n",filename.Data()); |
740 |
|
gSystem->Unlink(filename.Data()); |
741 |
|
}; |
742 |
|
// |
743 |
|
printf("\n Finished, exiting...\n\n"); |
744 |
// |
// |
745 |
// Close redirection if the case. |
// Close redirection if the case. |
746 |
// |
// |