/[PAMELA software]/DarthVader/src/DarthVader.cpp
ViewVC logotype

Diff of /DarthVader/src/DarthVader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mocchiut, Fri May 19 13:15:25 2006 UTC revision 1.23 by mocchiut, Wed Dec 6 10:49:21 2006 UTC
# Line 10  Line 10 
10  #include <TSQLServer.h>  #include <TSQLServer.h>
11  #include <TFile.h>  #include <TFile.h>
12  #include <TSystem.h>  #include <TSystem.h>
13    #include <TStopwatch.h>
14  //  //
15  // Detector's package headers  // Detector's package headers
16  //  //
# Line 22  Line 23 
23  #include <S4Core.h>  #include <S4Core.h>
24  #include <NDCore.h>  #include <NDCore.h>
25  #include <OrbitalInfoCore.h>  #include <OrbitalInfoCore.h>
26    #include <RunInfo.h>
27  //  //
28  using namespace std;  using namespace std;
29  //  //
# Line 33  using namespace std; Line 35  using namespace std;
35  //  //
36  void usage(){  void usage(){
37    printf("\nUsage:\n");    printf("\nUsage:\n");
38    printf("\n DarthVader [-v | --verbose] [-h | --help] [--version] -idRun ID_RUN [-processFile filename]\n");    printf("\n DarthVader [ options ] -idRun ID_RUN [+-all] [+-detector [ detector options ] ] \n");
39    printf("\n            [-host host] [-user username] [-psw password] [+-all] [+-detector [detector options] ]\n");    printf("\n Options are: \n\n");
40    printf("\n --version       print informations about compilation and exit\n");    printf(" --version         print informations about compilation and exit\n");
41    printf("\n -h | --help     print this help and exit \n");    printf(" -h | --help       print this help and exit \n");
42    printf("\n -v | --verbose  be verbose [default: print nothing on STDOUT]\n");    printf(" -v | --verbose    be verbose [default]\n");
43    printf("\n -idRun          ID_RUN: ID number of the run to be processed \n");    printf(" -s | --silent     print nothing on STDOUT\n");
44    printf("\n -processFile    output filename [default ID_RUN.Level2.root]\n");    printf(" -c | --clean      remove file if exiting with errors\n");
45    printf("\n -processFolder  folder for output data but the processFile [default \"calorimeterFolder\"]\n");    printf(" -b | --benchmark  perform and print a benchmark test\n");
46    printf("\n -host           name for the host [default = mysql://localhost/pamelaprod]\n");    printf(" -auto | -AUTO     exclude from processing detector which are NOT in the acquisition [default]\n");
47    printf("\n -user           username for the DB [default = anonymous] \n");    printf(" -zerofill         if a detector is not in the acquisition the routine is called anyway \n");
48    printf("\n -psw            password for the DB [default = \"\"]\n");    printf("                   but all detector's data will be marked as bad\n");
49    printf("\n +all            call all detectors software [default]\n");    printf(" -tedious          exit with error if a detector is not in the acquisition and \n");
50    printf("\n -all            call nothing\n");    printf("                   it has not been excluded from processing\n");
51    printf("\n +detector       process detector; detector can be: TOF,TRK,CAL,TRG,ORB,S4,ND,AC,RUN\n");    printf(" -host             name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
52    printf("\n -detector       do not process detector (as above)\n");    printf(" -user             username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n");
53    printf("\nExamples: \n");    printf(" -psw              password for the DB connection [default = $PAM_DBPSW or \"\"]\n");
54    printf("\nStandard call: DarthVader -idRun 1085 \n");    printf(" -idRun ID_RUN     ID number (from the DB) of the run to be processed \n");
55    printf("\nProcess only RunInfo and Tracker (be verbose for tracker): DarthVader -idRun 1085 -all +RUN +TRK [ --verbose ] \n");    printf(" -processFile file output filename [default ID_RUN.Level2.root]\n");
56    printf("\nProcess all and be verbose for calorimeter: DarthVader -idRun 1085 +CAL [ --verbose ] \n\n");    printf(" +all | +ALL       call all detectors software [default]\n");
57      printf(" -all | -ALL       call nothing\n");
58      printf(" +detector         process detector; detector can be: TOF,TRK,CAL,TRG,ORB,S4,ND,AC,RUN\n");
59      printf(" -detector         do not process detector (as above)\n");
60      printf("                   detector options must be included in square parenthesis with spaces, for example:\n");
61      printf("                   +CAL [ --verbose -g ] +TRK [ -v --level1 ] \n");  
62      printf("\n Examples: \n");
63      printf(" Standard call:\n            DarthVader -idRun 1085 \n");
64      printf(" Process only RunInfo and Tracker (be verbose for tracker):\n            DarthVader -idRun 1085 -all +RUN +TRK [ --verbose ] \n");
65      printf(" Process all and be verbose for calorimeter:\n            DarthVader -idRun 1085 +CAL [ --verbose ] \n\n");
66  };  };
67  //  //
68  // Here the main  // Here the main
# Line 60  int main(int numinp, char *inps[]){ Line 71  int main(int numinp, char *inps[]){
71    //    //
72    // Variables booking    // Variables booking
73    //    //
74      //
75      // benchmarck variables
76      //
77      TStopwatch timer;
78      TStopwatch dvtimer;
79      dvtimer.Start(kTRUE);
80      UInt_t nevents = 0;
81      UInt_t nruns = 0;
82      Double_t runtime = 0.;
83      Double_t cruntime = 0.;
84      Double_t trktime = 0.;
85      Double_t ctrktime = 0.;
86      Double_t caltime = 0.;
87      Double_t ccaltime = 0.;
88      Double_t toftime = 0.;
89      Double_t ctoftime = 0.;
90      Double_t trgtime = 0.;
91      Double_t ctrgtime = 0.;
92      Double_t actime = 0.;
93      Double_t cactime = 0.;
94      Double_t s4time = 0.;
95      Double_t cs4time = 0.;
96      Double_t ndtime = 0.;
97      Double_t cndtime = 0.;
98      Double_t orbtime = 0.;
99      Double_t corbtime = 0.;
100      Double_t dvtime = 0.;
101      Double_t cdvtime = 0.;
102      //
103    TString message;    TString message;
104    int nul = 0;    int nul = 0;
105    Int_t error = 0;    Int_t error = 0;
# Line 73  int main(int numinp, char *inps[]){ Line 113  int main(int numinp, char *inps[]){
113    Int_t ACSGN = 0;    Int_t ACSGN = 0;
114    Int_t S4SGN = 0;    Int_t S4SGN = 0;
115    Int_t NDSGN = 0;    Int_t NDSGN = 0;
116      Int_t DVSGN = 0;
117    //    //
118      Bool_t autom = true;
119      Bool_t zerofill = false;
120      Bool_t tedious = false;
121      Bool_t remfile = false;
122    Bool_t debug = false;    Bool_t debug = false;
123    Bool_t beverbose = false;    Bool_t beverbose = true;
124    Bool_t givenid = false;    Bool_t givenid = false;
125      Bool_t bench = false;
126    Bool_t CAL = true;    Bool_t CAL = true;
127    Bool_t TRK = true;    Bool_t TRK = true;
128    Bool_t TRG = true;    Bool_t TRG = true;
# Line 85  int main(int numinp, char *inps[]){ Line 131  int main(int numinp, char *inps[]){
131    Bool_t ND = true;    Bool_t ND = true;
132    Bool_t AC = true;    Bool_t AC = true;
133    Bool_t ORB = true;    Bool_t ORB = true;
134    Bool_t RUN = true;    Bool_t RUN = true;  
135    //    //
136    Int_t calargc = 0;    Int_t calargc = 0;
137    char *calargv[50];    char *calargv[50];
# Line 108  int main(int numinp, char *inps[]){ Line 154  int main(int numinp, char *inps[]){
154    //    //
155    //    //
156    //    //
157    ULong64_t run = 0;    UInt_t run = 0;
158    //    //
159    TString filename;    TString filename;
160    TString outDir =  gSystem->WorkingDirectory();    TString outDir =  gSystem->WorkingDirectory();
# Line 118  int main(int numinp, char *inps[]){ Line 164  int main(int numinp, char *inps[]){
164    TString user = "anonymous";    TString user = "anonymous";
165    TString psw = "";    TString psw = "";
166    //    //
167      //
168      const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
169      const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
170      const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
171      if ( !pamdbhost ) pamdbhost = "";
172      if ( !pamdbuser ) pamdbuser = "";
173      if ( !pamdbpsw ) pamdbpsw = "";
174      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
175      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
176      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
177      //
178      //
179    TFile *processFile = 0;    TFile *processFile = 0;
180    //    //
181    // Checking input parameters    // Checking input parameters
# Line 126  int main(int numinp, char *inps[]){ Line 184  int main(int numinp, char *inps[]){
184    try {    try {
185      if ( numinp > 1 ){      if ( numinp > 1 ){
186        while ( i < numinp ){        while ( i < numinp ){
187            Bool_t found = false;
188          if ( !strcmp(inps[i],"--version") ){          if ( !strcmp(inps[i],"--version") ){
189            DarthVaderInfo(true);            DarthVaderInfo(true);
190            exit(0);            exit(0);
# Line 139  int main(int numinp, char *inps[]){ Line 198  int main(int numinp, char *inps[]){
198              usage();              usage();
199              throw -3;              throw -3;
200            };            };
201              i++;
202              found = true;
203            givenid = true;            givenid = true;
204            char *pEnd;              run = atoll(inps[i]);
           run = strtoull(inps[i+1],&pEnd,0);      
205          };          };
206          if ( !strcmp(inps[i],"-processFile") ) {          if ( !strcmp(inps[i],"-processFile") ) {
207            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
208              usage();              usage();
209              throw -3;              throw -3;
210            };            };
211            filename = (TString)inps[i+1];                    i++;
212              found = true;
213              filename = (TString)inps[i];  
214          };          };
215          if ( !strcmp(inps[i],"-outDir") ) {          if ( !strcmp(inps[i],"-outDir") ) {
216            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
217              usage();              usage();
218              throw -3;              throw -3;
219            };            };
220            outDir = (TString)inps[i+1];              i++;
221              found = true;
222              outDir = (TString)inps[i];    
223          };          };
224          if ( !strcmp(inps[i],"-host") ) {          if ( !strcmp(inps[i],"-host") ) {
225            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
226              usage();              usage();
227              throw -3;              throw -3;
228            };            };
229            host = (TString)inps[i+1];                i++;
230              found = true;
231              host = (TString)inps[i];      
232          };          };
233          if ( !strcmp(inps[i],"-user") ) {          if ( !strcmp(inps[i],"-user") ) {
234            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
235              usage();              usage();
236              throw -3;              throw -3;
237            };            };
238            user = (TString)inps[i+1];                i++;
239              found = true;
240              user = (TString)inps[i];      
241          };          };
242          if ( !strcmp(inps[i],"-psw") ) {          if ( !strcmp(inps[i],"-psw") ) {
243            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
244              usage();              usage();
245              throw -3;              throw -3;
246            };            };
247            psw = (TString)inps[i+1];                i++;
248              found = true;
249              psw = (TString)inps[i];      
250            };
251            if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ){
252              found = true;
253              beverbose = true;
254            };
255            if ( !strcmp(inps[i],"-c") || !strcmp(inps[i],"--clean")){
256              found = true;
257              remfile = true;
258            };
259            if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ){
260              found = true;
261              beverbose = false;
262            };
263            if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ){
264              debug = true;
265              found = true;
266            };
267            if ( !strcmp(inps[i],"-b") || !strcmp(inps[i],"--benchmark") ){
268              bench = true;
269              found = true;
270            };
271            if ( !strcmp(inps[i],"-auto") || !strcmp(inps[i],"-AUTO") ){
272              autom = true;
273              tedious = false;
274              zerofill = false;
275              found = true;
276            };
277            if ( !strcmp(inps[i],"-zerofill") ){
278              tedious = false;
279              autom = false;
280              zerofill = true;
281              found = true;
282            };
283            if ( !strcmp(inps[i],"-tedious") ){
284              tedious = true;
285              zerofill = false;
286              autom = false;
287              found = true;
288          };          };
         if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;  
         //  
         if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;  
289          //          //
290          if ( !strcmp(inps[i],"-CAL") ) {          if ( !strcmp(inps[i],"-CAL") ) {
291              found = true;
292            CAL = false;            CAL = false;
293          };          };
294          if ( !strcmp(inps[i],"-TRK") ) {          if ( !strcmp(inps[i],"-TRK") ) {
295              found = true;
296            TRK = false;            TRK = false;
297          };          };
298          if ( !strcmp(inps[i],"-TOF") ) {          if ( !strcmp(inps[i],"-TOF") ) {
299              found = true;
300            TOF = false;            TOF = false;
301          };          };
302          if ( !strcmp(inps[i],"-TRG") ) {          if ( !strcmp(inps[i],"-TRG") ) {
303              found = true;
304            TRG = false;            TRG = false;
305          };          };
306          if ( !strcmp(inps[i],"-S4") ) {          if ( !strcmp(inps[i],"-S4") ) {
307              found = true;
308            S4 = false;            S4 = false;
309          };          };
310          if ( !strcmp(inps[i],"-ND") ) {          if ( !strcmp(inps[i],"-ND") ) {
311              found = true;
312            ND = false;            ND = false;
313          };          };
314          if ( !strcmp(inps[i],"-AC") ) {          if ( !strcmp(inps[i],"-AC") ) {
315              found = true;
316            AC = false;            AC = false;
317          };          };
318          if ( !strcmp(inps[i],"-RUN") ) {          if ( !strcmp(inps[i],"-RUN") ) {
319              found = true;
320            RUN = false;            RUN = false;
321          };          };
322          if ( !strcmp(inps[i],"-ORB") ) {          if ( !strcmp(inps[i],"-ORB") ) {
323              found = true;
324            ORB = false;            ORB = false;
325          };          };
326          //          //
327          if ( !strcmp(inps[i],"-all") ) {          if ( !strcmp(inps[i],"-all") || !strcmp(inps[i],"-ALL") ) {
328            CAL = false;            CAL = false;
329            ORB = false;            ORB = false;
330            TRK = false;            TRK = false;
# Line 220  int main(int numinp, char *inps[]){ Line 334  int main(int numinp, char *inps[]){
334            ND = false;            ND = false;
335            AC = false;            AC = false;
336            RUN = false;            RUN = false;
337              found = true;
338          };          };
339          //          //
340          if ( !strcmp(inps[i],"+all") ) {          if ( !strcmp(inps[i],"+all") || !strcmp(inps[i],"+ALL") ) {
341            CAL = true;            CAL = true;
342            ORB = true;            ORB = true;
343            TRK = true;            TRK = true;
# Line 232  int main(int numinp, char *inps[]){ Line 347  int main(int numinp, char *inps[]){
347            ND = true;            ND = true;
348            AC = true;            AC = true;
349            RUN = true;            RUN = true;
350              found = true;
351          };          };
352          //          //
353          if ( !strcmp(inps[i],"+CAL") ) {          if ( !strcmp(inps[i],"+CAL") ) {
354              found = true;
355            CAL = true;            CAL = true;
356            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
357              if ( numinp < i+2 ){              if ( numinp < i+2 ){
# Line 255  int main(int numinp, char *inps[]){ Line 372  int main(int numinp, char *inps[]){
372            };            };
373          };          };
374          if ( !strcmp(inps[i],"+TRK") ) {          if ( !strcmp(inps[i],"+TRK") ) {
375              found = true;
376            TRK = true;            TRK = true;
377            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
378              if ( numinp-1 < i+2 ){              if ( numinp-1 < i+2 ){
# Line 275  int main(int numinp, char *inps[]){ Line 393  int main(int numinp, char *inps[]){
393            };            };
394          };          };
395          if ( !strcmp(inps[i],"+TOF") ) {          if ( !strcmp(inps[i],"+TOF") ) {
396              found = true;
397            TOF = true;            TOF = true;
398            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
399              i += 2;                    i += 2;      
# Line 291  int main(int numinp, char *inps[]){ Line 410  int main(int numinp, char *inps[]){
410            };            };
411          };          };
412          if ( !strcmp(inps[i],"+TRG") ) {          if ( !strcmp(inps[i],"+TRG") ) {
413              found = true;
414            TRG = true;            TRG = true;
415            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
416              i += 2;                    i += 2;      
# Line 307  int main(int numinp, char *inps[]){ Line 427  int main(int numinp, char *inps[]){
427            };            };
428          };          };
429          if ( !strcmp(inps[i],"+ORB") ) {          if ( !strcmp(inps[i],"+ORB") ) {
430              found = true;
431            ORB = true;            ORB = true;
432            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
433              i += 2;                    i += 2;      
# Line 323  int main(int numinp, char *inps[]){ Line 444  int main(int numinp, char *inps[]){
444            };            };
445          };          };
446          if ( !strcmp(inps[i],"+RUN") ) {          if ( !strcmp(inps[i],"+RUN") ) {
447              found = true;
448            RUN = true;            RUN = true;
449            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
450              i += 2;                    i += 2;      
# Line 339  int main(int numinp, char *inps[]){ Line 461  int main(int numinp, char *inps[]){
461            };            };
462          };          };
463          if ( !strcmp(inps[i],"+AC") ) {          if ( !strcmp(inps[i],"+AC") ) {
464              found = true;
465            AC = true;            AC = true;
466            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
467              i += 2;                    i += 2;      
# Line 355  int main(int numinp, char *inps[]){ Line 478  int main(int numinp, char *inps[]){
478            };            };
479          };          };
480          if ( !strcmp(inps[i],"+S4") ) {          if ( !strcmp(inps[i],"+S4") ) {
481              found = true;
482            S4 = true;            S4 = true;
483            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
484              i += 2;                    i += 2;      
# Line 371  int main(int numinp, char *inps[]){ Line 495  int main(int numinp, char *inps[]){
495            };            };
496          };          };
497          if ( !strcmp(inps[i],"+ND") ) {          if ( !strcmp(inps[i],"+ND") ) {
498              found = true;
499            ND = true;            ND = true;
500            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
501              i += 2;                    i += 2;      
# Line 387  int main(int numinp, char *inps[]){ Line 512  int main(int numinp, char *inps[]){
512            };            };
513          };          };
514          //          //
515            if ( !found && i > 0 ){
516              usage();
517              printf(" Unknown input number %i, that is \"%s\" \n",i,inps[i]);
518              throw -22;
519            };
520            //
521          i++;          i++;
522        };        };
523        //        //
# Line 409  int main(int numinp, char *inps[]){ Line 540  int main(int numinp, char *inps[]){
540      //      //
541      if ( !givenid ) throw -1;      if ( !givenid ) throw -1;
542      //      //
543      char *version = DarthVaderInfo(false);      TString version = DarthVaderInfo(false);
544      //      //
545      // Start:      // Start:
546      //      //
547      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());
548        if ( run )  printf("\n Processing run number %u \n\n",run);
549      //      //
550      // Connect to the DB      // Connect to the DB
551      //      //
# Line 422  int main(int numinp, char *inps[]){ Line 554  int main(int numinp, char *inps[]){
554      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
555      if( !dbc ) throw -2;          if( !dbc ) throw -2;    
556      //      //
557      bool connect = dbc->IsConnected();      Bool_t connect = dbc->IsConnected();
558      //      //
559      if( !connect ) throw -2;          if( !connect ) throw -2;    
560      //      //
561      if ( debug ) printf("...connected! \n\n");      if ( debug ) printf("...connected! \n\n");
562      //      //
563        if ( debug ) printf("\n DB INFORMATIONS:\n SQL: %s Version: %s Host %s Port %i \n\n",dbc->GetDBMS(),dbc->ServerInfo(),dbc->GetHost(),dbc->GetPort());
564        //
565        // Use UTC in the DB
566        //
567        stringstream myquery;
568        myquery.str("");
569        myquery << "SET time_zone='+0:00'";
570        dbc->Query(myquery.str().c_str());
571        //
572        //
573      // Create LEVEL2 filename and open it in update mode      // Create LEVEL2 filename and open it in update mode
574      //      //
575      if ( filename.IsNull() ){      if ( filename.IsNull() ){
576        stringstream strun;        stringstream strun;
577        strun.str("");        strun.str("");
578        strun << run;        strun << run;
579          filename += outDir;
580          filename += "/";
581        filename += strun.str();        filename += strun.str();
582        filename += ".Level2.root";        filename += ".Level2.root";
583      };      };
     filename = outDir + "/" + filename;  
584      processFile = new TFile(filename.Data(),"UPDATE");      processFile = new TFile(filename.Data(),"UPDATE");
585      if ( !processFile->IsOpen() ) throw -15;          if ( !processFile->IsOpen() ) throw -15;    
586      //      //
587        Long64_t maxsize = 10000000000LL;  
588        TTree::SetMaxTreeSize(maxsize);
589        //
590        //
591      // Run the core program, put any output error in the "error" variable      // Run the core program, put any output error in the "error" variable
592      //      //
593        if ( debug ) printf("\n\n Pre-processing:\n\n");
594        //
595        timer.Start(kTRUE);
596      if ( RUN ) {      if ( RUN ) {
597        printf(" Calling RunInfo... ");        if ( debug ) printf(" Retrieve, if the case, the RUN informations from the DB...\n");
598        RUNSGN = RunInfoCore(run,processFile,dbc,runargc,runargv);        printf(" RunInfo called\n");
599        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start RunInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
600          RUNSGN = RunInfoCore(run,processFile,dbc,version,runargc,runargv);
601          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end RunInfoCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
602          if ( debug ) printf(" ...done\n");
603        };
604        timer.Stop();
605        runtime = timer.RealTime();
606        cruntime = timer.CpuTime();
607        //
608        // From the Run Infos extract acq_var_info to determine if detectors are in the acquisition or not
609        //
610        if ( debug ) printf(" Checking if requested detectors are in the acquisition\n");
611        ItoRunInfo *runinfo = new ItoRunInfo(processFile);
612        Int_t sgnl = runinfo->Read(run);
613        if ( sgnl != 0 ) throw -17;
614        nevents = runinfo->GetEntries();
615        nruns = runinfo->GetNoRun();
616        if ( debug ) printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO);
617        if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ){
618          DVSGN += 1;
619          if ( tedious ) throw -30;
620          if ( autom ){
621            TRK = 0;
622            if ( debug ) printf(" TRK excluded from processing \n");
623          };
624          if ( zerofill && debug ) printf(" TRK is not in the acquisition! \n");
625      };      };
626        if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ){
627          DVSGN += 2;
628          if ( tedious ) throw -31;
629          if ( autom ){
630            TOF = 0;
631            if ( debug ) printf(" TOF excluded from processing \n");
632          };      
633          if ( zerofill && debug ) printf(" TOF is not in the acquisition! \n");
634        };
635        if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ){
636          DVSGN += 4;
637          if ( tedious ) throw -32;
638          if ( autom ){
639            CAL = 0;
640            if ( debug ) printf(" CAL excluded from processing \n");
641          };
642          if ( zerofill && debug ) printf(" CAL is not in the acquisition! \n");
643        };
644        if ( AC  && (!(runinfo->ACQ_VAR_INFO & (1 << 1)) || !(runinfo->ACQ_VAR_INFO & (1 << 2))) ){
645          DVSGN += 8;
646          if ( tedious ) throw -33;
647          if ( autom ){
648            AC = 0;
649            if ( debug ) printf(" AC excluded from processing \n");
650          };
651          if ( zerofill && debug ) printf(" AC is not in the acquisition! \n");
652        };
653        if ( S4  && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ){
654          DVSGN += 16;
655          if ( tedious ) throw -34;
656          if ( autom ){
657            S4 = 0;
658            if ( debug ) printf(" S4 excluded from processing \n");
659          };
660          if ( zerofill && debug ) printf(" S4 is not in the acquisition! \n");
661        };
662        if ( ND  && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ){
663          DVSGN += 32;
664          if ( tedious ) throw -35;
665          if ( autom ){
666            ND = 0;
667            if ( debug ) printf(" ND excluded from processing \n");
668          };
669          if ( zerofill && debug ) printf(" ND is not in the acquisition! \n");
670        };
671        //
672        if ( !DVSGN ){
673          if ( debug ) printf(" OK! Start processing detector's data. \n");
674        } else {
675          if ( debug ) printf(" WARNING! missing detector(s)! Start anyway processing detector's data. \n");
676        };
677        if ( debug ) printf("\n End pre-processing \n\n");
678        //
679        timer.Start(kTRUE);
680      if ( TRK ) {      if ( TRK ) {
681        printf(" Calling TrackerLevel2... ");        printf(" TrackerLevel2 called\n");                
682          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start TrkCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
683        TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv);        TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv);
684        printf("done\n");        gSystem->Unlink("TrackerFolder"); //patch
685          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end TrkCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
686      };      };
687        timer.Stop();
688        trktime = timer.RealTime();
689        ctrktime = timer.CpuTime();
690        //
691        timer.Start(kTRUE);
692      if ( TOF ) {      if ( TOF ) {
693        printf(" Calling ToFLevel2... ");        printf(" ToFLevel2 called\n");
694          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start ToFCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
695        TOFSGN = ToFCore(run,processFile,dbc,tofargc,tofargv);        TOFSGN = ToFCore(run,processFile,dbc,tofargc,tofargv);
696        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end ToFCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
697      };      };
698        timer.Stop();
699        toftime = timer.RealTime();
700        ctoftime = timer.CpuTime();
701        //
702        timer.Start(kTRUE);
703      if ( CAL ) {      if ( CAL ) {
704        printf(" Calling CalorimeterLevel2... ");        printf(" CalorimeterLevel2 called\n");
705          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start CaloCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
706        CALSGN = CaloCore(run,processFile,dbc,calargc,calargv);        CALSGN = CaloCore(run,processFile,dbc,calargc,calargv);
707        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end CaloCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
708      };      };
709        timer.Stop();
710        caltime = timer.RealTime();
711        ccaltime = timer.CpuTime();
712        //
713        timer.Start(kTRUE);
714      if ( TRG ) {      if ( TRG ) {
715        printf(" Calling TriggerLevel2... ");        printf(" TriggerLevel2 called\n");
716          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start TrigCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
717        TRGSGN = TrigCore(run,processFile,dbc,trgargc,trgargv);        TRGSGN = TrigCore(run,processFile,dbc,trgargc,trgargv);
718        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end TrigCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
719      };      };
720        timer.Stop();
721        trgtime = timer.RealTime();
722        ctrgtime = timer.CpuTime();
723        //
724        timer.Start(kTRUE);
725      if ( AC ) {      if ( AC ) {
726        printf(" Calling AnticounterLevel2... ");        printf(" AnticounterLevel2 called\n");
727          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start AcCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
728        ACSGN = AcCore(run,processFile,dbc,acargc,acargv);        ACSGN = AcCore(run,processFile,dbc,acargc,acargv);
729        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end AcCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
730      };      };
731        timer.Stop();
732        actime = timer.RealTime();
733        cactime = timer.CpuTime();
734        //
735        timer.Start(kTRUE);
736      if ( S4 ) {      if ( S4 ) {
737        printf(" Calling S4Level2 ... ");        printf(" S4Level2 called\n");
738          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start S4Core STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
739        S4SGN = S4Core(run,processFile,dbc,s4argc,s4argv);        S4SGN = S4Core(run,processFile,dbc,s4argc,s4argv);
740        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end S4Core STDOUT   |<<<<<<<<<<<<<<<<<<<\n");
741      };      };
742        timer.Stop();
743        s4time = timer.RealTime();
744        cs4time = timer.CpuTime();
745        //
746        timer.Start(kTRUE);
747      if ( ND ) {      if ( ND ) {
748        printf(" Calling NDLevel2... ");        printf(" NDLevel2 called\n");
749          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start NDCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
750        NDSGN = NDCore(run,processFile,dbc,ndargc,ndargv);        NDSGN = NDCore(run,processFile,dbc,ndargc,ndargv);
751        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end NDCore STDOUT   |<<<<<<<<<<<<<<<<<<<\n");
752      };      };
753        timer.Stop();
754        ndtime = timer.RealTime();
755        cndtime = timer.CpuTime();
756        //
757        timer.Start(kTRUE);
758      if ( ORB ) {      if ( ORB ) {
759        printf(" Calling OrbitalInfo... ");        printf(" OrbitalInfo called\n");
760          if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>| start OrbitalInfoCore STDOUT  |<<<<<<<<<<<<<<<<<<<\n");
761        ORBSGN = OrbitalInfoCore(run,processFile,dbc,orbargc,orbargv);        ORBSGN = OrbitalInfoCore(run,processFile,dbc,orbargc,orbargv);
762        printf("done\n");        if ( debug ) printf("                      >>>>>>>>>>>>>>>>>>>|  end OrbitalInfoCore STDOUT   |<<<<<<<<<<<<<<<<<<<\n");
763      };          };    
764        timer.Stop();
765        orbtime = timer.RealTime();
766        corbtime = timer.CpuTime();
767      //      //
768    } catch(Int_t signal) {        } catch(Int_t signal) {    
769      error = signal;      error = signal;
# Line 502  int main(int numinp, char *inps[]){ Line 778  int main(int numinp, char *inps[]){
778      case -8:   message += " No Header branch in LEVEL0 Physics tree"; break;      case -8:   message += " No Header branch in LEVEL0 Physics tree"; break;
779      case -9:   message += " No Registry branch in LEVEL0 Physics tree"; break;      case -9:   message += " No Registry branch in LEVEL0 Physics tree"; break;
780      case -11:  message += " LEVEL0 Physics tree is empty"; break;      case -11:  message += " LEVEL0 Physics tree is empty"; break;
781      case -12:  message += " LEVEL2 output directory does not exists"; break;      case -12:  message += " Too few entries in the tree"; break;
782      case -13:  message += " Cannot create processFolder directory"; break;      case -13:  message += " Cannot create processFolder directory"; break;
783      case -14:  message += " Error querying the DB"; break;      case -14:  message += " Error querying the DB"; break;
784      case -15:  message += " Cannot open file for writing"; break;      case -15:  message += " Cannot open file for writing"; break;
785        case -17:  message += " Error during pre-processing"; break;
786        case -22:  message += " Unknown input or wrong syntax in input paramters!"; break;
787        case -30:  message += " No TRK in the acquisition"; break;
788        case -31:  message += " No TOF in the acquisition"; break;
789        case -32:  message += " No CAL in the acquisition"; break;
790        case -33:  message += " No AC in the acquisition"; break;
791        case -34:  message += " No S4 in the acquisition"; break;
792        case -35:  message += " No ND in the acquisition"; break;
793        //        //
794      case -50:  message += " GLTABLES - No entries matching GL_RUN query"; break;      case -50:  message += " GLTABLES - No entries matching GL_RUN query"; break;
795      case -51:  message += " GLTABLES - No entries matching GL_ROOT query"; break;      case -51:  message += " GLTABLES - No entries matching GL_ROOT query"; break;
# Line 528  int main(int numinp, char *inps[]){ Line 812  int main(int numinp, char *inps[]){
812      case -111: message += " CALORIMETERLEVEL2 -  Corrupted calibration"; break;      case -111: message += " CALORIMETERLEVEL2 -  Corrupted calibration"; break;
813      case -112: message += " CALORIMETERLEVEL2 -  No physics event related to registry entry in Level0 file"; break;      case -112: message += " CALORIMETERLEVEL2 -  No physics event related to registry entry in Level0 file"; break;
814      case -113: message += " CALORIMETERLEVEL2 -  No tracker event related to registry entry in Level2 file"; break;      case -113: message += " CALORIMETERLEVEL2 -  No tracker event related to registry entry in Level2 file"; break;
815        case -114: message += " CALORIMETERLEVEL2 -  Help called"; break;
816        case -115: message += " CALORIMETERLEVEL2 -  No Calorimeter bad strip offline mask file"; break;
817        case -116: message += " CALORIMETERLEVEL2 -  DB connection problems"; break;
818        case -117: message += " CALORIMETERLEVEL2 -  Cannot reprocess file with Level1 data without calling Level1 routine"; break;
819        case -118: message += " CALORIMETERLEVEL2 -  Cannot reprocess file without Level1 data calling Level1 routine"; break;
820        //        //
821      case -200: message += " TRACKERLEVEL2 - LEVEL1 framework unknown (HBOOK/ROOT)"; break;      case -200: message += " TRACKERLEVEL2 - LEVEL1 framework unknown (HBOOK/ROOT)"; break;
822      case -201: message += " TRACKERLEVEL2 - LEVEL2 framework unknown (HBOOK/ROOT)"; break;      case -201: message += " TRACKERLEVEL2 - LEVEL2 framework unknown (HBOOK/ROOT)"; break;
# Line 550  int main(int numinp, char *inps[]){ Line 839  int main(int numinp, char *inps[]){
839      case -302: message += " TOFLEVEL2 - No tracker tree in Level2 file"; break;      case -302: message += " TOFLEVEL2 - No tracker tree in Level2 file"; break;
840      case -303: message += " TOFLEVEL2 - No Tof branch in Level0 file"; break;      case -303: message += " TOFLEVEL2 - No Tof branch in Level0 file"; break;
841      case -313: message += " TOFLEVEL2 - No more tracker events in Level2 file"; break;      case -313: message += " TOFLEVEL2 - No more tracker events in Level2 file"; break;
842        case -314: message += " TOFLEVEL2 - DB connection problems"; break;
843        //        //
844      case -401: message += " TRIGGERLEVEL2 - Cannot open file for writing"; break;      case -401: message += " TRIGGERLEVEL2 - Cannot open file for writing"; break;
845      case -402: message += " TRIGGERLEVEL2 - No Trigger branch in Level0 tree"; break;      case -402: message += " TRIGGERLEVEL2 - No Trigger branch in Level0 tree"; break;
846        case -403: message += " TRIGGERLEVEL2 - DB connection problems"; break;
847        //        //
848      case -500: message += " S4LEVEL2 - No level2 file"; break;      case -500: message += " S4LEVEL2 - No level2 file"; break;
849      case -501: message += " S4LEVEL2 - Cannot open file for writing"; break;      case -501: message += " S4LEVEL2 - Cannot open file for writing"; break;
850      case -502: message += " S4LEVEL2 - No result from GL_S4_CALIB"; break;      case -502: message += " S4LEVEL2 - No result from GL_S4_CALIB"; break;
851      case -503: message += " S4LEVEL2 - No S4 branch in Level0 tree"; break;      case -503: message += " S4LEVEL2 - No S4 branch in Level0 tree"; break;
852        case -504: message += " S4LEVEL2 - DB connection problems"; break;
853        //        //
854      case -600: message += " NDLEVEL2 - No level2 file"; break;      case -600: message += " NDLEVEL2 - No level2 file"; break;
855      case -601: message += " NDLEVEL2 - Cannot open file for writing"; break;      case -601: message += " NDLEVEL2 - Cannot open file for writing"; break;
856      case -603: message += " NDLEVEL2 - No S4Level2 branch in Level0 tree"; break;      case -603: message += " NDLEVEL2 - No S4Level2 branch in Level0 tree"; break;
857        case -604: message += " NDLEVEL2 - DB connection problems"; break;
858        //        //
859      case -701: message += " NDLEVEL2 - Cannot open file for writing"; break;      case -701: message += " ACLEVEL2 - Cannot open file for writing"; break;
860      case -704: message += " NDLEVEL2 - No Anticounter branch in Level0 tree"; break;      case -704: message += " ACLEVEL2 - No Anticounter branch in Level0 tree"; break;
861        case -705: message += " ACLEVEL2 - DB connection problems"; break;
862        //        //
863      case -800: message += " RUNINFO - No such run in the RunInfo list"; break;      case -800: message += " RUNINFO - No such run in the RunInfo list"; break;
864      case -801: message += " RUNINFO - No RunInfo tree in Level2 file"; break;      case -801: message += " RUNINFO - No RunInfo tree in Level2 file"; break;
865      case -802: message += " RUNINFO - Cannot open file for writing"; break;      case -802: message += " RUNINFO - Cannot open file for writing"; break;
866      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;
867      case -804: message += " RUNINFO - Unknown detector"; break;      case -804: message += " RUNINFO - Unknown detector"; break;
868        //      case -805: message += " RUNINFO - Reprocessing data but no RunInfo tree in Level2 file"; break;
869        case -806: message += " RUNINFO - Can not handle more than 500 runs"; break;
870        case -807: message += " RUNINFO - DB connection problems"; break;
871         //
872      default: message += "Unidentified error or warning"; break;      default: message += "Unidentified error or warning"; break;
873      };      };
874      printf("\n");      printf("\n");
875      if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl;      if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl;
876    }    }
877    //  switch(RUNSGN){    //
878    //  };    // Warnings from XCore routines and from DV:
879      //
880      if ( debug && DVSGN ) printf(" DVSGN = %i \n",DVSGN);
881      if ( DVSGN ) printf("\n WARNING DarthVader: \n");
882      if ( DVSGN & (1 << 0) ) printf(" - No tracker in the acquisition\n");
883      if ( DVSGN & (1 << 1) ) printf(" - No ToF in the acquisition\n");
884      if ( DVSGN & (1 << 2) ) printf(" - No calorimeter in the acquisition\n");
885      if ( DVSGN & (1 << 3) ) printf(" - No anticounters in the acquisition\n");
886      if ( DVSGN & (1 << 4) ) printf(" - No S4 in the acquisition\n");
887      if ( DVSGN & (1 << 5) ) printf(" - No neutron detector in the acquisition\n");
888      //
889      // CaloCore:
890      //
891    switch(CALSGN){    switch(CALSGN){
892    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");
893    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");
894    };    };
895    //    //
896      // no other at the moment
897      //
898      //
899    // Close the DB connection    // Close the DB connection
900    //    //
901    if ( dbc ){    if ( dbc ){
# Line 596  int main(int numinp, char *inps[]){ Line 908  int main(int numinp, char *inps[]){
908      processFile->Close();      processFile->Close();
909    };    };
910    //    //
911      // print benchmark results (if the case)
912      //
913      dvtimer.Stop();
914      dvtime = dvtimer.RealTime();
915      cdvtime = dvtimer.CpuTime();
916      if ( bench ){
917        Float_t runrt = 0.;
918        Float_t trkrt = 0.;
919        Float_t calrt = 0.;
920        Float_t tofrt = 0.;
921        Float_t trgrt = 0.;
922        Float_t acrt = 0.;
923        Float_t s4rt = 0.;
924        Float_t ndrt = 0.;
925        Float_t orbrt = 0.;
926        Float_t dvrt = nevents/dvtime;
927        if ( RUN ) runrt = nruns/runtime;
928        if ( TRK ) trkrt = nevents/trktime;
929        if ( CAL ) calrt = nevents/caltime;
930        if ( TOF ) tofrt = nevents/toftime;
931        if ( TRG ) trgrt = nevents/trgtime;
932        if ( AC ) acrt = nevents/actime;
933        if ( S4 ) s4rt = nevents/s4time;
934        if ( ND ) ndrt = nevents/ndtime;
935        if ( ORB ) orbrt = nevents/orbtime;
936        //
937        printf("\n\n################################################################################\n");
938        printf("#              Benchmark results: nevents = %10u runs = %3u              #\n",nevents,nruns);
939        printf("################################################################################\n");
940        printf("# Detector # Core routine called #     Real Time   #   CPU time   #  Events/s  #\n");
941        printf("################################################################################\n");
942        printf("# RUN      #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",RUN,fabs(runtime),fabs(cruntime),runrt);
943        printf("# TRK      #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",TRK,fabs(trktime),fabs(ctrktime),trkrt);
944        printf("# CAL      #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",CAL,fabs(caltime),fabs(ccaltime),calrt);
945        printf("# TOF      #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",TOF,fabs(toftime),fabs(ctoftime),tofrt);
946        printf("# TRG      #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",TRG,fabs(trgtime),fabs(ctrgtime),trgrt);
947        printf("# AC       #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",AC,fabs(actime),fabs(cactime),acrt);
948        printf("# S4       #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",S4,fabs(s4time),fabs(cs4time),s4rt);
949        printf("# ND       #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",ND,fabs(ndtime),fabs(cndtime),ndrt);
950        printf("# ORB      #         %i           #      %8.2f   #    %8.2f  #  %8.2f  #\n",ORB,fabs(orbtime),fabs(corbtime),orbrt);
951        printf("################################################################################\n");
952        printf("# Total    #                     #      %8.2f   #    %8.2f  #  %8.2f  #\n",fabs(dvtime),fabs(cdvtime),dvrt);
953        printf("################################################################################\n");
954      };
955      //
956      //
957    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);
958    printf("\n");    //
959      //
960      //
961      if ( remfile && error < 0 ){
962        printf(" -c or --clean option used, deleting file %s \n\n",filename.Data());
963        gSystem->Unlink(filename.Data());
964      };
965      //
966      printf("\n Finished, exiting...\n\n");
967    //    //
968    // Close redirection if the case.    // Close redirection if the case.
969    //    //

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.23