/[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.5 by mocchiut, Fri Jun 30 13:03:32 2006 UTC revision 1.13 by mocchiut, Tue Sep 12 15:27:38 2006 UTC
# Line 35  using namespace std; Line 35  using namespace std;
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 -host           name for the host [default = mysql://localhost/pamelaprod]\n");    printf("\n -host           name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
46    printf("\n -user           username for the DB [default = anonymous] \n");    printf("\n -user           username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n");
47    printf("\n -psw            password for the DB [default = \"\"]\n");    printf("\n -psw            password for the DB [default = $PAM_DBPSW or \"\"]\n");
48    printf("\n +all            call all detectors software [default]\n");    printf("\n +all | +ALL     call all detectors software [default]\n");
49    printf("\n -all            call nothing\n");    printf("\n -all | -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");
# Line 73  int main(int numinp, char *inps[]){ Line 77  int main(int numinp, char *inps[]){
77    Int_t ACSGN = 0;    Int_t ACSGN = 0;
78    Int_t S4SGN = 0;    Int_t S4SGN = 0;
79    Int_t NDSGN = 0;    Int_t NDSGN = 0;
80      Int_t DVSGN = 0;
81    //    //
82    Bool_t debug = false;    Bool_t debug = false;
83    Bool_t beverbose = false;    Bool_t beverbose = true;
84    Bool_t givenid = false;    Bool_t givenid = false;
85    Bool_t CAL = true;    Bool_t CAL = true;
86    Bool_t TRK = true;    Bool_t TRK = true;
# Line 108  int main(int numinp, char *inps[]){ Line 113  int main(int numinp, char *inps[]){
113    //    //
114    //    //
115    //    //
116    ULong64_t run = 0;    UInt_t run = 0;
117    //    //
118    TString filename;    TString filename;
119    TString outDir =  gSystem->WorkingDirectory();    TString outDir =  gSystem->WorkingDirectory();
# Line 118  int main(int numinp, char *inps[]){ Line 123  int main(int numinp, char *inps[]){
123    TString user = "anonymous";    TString user = "anonymous";
124    TString psw = "";    TString psw = "";
125    //    //
126      //
127      const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
128      const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
129      const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
130      if ( !pamdbhost ) pamdbhost = "";
131      if ( !pamdbuser ) pamdbuser = "";
132      if ( !pamdbpsw ) pamdbpsw = "";
133      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
134      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
135      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
136      //
137      //
138    TFile *processFile = 0;    TFile *processFile = 0;
139    //    //
140    // Checking input parameters    // Checking input parameters
# Line 126  int main(int numinp, char *inps[]){ Line 143  int main(int numinp, char *inps[]){
143    try {    try {
144      if ( numinp > 1 ){      if ( numinp > 1 ){
145        while ( i < numinp ){        while ( i < numinp ){
146            Bool_t found = false;
147          if ( !strcmp(inps[i],"--version") ){          if ( !strcmp(inps[i],"--version") ){
148            DarthVaderInfo(true);            DarthVaderInfo(true);
149            exit(0);            exit(0);
# Line 139  int main(int numinp, char *inps[]){ Line 157  int main(int numinp, char *inps[]){
157              usage();              usage();
158              throw -3;              throw -3;
159            };            };
160              i++;
161              found = true;
162            givenid = true;            givenid = true;
163            char *pEnd;              run = atoll(inps[i]);
           run = strtoull(inps[i+1],&pEnd,0);      
164          };          };
165          if ( !strcmp(inps[i],"-processFile") ) {          if ( !strcmp(inps[i],"-processFile") ) {
166            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
167              usage();              usage();
168              throw -3;              throw -3;
169            };            };
170            filename = (TString)inps[i+1];                    i++;
171              found = true;
172              filename = (TString)inps[i];  
173          };          };
174          if ( !strcmp(inps[i],"-outDir") ) {          if ( !strcmp(inps[i],"-outDir") ) {
175            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
176              usage();              usage();
177              throw -3;              throw -3;
178            };            };
179            outDir = (TString)inps[i+1];              i++;
180              found = true;
181              outDir = (TString)inps[i];    
182          };          };
183          if ( !strcmp(inps[i],"-host") ) {          if ( !strcmp(inps[i],"-host") ) {
184            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
185              usage();              usage();
186              throw -3;              throw -3;
187            };            };
188            host = (TString)inps[i+1];                i++;
189              found = true;
190              host = (TString)inps[i];      
191          };          };
192          if ( !strcmp(inps[i],"-user") ) {          if ( !strcmp(inps[i],"-user") ) {
193            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
194              usage();              usage();
195              throw -3;              throw -3;
196            };            };
197            user = (TString)inps[i+1];                i++;
198              found = true;
199              user = (TString)inps[i];      
200          };          };
201          if ( !strcmp(inps[i],"-psw") ) {          if ( !strcmp(inps[i],"-psw") ) {
202            if ( numinp-1 < i+1 ){            if ( numinp-1 < i+1 ){
203              usage();              usage();
204              throw -3;              throw -3;
205            };            };
206            psw = (TString)inps[i+1];                i++;
207              found = true;
208              psw = (TString)inps[i];      
209            };
210            if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ){
211              found = true;
212              beverbose = true;
213            };
214            if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ){
215              found = true;
216              beverbose = false;
217          };          };
         if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;  
218          //          //
219          if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;          if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ){
220              debug = true;
221              found = true;
222            };
223          //          //
224          if ( !strcmp(inps[i],"-CAL") ) {          if ( !strcmp(inps[i],"-CAL") ) {
225              found = true;
226            CAL = false;            CAL = false;
227          };          };
228          if ( !strcmp(inps[i],"-TRK") ) {          if ( !strcmp(inps[i],"-TRK") ) {
229              found = true;
230            TRK = false;            TRK = false;
231          };          };
232          if ( !strcmp(inps[i],"-TOF") ) {          if ( !strcmp(inps[i],"-TOF") ) {
233              found = true;
234            TOF = false;            TOF = false;
235          };          };
236          if ( !strcmp(inps[i],"-TRG") ) {          if ( !strcmp(inps[i],"-TRG") ) {
237              found = true;
238            TRG = false;            TRG = false;
239          };          };
240          if ( !strcmp(inps[i],"-S4") ) {          if ( !strcmp(inps[i],"-S4") ) {
241              found = true;
242            S4 = false;            S4 = false;
243          };          };
244          if ( !strcmp(inps[i],"-ND") ) {          if ( !strcmp(inps[i],"-ND") ) {
245              found = true;
246            ND = false;            ND = false;
247          };          };
248          if ( !strcmp(inps[i],"-AC") ) {          if ( !strcmp(inps[i],"-AC") ) {
249              found = true;
250            AC = false;            AC = false;
251          };          };
252          if ( !strcmp(inps[i],"-RUN") ) {          if ( !strcmp(inps[i],"-RUN") ) {
253              found = true;
254            RUN = false;            RUN = false;
255          };          };
256          if ( !strcmp(inps[i],"-ORB") ) {          if ( !strcmp(inps[i],"-ORB") ) {
257              found = true;
258            ORB = false;            ORB = false;
259          };          };
260          //          //
261          if ( !strcmp(inps[i],"-all") ) {          if ( !strcmp(inps[i],"-all") || !strcmp(inps[i],"-ALL") ) {
262            CAL = false;            CAL = false;
263            ORB = false;            ORB = false;
264            TRK = false;            TRK = false;
# Line 220  int main(int numinp, char *inps[]){ Line 268  int main(int numinp, char *inps[]){
268            ND = false;            ND = false;
269            AC = false;            AC = false;
270            RUN = false;            RUN = false;
271              found = true;
272          };          };
273          //          //
274          if ( !strcmp(inps[i],"+all") ) {          if ( !strcmp(inps[i],"+all") || !strcmp(inps[i],"+ALL") ) {
275            CAL = true;            CAL = true;
276            ORB = true;            ORB = true;
277            TRK = true;            TRK = true;
# Line 232  int main(int numinp, char *inps[]){ Line 281  int main(int numinp, char *inps[]){
281            ND = true;            ND = true;
282            AC = true;            AC = true;
283            RUN = true;            RUN = true;
284              found = true;
285          };          };
286          //          //
287          if ( !strcmp(inps[i],"+CAL") ) {          if ( !strcmp(inps[i],"+CAL") ) {
288              found = true;
289            CAL = true;            CAL = true;
290            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
291              if ( numinp < i+2 ){              if ( numinp < i+2 ){
# Line 255  int main(int numinp, char *inps[]){ Line 306  int main(int numinp, char *inps[]){
306            };            };
307          };          };
308          if ( !strcmp(inps[i],"+TRK") ) {          if ( !strcmp(inps[i],"+TRK") ) {
309              found = true;
310            TRK = true;            TRK = true;
311            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
312              if ( numinp-1 < i+2 ){              if ( numinp-1 < i+2 ){
# Line 275  int main(int numinp, char *inps[]){ Line 327  int main(int numinp, char *inps[]){
327            };            };
328          };          };
329          if ( !strcmp(inps[i],"+TOF") ) {          if ( !strcmp(inps[i],"+TOF") ) {
330              found = true;
331            TOF = true;            TOF = true;
332            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
333              i += 2;                    i += 2;      
# Line 291  int main(int numinp, char *inps[]){ Line 344  int main(int numinp, char *inps[]){
344            };            };
345          };          };
346          if ( !strcmp(inps[i],"+TRG") ) {          if ( !strcmp(inps[i],"+TRG") ) {
347              found = true;
348            TRG = true;            TRG = true;
349            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
350              i += 2;                    i += 2;      
# Line 307  int main(int numinp, char *inps[]){ Line 361  int main(int numinp, char *inps[]){
361            };            };
362          };          };
363          if ( !strcmp(inps[i],"+ORB") ) {          if ( !strcmp(inps[i],"+ORB") ) {
364              found = true;
365            ORB = true;            ORB = true;
366            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
367              i += 2;                    i += 2;      
# Line 323  int main(int numinp, char *inps[]){ Line 378  int main(int numinp, char *inps[]){
378            };            };
379          };          };
380          if ( !strcmp(inps[i],"+RUN") ) {          if ( !strcmp(inps[i],"+RUN") ) {
381              found = true;
382            RUN = true;            RUN = true;
383            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
384              i += 2;                    i += 2;      
# Line 339  int main(int numinp, char *inps[]){ Line 395  int main(int numinp, char *inps[]){
395            };            };
396          };          };
397          if ( !strcmp(inps[i],"+AC") ) {          if ( !strcmp(inps[i],"+AC") ) {
398              found = true;
399            AC = true;            AC = true;
400            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
401              i += 2;                    i += 2;      
# Line 355  int main(int numinp, char *inps[]){ Line 412  int main(int numinp, char *inps[]){
412            };            };
413          };          };
414          if ( !strcmp(inps[i],"+S4") ) {          if ( !strcmp(inps[i],"+S4") ) {
415              found = true;
416            S4 = true;            S4 = true;
417            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
418              i += 2;                    i += 2;      
# Line 371  int main(int numinp, char *inps[]){ Line 429  int main(int numinp, char *inps[]){
429            };            };
430          };          };
431          if ( !strcmp(inps[i],"+ND") ) {          if ( !strcmp(inps[i],"+ND") ) {
432              found = true;
433            ND = true;            ND = true;
434            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){            if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
435              i += 2;                    i += 2;      
# Line 387  int main(int numinp, char *inps[]){ Line 446  int main(int numinp, char *inps[]){
446            };            };
447          };          };
448          //          //
449            if ( !found && i > 0 ){
450              usage();
451              printf(" Unknown input number %i, that is \"%s\" \n",i,inps[i]);
452              throw -22;
453            };
454            //
455          i++;          i++;
456        };        };
457        //        //
# Line 457  int main(int numinp, char *inps[]){ Line 522  int main(int numinp, char *inps[]){
522      ItoRunInfo *runinfo = new ItoRunInfo(processFile);      ItoRunInfo *runinfo = new ItoRunInfo(processFile);
523      runinfo->Read(run);      runinfo->Read(run);
524      printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO);      printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO);
525      if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ) throw -16;      if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ) DVSGN = 16;
526      if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ) throw -17;      if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ) DVSGN = 17;
527      if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ) throw -18;      if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ) DVSGN = 18;
528      if ( AC  && !(runinfo->ACQ_VAR_INFO & (1 << 1)) && !(runinfo->ACQ_VAR_INFO & (1 << 2)) ) throw -19;      if ( AC  && !(runinfo->ACQ_VAR_INFO & (1 << 1)) && !(runinfo->ACQ_VAR_INFO & (1 << 2)) ) DVSGN = 19;
529      if ( S4  && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ) throw -20;      if ( S4  && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ) DVSGN = 20;
530      if ( ND  && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ) throw -21;      if ( ND  && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ) DVSGN = 21;
531      printf(" OK! start processing detector's data. \n");      printf(" OK! start processing detector's data. \n");
532      //      //
533      if ( TRK ) {      if ( TRK ) {
534        printf(" Calling TrackerLevel2... ");        printf(" Calling TrackerLevel2... ");
535        TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv);        TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv);
536          gSystem->Unlink("TrackerFolder"); //patch
537        printf("done\n");        printf("done\n");
538      };      };
539      if ( TOF ) {      if ( TOF ) {
# Line 519  int main(int numinp, char *inps[]){ Line 585  int main(int numinp, char *inps[]){
585      case -8:   message += " No Header branch in LEVEL0 Physics tree"; break;      case -8:   message += " No Header branch in LEVEL0 Physics tree"; break;
586      case -9:   message += " No Registry branch in LEVEL0 Physics tree"; break;      case -9:   message += " No Registry branch in LEVEL0 Physics tree"; break;
587      case -11:  message += " LEVEL0 Physics tree is empty"; break;      case -11:  message += " LEVEL0 Physics tree is empty"; break;
588      case -12:  message += " Too few entries in the registry tree"; break;      case -12:  message += " Too few entries in the tree"; break;
589      case -13:  message += " Cannot create processFolder directory"; break;      case -13:  message += " Cannot create processFolder directory"; break;
590      case -14:  message += " Error querying the DB"; break;      case -14:  message += " Error querying the DB"; break;
591      case -15:  message += " Cannot open file for writing"; break;      case -15:  message += " Cannot open file for writing"; break;
592      case -16:  message += " No tracker in the acquisition (use -TRK to process anyway)"; break;      case -22:  message += " Unknown input or wrong syntax in input paramters!"; break;
     case -17:  message += " No ToF in the acquisition (use -TOF to process anyway)"; break;  
     case -18:  message += " No calorimeter in the acquisition (use -CAL to process anyway)"; break;  
     case -19:  message += " No anticounters in the acquisition (use -AC to process anyway)"; break;  
     case -20:  message += " No S4 in the acquisition (use -S4 to process anyway)"; break;  
     case -21:  message += " No neutron detector in the acquisition (use -ND to process anyway)"; break;  
593        //        //
594      case -50:  message += " GLTABLES - No entries matching GL_RUN query"; break;      case -50:  message += " GLTABLES - No entries matching GL_RUN query"; break;
595      case -51:  message += " GLTABLES - No entries matching GL_ROOT query"; break;      case -51:  message += " GLTABLES - No entries matching GL_ROOT query"; break;
# Line 595  int main(int numinp, char *inps[]){ Line 656  int main(int numinp, char *inps[]){
656      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;
657      case -804: message += " RUNINFO - Unknown detector"; break;      case -804: message += " RUNINFO - Unknown detector"; break;
658      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;
659        case -806: message += " RUNINFO - Can not handle more than 500 runs"; break;
660        //        //
661      default: message += "Unidentified error or warning"; break;      default: message += "Unidentified error or warning"; break;
662      };      };
663      printf("\n");      printf("\n");
664      if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl;      if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl;
665    }    }
666      //
667      switch(DVSGN){ // change message with printf!!
668      case 16:  printf(" No tracker in the acquisition\n");
669      case 17:  printf(" No ToF in the acquisition\n");
670      case 18:  printf(" No calorimeter in the acquisition\n");
671      case 19:  printf(" No anticounters in the acquisition\n");
672      case 20:  printf(" No S4 in the acquisition\n");
673      case 21:  printf(" No neutron detector in the acquisition\n");
674      };
675      //
676    //  switch(RUNSGN){    //  switch(RUNSGN){
677    //  };    //  };
678    switch(CALSGN){    switch(CALSGN){
679    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");
680    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");
681    };    };
682    //    //
683    // Close the DB connection    // Close the DB connection
# Line 622  int main(int numinp, char *inps[]){ Line 694  int main(int numinp, char *inps[]){
694    //    //
695    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);
696    printf("\n");    printf("\n");
697      printf("Finished, exiting...\n");
698      printf("\n");
699    //    //
700    // Close redirection if the case.    // Close redirection if the case.
701    //    //

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23