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

Annotation of /DarthVader/src/DarthVader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (hide annotations) (download)
Sat Jan 27 06:22:24 2007 UTC (17 years, 10 months ago) by mocchiut
Branch: MAIN
Changes since 1.25: +22 -0 lines
Added DB reconnection routine called in between detector software

1 mocchiut 1.1 //
2     // C/C++ headers
3     //
4     #include <iostream>
5     #include <sstream>
6     //
7     // ROOT headers
8     //
9     #include <TString.h>
10     #include <TSQLServer.h>
11     #include <TFile.h>
12     #include <TSystem.h>
13 mocchiut 1.19 #include <TStopwatch.h>
14 mocchiut 1.1 //
15     // Detector's package headers
16     //
17     #include <RunInfoCore.h>
18     #include <TrkCore.h>
19     #include <TrigCore.h>
20     #include <ToFCore.h>
21     #include <CaloCore.h>
22     #include <AcCore.h>
23     #include <S4Core.h>
24     #include <NDCore.h>
25     #include <OrbitalInfoCore.h>
26 mocchiut 1.4 #include <RunInfo.h>
27 mocchiut 1.1 //
28     using namespace std;
29     //
30     //
31     //
32     #include <DarthVaderVerl2.h>
33     //
34     // Usage subroutine
35     //
36     void usage(){
37     printf("\nUsage:\n");
38 mocchiut 1.19 printf("\n DarthVader [ options ] -idRun ID_RUN [+-all] [+-detector [ detector options ] ] \n");
39 mocchiut 1.22 printf("\n Options are: \n\n");
40     printf(" --version print informations about compilation and exit\n");
41     printf(" -h | --help print this help and exit \n");
42     printf(" -v | --verbose be verbose [default]\n");
43     printf(" -s | --silent print nothing on STDOUT\n");
44     printf(" -c | --clean remove file if exiting with errors\n");
45     printf(" -b | --benchmark perform and print a benchmark test\n");
46     printf(" -auto | -AUTO exclude from processing detector which are NOT in the acquisition [default]\n");
47     printf(" -zerofill if a detector is not in the acquisition the routine is called anyway \n");
48     printf(" but all detector's data will be marked as bad\n");
49     printf(" -tedious exit with error if a detector is not in the acquisition and \n");
50     printf(" it has not been excluded from processing\n");
51     printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
52     printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n");
53     printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n");
54     printf(" -idRun ID_RUN ID number (from the DB) of the run to be processed \n");
55     printf(" -processFile file output filename [default ID_RUN.Level2.root]\n");
56     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 mocchiut 1.1 };
67 mocchiut 1.26
68     Bool_t CheckDBC(TSQLServer *dbc, TString host, TString user, TString psw){
69     //
70     Bool_t connect = dbc->IsConnected();
71     //
72     if( !dbc || !connect ){
73     dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
74     };
75     //
76     connect = dbc->IsConnected();
77     //
78     return(connect);
79     //
80     };
81 mocchiut 1.1 //
82     // Here the main
83     //
84     int main(int numinp, char *inps[]){
85     //
86     // Variables booking
87     //
88 mocchiut 1.19 //
89     // benchmarck variables
90     //
91     TStopwatch timer;
92     TStopwatch dvtimer;
93     dvtimer.Start(kTRUE);
94     UInt_t nevents = 0;
95     UInt_t nruns = 0;
96     Double_t runtime = 0.;
97     Double_t cruntime = 0.;
98     Double_t trktime = 0.;
99     Double_t ctrktime = 0.;
100     Double_t caltime = 0.;
101     Double_t ccaltime = 0.;
102     Double_t toftime = 0.;
103     Double_t ctoftime = 0.;
104     Double_t trgtime = 0.;
105     Double_t ctrgtime = 0.;
106     Double_t actime = 0.;
107     Double_t cactime = 0.;
108     Double_t s4time = 0.;
109     Double_t cs4time = 0.;
110     Double_t ndtime = 0.;
111     Double_t cndtime = 0.;
112     Double_t orbtime = 0.;
113     Double_t corbtime = 0.;
114     Double_t dvtime = 0.;
115     Double_t cdvtime = 0.;
116     //
117 mocchiut 1.1 TString message;
118     int nul = 0;
119     Int_t error = 0;
120     //
121     Int_t CALSGN = 0;
122     Int_t TRKSGN = 0;
123     Int_t TRGSGN = 0;
124     Int_t TOFSGN = 0;
125     Int_t RUNSGN = 0;
126     Int_t ORBSGN = 0;
127     Int_t ACSGN = 0;
128     Int_t S4SGN = 0;
129     Int_t NDSGN = 0;
130 mocchiut 1.12 Int_t DVSGN = 0;
131 mocchiut 1.1 //
132 mocchiut 1.17 Bool_t autom = true;
133     Bool_t zerofill = false;
134     Bool_t tedious = false;
135 mocchiut 1.15 Bool_t remfile = false;
136 mocchiut 1.1 Bool_t debug = false;
137 mocchiut 1.10 Bool_t beverbose = true;
138 mocchiut 1.1 Bool_t givenid = false;
139 mocchiut 1.19 Bool_t bench = false;
140 mocchiut 1.1 Bool_t CAL = true;
141     Bool_t TRK = true;
142     Bool_t TRG = true;
143     Bool_t TOF = true;
144     Bool_t S4 = true;
145     Bool_t ND = true;
146     Bool_t AC = true;
147     Bool_t ORB = true;
148 mocchiut 1.19 Bool_t RUN = true;
149 mocchiut 1.1 //
150     Int_t calargc = 0;
151     char *calargv[50];
152     Int_t trkargc = 0;
153     char *trkargv[50];
154     Int_t tofargc = 0;
155     char *tofargv[50];
156     Int_t trgargc = 0;
157     char *trgargv[50];
158     Int_t orbargc = 0;
159     char *orbargv[50];
160     Int_t runargc = 0;
161     char *runargv[50];
162     Int_t acargc = 0;
163     char *acargv[50];
164     Int_t s4argc = 0;
165     char *s4argv[50];
166     Int_t ndargc = 0;
167     char *ndargv[50];
168     //
169     //
170     //
171 mocchiut 1.8 UInt_t run = 0;
172 mocchiut 1.1 //
173     TString filename;
174     TString outDir = gSystem->WorkingDirectory();
175     //
176     TSQLServer *dbc = 0;
177     TString host = "mysql://localhost/pamelaprod";
178     TString user = "anonymous";
179     TString psw = "";
180     //
181 mocchiut 1.10 //
182     const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
183     const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
184     const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
185 mocchiut 1.12 if ( !pamdbhost ) pamdbhost = "";
186     if ( !pamdbuser ) pamdbuser = "";
187     if ( !pamdbpsw ) pamdbpsw = "";
188 mocchiut 1.10 if ( strcmp(pamdbhost,"") ) host = pamdbhost;
189     if ( strcmp(pamdbuser,"") ) user = pamdbuser;
190     if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
191     //
192     //
193 mocchiut 1.1 TFile *processFile = 0;
194     //
195     // Checking input parameters
196     //
197     Int_t i = 0;
198     try {
199     if ( numinp > 1 ){
200     while ( i < numinp ){
201 mocchiut 1.8 Bool_t found = false;
202 mocchiut 1.1 if ( !strcmp(inps[i],"--version") ){
203     DarthVaderInfo(true);
204     exit(0);
205     };
206     if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){
207     usage();
208     exit(0);
209     };
210     if ( !strcmp(inps[i],"-idRun") ) {
211     if ( numinp-1 < i+1 ) {
212     usage();
213     throw -3;
214     };
215 mocchiut 1.8 i++;
216     found = true;
217 mocchiut 1.1 givenid = true;
218 mocchiut 1.8 run = atoll(inps[i]);
219 mocchiut 1.1 };
220     if ( !strcmp(inps[i],"-processFile") ) {
221     if ( numinp-1 < i+1 ){
222     usage();
223     throw -3;
224     };
225 mocchiut 1.8 i++;
226     found = true;
227     filename = (TString)inps[i];
228 mocchiut 1.1 };
229     if ( !strcmp(inps[i],"-outDir") ) {
230     if ( numinp-1 < i+1 ){
231     usage();
232     throw -3;
233     };
234 mocchiut 1.8 i++;
235     found = true;
236     outDir = (TString)inps[i];
237 mocchiut 1.1 };
238     if ( !strcmp(inps[i],"-host") ) {
239     if ( numinp-1 < i+1 ){
240     usage();
241     throw -3;
242     };
243 mocchiut 1.8 i++;
244     found = true;
245     host = (TString)inps[i];
246 mocchiut 1.1 };
247     if ( !strcmp(inps[i],"-user") ) {
248     if ( numinp-1 < i+1 ){
249     usage();
250     throw -3;
251     };
252 mocchiut 1.8 i++;
253     found = true;
254     user = (TString)inps[i];
255 mocchiut 1.1 };
256     if ( !strcmp(inps[i],"-psw") ) {
257     if ( numinp-1 < i+1 ){
258     usage();
259     throw -3;
260     };
261 mocchiut 1.8 i++;
262     found = true;
263     psw = (TString)inps[i];
264     };
265     if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ){
266     found = true;
267     beverbose = true;
268 mocchiut 1.1 };
269 mocchiut 1.15 if ( !strcmp(inps[i],"-c") || !strcmp(inps[i],"--clean")){
270     found = true;
271     remfile = true;
272     };
273 mocchiut 1.10 if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ){
274     found = true;
275     beverbose = false;
276     };
277 mocchiut 1.8 if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ){
278     debug = true;
279     found = true;
280     };
281 mocchiut 1.19 if ( !strcmp(inps[i],"-b") || !strcmp(inps[i],"--benchmark") ){
282     bench = true;
283     found = true;
284     };
285 mocchiut 1.17 if ( !strcmp(inps[i],"-auto") || !strcmp(inps[i],"-AUTO") ){
286     autom = true;
287     tedious = false;
288     zerofill = false;
289     found = true;
290     };
291     if ( !strcmp(inps[i],"-zerofill") ){
292     tedious = false;
293     autom = false;
294     zerofill = true;
295     found = true;
296     };
297     if ( !strcmp(inps[i],"-tedious") ){
298     tedious = true;
299     zerofill = false;
300     autom = false;
301     found = true;
302     };
303 mocchiut 1.1 //
304     if ( !strcmp(inps[i],"-CAL") ) {
305 mocchiut 1.8 found = true;
306 mocchiut 1.1 CAL = false;
307     };
308     if ( !strcmp(inps[i],"-TRK") ) {
309 mocchiut 1.8 found = true;
310 mocchiut 1.1 TRK = false;
311     };
312     if ( !strcmp(inps[i],"-TOF") ) {
313 mocchiut 1.8 found = true;
314 mocchiut 1.1 TOF = false;
315     };
316     if ( !strcmp(inps[i],"-TRG") ) {
317 mocchiut 1.8 found = true;
318 mocchiut 1.1 TRG = false;
319     };
320     if ( !strcmp(inps[i],"-S4") ) {
321 mocchiut 1.8 found = true;
322 mocchiut 1.1 S4 = false;
323     };
324     if ( !strcmp(inps[i],"-ND") ) {
325 mocchiut 1.8 found = true;
326 mocchiut 1.1 ND = false;
327     };
328     if ( !strcmp(inps[i],"-AC") ) {
329 mocchiut 1.8 found = true;
330 mocchiut 1.1 AC = false;
331     };
332     if ( !strcmp(inps[i],"-RUN") ) {
333 mocchiut 1.8 found = true;
334 mocchiut 1.1 RUN = false;
335     };
336     if ( !strcmp(inps[i],"-ORB") ) {
337 mocchiut 1.8 found = true;
338 mocchiut 1.1 ORB = false;
339     };
340     //
341 mocchiut 1.8 if ( !strcmp(inps[i],"-all") || !strcmp(inps[i],"-ALL") ) {
342 mocchiut 1.1 CAL = false;
343     ORB = false;
344     TRK = false;
345     TRG = false;
346     TOF = false;
347     S4 = false;
348     ND = false;
349     AC = false;
350     RUN = false;
351 mocchiut 1.8 found = true;
352 mocchiut 1.1 };
353     //
354 mocchiut 1.8 if ( !strcmp(inps[i],"+all") || !strcmp(inps[i],"+ALL") ) {
355 mocchiut 1.1 CAL = true;
356     ORB = true;
357     TRK = true;
358     TRG = true;
359     TOF = true;
360     S4 = true;
361     ND = true;
362     AC = true;
363     RUN = true;
364 mocchiut 1.8 found = true;
365 mocchiut 1.1 };
366     //
367     if ( !strcmp(inps[i],"+CAL") ) {
368 mocchiut 1.8 found = true;
369 mocchiut 1.1 CAL = true;
370     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
371     if ( numinp < i+2 ){
372     usage();
373     throw -3;
374     };
375     i += 2;
376     calargc = 0;
377     while ( strcmp(inps[i],"]") ){
378     calargv[calargc] = inps[i];
379     calargc++;
380     i++;
381     if ( i > numinp-1 ){
382     usage();
383     throw -3;
384     };
385     };
386     };
387     };
388     if ( !strcmp(inps[i],"+TRK") ) {
389 mocchiut 1.8 found = true;
390 mocchiut 1.1 TRK = true;
391     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
392     if ( numinp-1 < i+2 ){
393     usage();
394     throw -3;
395     };
396     i += 2;
397     trkargc = 0;
398     while ( strcmp(inps[i],"]") ){
399     trkargv[trkargc] = inps[i];
400     trkargc++;
401     i++;
402     if ( i > numinp-1 ){
403     usage();
404     throw -3;
405     };
406     };
407     };
408     };
409     if ( !strcmp(inps[i],"+TOF") ) {
410 mocchiut 1.8 found = true;
411 mocchiut 1.1 TOF = true;
412     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
413     i += 2;
414     tofargc = 0;
415     while ( strcmp(inps[i],"]") ){
416     tofargv[tofargc] = inps[i];
417     tofargc++;
418     i++;
419     if ( i > numinp-1 ){
420     usage();
421     throw -3;
422     };
423     };
424     };
425     };
426     if ( !strcmp(inps[i],"+TRG") ) {
427 mocchiut 1.8 found = true;
428 mocchiut 1.1 TRG = true;
429     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
430     i += 2;
431     trgargc = 0;
432     while ( strcmp(inps[i],"]") ){
433     trgargv[trgargc] = inps[i];
434     trgargc++;
435     i++;
436     if ( i > numinp-1 ){
437     usage();
438     throw -3;
439     };
440     };
441     };
442     };
443     if ( !strcmp(inps[i],"+ORB") ) {
444 mocchiut 1.8 found = true;
445 mocchiut 1.1 ORB = true;
446     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
447     i += 2;
448     orbargc = 0;
449     while ( strcmp(inps[i],"]") ){
450     orbargv[orbargc] = inps[i];
451     orbargc++;
452     i++;
453     if ( i > numinp-1 ){
454     usage();
455     throw -3;
456     };
457     };
458     };
459     };
460     if ( !strcmp(inps[i],"+RUN") ) {
461 mocchiut 1.8 found = true;
462 mocchiut 1.1 RUN = true;
463     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
464     i += 2;
465     runargc = 0;
466     while ( strcmp(inps[i],"]") ){
467     runargv[runargc] = inps[i];
468     runargc++;
469     i++;
470     if ( i > numinp-1 ){
471     usage();
472     throw -3;
473     };
474     };
475     };
476     };
477     if ( !strcmp(inps[i],"+AC") ) {
478 mocchiut 1.8 found = true;
479 mocchiut 1.1 AC = true;
480     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
481     i += 2;
482     acargc = 0;
483     while ( strcmp(inps[i],"]") ){
484     acargv[acargc] = inps[i];
485     acargc++;
486     i++;
487     if ( i > numinp-1 ){
488     usage();
489     throw -3;
490     };
491     };
492     };
493     };
494     if ( !strcmp(inps[i],"+S4") ) {
495 mocchiut 1.8 found = true;
496 mocchiut 1.1 S4 = true;
497     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
498     i += 2;
499     s4argc = 0;
500     while ( strcmp(inps[i],"]") ){
501     s4argv[s4argc] = inps[i];
502     s4argc++;
503     i++;
504     if ( i > numinp-1 ){
505     usage();
506     throw -3;
507     };
508     };
509     };
510     };
511     if ( !strcmp(inps[i],"+ND") ) {
512 mocchiut 1.8 found = true;
513 mocchiut 1.1 ND = true;
514     if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){
515     i += 2;
516     ndargc = 0;
517     while ( strcmp(inps[i],"]") ){
518     ndargv[ndargc] = inps[i];
519     ndargc++;
520     i++;
521     if ( i > numinp-1 ){
522     usage();
523     throw -3;
524     };
525     };
526     };
527     };
528     //
529 mocchiut 1.8 if ( !found && i > 0 ){
530     usage();
531     printf(" Unknown input number %i, that is \"%s\" \n",i,inps[i]);
532     throw -22;
533     };
534     //
535 mocchiut 1.1 i++;
536     };
537     //
538     } else {
539     //
540     // no input parameters exit with error, we need at least the run id.
541     //
542     throw -1;
543     };
544     //
545     // If not in verbose mode redirect to /dev/null the stdout and stderr
546     //
547     if ( !beverbose ){
548     nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
549     dup2(nul,1);
550     dup2(nul,2);
551     };
552     //
553     // Check that an input run number has been given
554     //
555     if ( !givenid ) throw -1;
556     //
557 mocchiut 1.15 TString version = DarthVaderInfo(false);
558 mocchiut 1.1 //
559     // Start:
560     //
561 mocchiut 1.15 printf("\n Welcome to the PAMELA LEVEL2 flight software, version %s \n\n",version.Data());
562 mocchiut 1.21 if ( run ) printf("\n Processing run number %u \n\n",run);
563 mocchiut 1.1 //
564     // Connect to the DB
565     //
566     if ( debug ) printf("\nConnecting to database... \n");
567     //
568     dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
569     if( !dbc ) throw -2;
570     //
571 mocchiut 1.18 Bool_t connect = dbc->IsConnected();
572 mocchiut 1.1 //
573     if( !connect ) throw -2;
574     //
575     if ( debug ) printf("...connected! \n\n");
576     //
577 mocchiut 1.19 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());
578     //
579 mocchiut 1.15 // Use UTC in the DB
580     //
581 mocchiut 1.14 stringstream myquery;
582     myquery.str("");
583     myquery << "SET time_zone='+0:00'";
584     dbc->Query(myquery.str().c_str());
585     //
586     //
587 mocchiut 1.1 // Create LEVEL2 filename and open it in update mode
588     //
589     if ( filename.IsNull() ){
590     stringstream strun;
591     strun.str("");
592     strun << run;
593 mocchiut 1.3 filename += outDir;
594     filename += "/";
595 mocchiut 1.1 filename += strun.str();
596     filename += ".Level2.root";
597     };
598     processFile = new TFile(filename.Data(),"UPDATE");
599     if ( !processFile->IsOpen() ) throw -15;
600     //
601 mocchiut 1.23 Long64_t maxsize = 10000000000LL;
602     TTree::SetMaxTreeSize(maxsize);
603 mocchiut 1.24 processFile->SetCompressionLevel(1);
604 mocchiut 1.23 //
605     //
606 mocchiut 1.1 // Run the core program, put any output error in the "error" variable
607     //
608 mocchiut 1.19 if ( debug ) printf("\n\n Pre-processing:\n\n");
609 mocchiut 1.15 //
610 mocchiut 1.19 timer.Start(kTRUE);
611 mocchiut 1.1 if ( RUN ) {
612 mocchiut 1.19 if ( debug ) printf(" Retrieve, if the case, the RUN informations from the DB...\n");
613 mocchiut 1.15 printf(" RunInfo called\n");
614     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start RunInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
615     RUNSGN = RunInfoCore(run,processFile,dbc,version,runargc,runargv);
616     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end RunInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
617 mocchiut 1.19 if ( debug ) printf(" ...done\n");
618 mocchiut 1.1 };
619 mocchiut 1.19 timer.Stop();
620     runtime = timer.RealTime();
621     cruntime = timer.CpuTime();
622 mocchiut 1.4 //
623     // From the Run Infos extract acq_var_info to determine if detectors are in the acquisition or not
624     //
625 mocchiut 1.19 if ( debug ) printf(" Checking if requested detectors are in the acquisition\n");
626 mocchiut 1.4 ItoRunInfo *runinfo = new ItoRunInfo(processFile);
627 mocchiut 1.15 Int_t sgnl = runinfo->Read(run);
628     if ( sgnl != 0 ) throw -17;
629 mocchiut 1.19 nevents = runinfo->GetEntries();
630     nruns = runinfo->GetNoRun();
631     if ( debug ) printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO);
632 mocchiut 1.17 if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ){
633     DVSGN += 1;
634     if ( tedious ) throw -30;
635     if ( autom ){
636     TRK = 0;
637 mocchiut 1.19 if ( debug ) printf(" TRK excluded from processing \n");
638 mocchiut 1.17 };
639 mocchiut 1.19 if ( zerofill && debug ) printf(" TRK is not in the acquisition! \n");
640 mocchiut 1.17 };
641     if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ){
642     DVSGN += 2;
643     if ( tedious ) throw -31;
644     if ( autom ){
645     TOF = 0;
646 mocchiut 1.19 if ( debug ) printf(" TOF excluded from processing \n");
647 mocchiut 1.17 };
648 mocchiut 1.19 if ( zerofill && debug ) printf(" TOF is not in the acquisition! \n");
649 mocchiut 1.17 };
650     if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ){
651     DVSGN += 4;
652     if ( tedious ) throw -32;
653     if ( autom ){
654     CAL = 0;
655 mocchiut 1.19 if ( debug ) printf(" CAL excluded from processing \n");
656 mocchiut 1.17 };
657 mocchiut 1.19 if ( zerofill && debug ) printf(" CAL is not in the acquisition! \n");
658 mocchiut 1.17 };
659     if ( AC && (!(runinfo->ACQ_VAR_INFO & (1 << 1)) || !(runinfo->ACQ_VAR_INFO & (1 << 2))) ){
660     DVSGN += 8;
661     if ( tedious ) throw -33;
662     if ( autom ){
663     AC = 0;
664 mocchiut 1.19 if ( debug ) printf(" AC excluded from processing \n");
665 mocchiut 1.17 };
666 mocchiut 1.19 if ( zerofill && debug ) printf(" AC is not in the acquisition! \n");
667 mocchiut 1.17 };
668     if ( S4 && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ){
669     DVSGN += 16;
670     if ( tedious ) throw -34;
671     if ( autom ){
672     S4 = 0;
673 mocchiut 1.19 if ( debug ) printf(" S4 excluded from processing \n");
674 mocchiut 1.17 };
675 mocchiut 1.19 if ( zerofill && debug ) printf(" S4 is not in the acquisition! \n");
676 mocchiut 1.17 };
677     if ( ND && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ){
678     DVSGN += 32;
679     if ( tedious ) throw -35;
680     if ( autom ){
681     ND = 0;
682 mocchiut 1.19 if ( debug ) printf(" ND excluded from processing \n");
683 mocchiut 1.17 };
684 mocchiut 1.19 if ( zerofill && debug ) printf(" ND is not in the acquisition! \n");
685 mocchiut 1.17 };
686 mocchiut 1.15 //
687     if ( !DVSGN ){
688 mocchiut 1.19 if ( debug ) printf(" OK! Start processing detector's data. \n");
689 mocchiut 1.15 } else {
690 mocchiut 1.19 if ( debug ) printf(" WARNING! missing detector(s)! Start anyway processing detector's data. \n");
691 mocchiut 1.15 };
692 mocchiut 1.19 if ( debug ) printf("\n End pre-processing \n\n");
693 mocchiut 1.4 //
694 mocchiut 1.19 timer.Start(kTRUE);
695 mocchiut 1.1 if ( TRK ) {
696 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
697 mocchiut 1.15 printf(" TrackerLevel2 called\n");
698     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start TrkCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
699 mocchiut 1.1 TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv);
700 mocchiut 1.11 gSystem->Unlink("TrackerFolder"); //patch
701 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end TrkCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
702 mocchiut 1.1 };
703 mocchiut 1.19 timer.Stop();
704     trktime = timer.RealTime();
705     ctrktime = timer.CpuTime();
706     //
707     timer.Start(kTRUE);
708 mocchiut 1.1 if ( TOF ) {
709 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
710 mocchiut 1.15 printf(" ToFLevel2 called\n");
711     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start ToFCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
712 mocchiut 1.1 TOFSGN = ToFCore(run,processFile,dbc,tofargc,tofargv);
713 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end ToFCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
714 mocchiut 1.1 };
715 mocchiut 1.19 timer.Stop();
716     toftime = timer.RealTime();
717     ctoftime = timer.CpuTime();
718     //
719     timer.Start(kTRUE);
720 mocchiut 1.1 if ( CAL ) {
721 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
722 mocchiut 1.15 printf(" CalorimeterLevel2 called\n");
723     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start CaloCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
724 mocchiut 1.1 CALSGN = CaloCore(run,processFile,dbc,calargc,calargv);
725 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end CaloCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
726 mocchiut 1.1 };
727 mocchiut 1.19 timer.Stop();
728     caltime = timer.RealTime();
729     ccaltime = timer.CpuTime();
730     //
731     timer.Start(kTRUE);
732 mocchiut 1.1 if ( TRG ) {
733 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
734 mocchiut 1.15 printf(" TriggerLevel2 called\n");
735     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start TrigCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
736 mocchiut 1.1 TRGSGN = TrigCore(run,processFile,dbc,trgargc,trgargv);
737 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end TrigCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
738 mocchiut 1.1 };
739 mocchiut 1.19 timer.Stop();
740     trgtime = timer.RealTime();
741     ctrgtime = timer.CpuTime();
742     //
743     timer.Start(kTRUE);
744 mocchiut 1.1 if ( AC ) {
745 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
746 mocchiut 1.15 printf(" AnticounterLevel2 called\n");
747     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start AcCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
748 mocchiut 1.1 ACSGN = AcCore(run,processFile,dbc,acargc,acargv);
749 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end AcCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
750 mocchiut 1.1 };
751 mocchiut 1.19 timer.Stop();
752     actime = timer.RealTime();
753     cactime = timer.CpuTime();
754     //
755     timer.Start(kTRUE);
756 mocchiut 1.1 if ( S4 ) {
757 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
758 mocchiut 1.15 printf(" S4Level2 called\n");
759     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start S4Core STDOUT |<<<<<<<<<<<<<<<<<<<\n");
760 mocchiut 1.1 S4SGN = S4Core(run,processFile,dbc,s4argc,s4argv);
761 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end S4Core STDOUT |<<<<<<<<<<<<<<<<<<<\n");
762 mocchiut 1.1 };
763 mocchiut 1.19 timer.Stop();
764     s4time = timer.RealTime();
765     cs4time = timer.CpuTime();
766     //
767     timer.Start(kTRUE);
768 mocchiut 1.1 if ( ND ) {
769 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
770 mocchiut 1.15 printf(" NDLevel2 called\n");
771     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start NDCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
772 mocchiut 1.1 NDSGN = NDCore(run,processFile,dbc,ndargc,ndargv);
773 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end NDCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
774 mocchiut 1.1 };
775 mocchiut 1.19 timer.Stop();
776     ndtime = timer.RealTime();
777     cndtime = timer.CpuTime();
778     //
779     timer.Start(kTRUE);
780 mocchiut 1.1 if ( ORB ) {
781 mocchiut 1.26 CheckDBC(dbc,host,user,psw);
782 mocchiut 1.15 printf(" OrbitalInfo called\n");
783     if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| start OrbitalInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
784 mocchiut 1.1 ORBSGN = OrbitalInfoCore(run,processFile,dbc,orbargc,orbargv);
785 mocchiut 1.15 if ( debug ) printf(" >>>>>>>>>>>>>>>>>>>| end OrbitalInfoCore STDOUT |<<<<<<<<<<<<<<<<<<<\n");
786 mocchiut 1.1 };
787 mocchiut 1.19 timer.Stop();
788     orbtime = timer.RealTime();
789     corbtime = timer.CpuTime();
790 mocchiut 1.1 //
791     } catch(Int_t signal) {
792     error = signal;
793     switch(signal){
794     case 51: message += " GLTABLES - TO_TIME < time when querying tables"; break;
795     case -1: message += " Missing/wrong run ID input parameter"; break;
796     case -2: message += " DB connection failure"; break;
797     case -3: message += " Error in input parameters (check format)"; break;
798     case -4: message += " Request reprocessing of all runs (idRun = 0) but processFile is missing"; break;
799     case -6: message += " No LEVEL0 file "; break;
800     case -7: message += " No Physics tree in LEVEL0 file"; break;
801     case -8: message += " No Header branch in LEVEL0 Physics tree"; break;
802     case -9: message += " No Registry branch in LEVEL0 Physics tree"; break;
803     case -11: message += " LEVEL0 Physics tree is empty"; break;
804 mocchiut 1.9 case -12: message += " Too few entries in the tree"; break;
805 mocchiut 1.1 case -13: message += " Cannot create processFolder directory"; break;
806     case -14: message += " Error querying the DB"; break;
807     case -15: message += " Cannot open file for writing"; break;
808 mocchiut 1.15 case -17: message += " Error during pre-processing"; break;
809 mocchiut 1.8 case -22: message += " Unknown input or wrong syntax in input paramters!"; break;
810 mocchiut 1.17 case -30: message += " No TRK in the acquisition"; break;
811     case -31: message += " No TOF in the acquisition"; break;
812     case -32: message += " No CAL in the acquisition"; break;
813     case -33: message += " No AC in the acquisition"; break;
814     case -34: message += " No S4 in the acquisition"; break;
815     case -35: message += " No ND in the acquisition"; break;
816 mocchiut 1.1 //
817     case -50: message += " GLTABLES - No entries matching GL_RUN query"; break;
818     case -51: message += " GLTABLES - No entries matching GL_ROOT query"; break;
819     case -52: message += " GLTABLES - No entries matching GL_PARAM query"; break;
820     case -53: message += " GLTABLES - No entries matching GL_TRK_CALIB query"; break;
821     case -54: message += " GLTABLES - No entries matching GL_CALO_CALIB query"; break;
822     case -55: message += " GLTABLES - No entries matching GL_CALO_CALIB query"; break;
823 mocchiut 1.25 case -56: message += " GLTABLES - No entries matching GL_TLE query"; break;
824 mocchiut 1.1 //
825     case -100: message += " CALORIMETERLEVEL2 - No Level2 input file"; break;
826     case -101: message += " CALORIMETERLEVEL2 - Cannot open Level2 file"; break;
827     case -102: message += " CALORIMETERLEVEL2 - No Tracker TTree in Level2 file"; break;
828     case -103: message += " CALORIMETERLEVEL2 - No Calorimeter TBranch in Level0 file"; break;
829     case -104: message += " CALORIMETERLEVEL2 - No Trigger TTree in Level0 file"; break;
830     case -105: message += " CALORIMETERLEVEL2 - No Calorimeter ADC2MIP conversion file"; break;
831     case -106: message += " CALORIMETERLEVEL2 - No Calorimeter alignement file"; break;
832     case -107: message += " CALORIMETERLEVEL2 - Cannot find Level0 file needed for the calibration"; break;
833     case -108: message += " CALORIMETERLEVEL2 - Cannot open Level0 file needed for the calibration"; break;
834     case -109: message += " CALORIMETERLEVEL2 - No CalibCalPed TTree in Level0 file needed for the calibration"; break;
835     case -110: message += " CALORIMETERLEVEL2 - No calibrations in Level0 file needed for the calibration"; break;
836     case -111: message += " CALORIMETERLEVEL2 - Corrupted calibration"; break;
837     case -112: message += " CALORIMETERLEVEL2 - No physics event related to registry entry in Level0 file"; break;
838     case -113: message += " CALORIMETERLEVEL2 - No tracker event related to registry entry in Level2 file"; break;
839 mocchiut 1.17 case -114: message += " CALORIMETERLEVEL2 - Help called"; break;
840     case -115: message += " CALORIMETERLEVEL2 - No Calorimeter bad strip offline mask file"; break;
841 mocchiut 1.18 case -116: message += " CALORIMETERLEVEL2 - DB connection problems"; break;
842 mocchiut 1.20 case -117: message += " CALORIMETERLEVEL2 - Cannot reprocess file with Level1 data without calling Level1 routine"; break;
843     case -118: message += " CALORIMETERLEVEL2 - Cannot reprocess file without Level1 data calling Level1 routine"; break;
844 mocchiut 1.1 //
845     case -200: message += " TRACKERLEVEL2 - LEVEL1 framework unknown (HBOOK/ROOT)"; break;
846     case -201: message += " TRACKERLEVEL2 - LEVEL2 framework unknown (HBOOK/ROOT)"; break;
847     case -202: message += " TRACKERLEVEL2 - Neither LEVEL1 nor LEVEL2 output requested"; break;
848     case -203: message += " TRACKERLEVEL2 - No Tracker branch in LEVEL0 Physics tree"; break;
849     case -204: message += " TRACKERLEVEL2 - No reprocessing implemented for LEVEL1 output"; break;
850     case -205: message += " TRACKERLEVEL2 - Error accessing RunInfo "; break;
851     case -210: message += " TRACKERLEVEL2 - Error opening/reading trk mask GL_PARAM parameters "; break;
852     case -211: message += " TRACKERLEVEL2 - Error opening/reading trk alignment GL_PARAM parameters"; break;
853     case -212: message += " TRACKERLEVEL2 - Error opening/reading trk mip GL_PARAM parameters"; break;
854     case -213: message += " TRACKERLEVEL2 - Error opening/reading trk charge GL_PARAM parameters"; break;
855     case -214: message += " TRACKERLEVEL2 - Error opening/reading trk pfa GL_PARAM parameters"; break;
856     case -215: message += " TRACKERLEVEL2 - Error opening/reading field GL_PARAM parameters"; break;
857     case -216: message += " TRACKERLEVEL2 - Error opening/reading default calibration GL_PARAM parameters"; break;
858     case -298: message += " TRACKERLEVEL2 - Reprocessing not implemented in standalone mode"; break;
859     case -299: message += " TRACKERLEVEL2 - Not yet implemented"; break;
860     //
861     case -300: message += " TOFLEVEL2 - No Trigger branch in Level0 tree"; break;
862     case -301: message += " TOFLEVEL2 - Cannot open file for writing"; break;
863     case -302: message += " TOFLEVEL2 - No tracker tree in Level2 file"; break;
864     case -303: message += " TOFLEVEL2 - No Tof branch in Level0 file"; break;
865     case -313: message += " TOFLEVEL2 - No more tracker events in Level2 file"; break;
866 mocchiut 1.18 case -314: message += " TOFLEVEL2 - DB connection problems"; break;
867 mocchiut 1.1 //
868     case -401: message += " TRIGGERLEVEL2 - Cannot open file for writing"; break;
869     case -402: message += " TRIGGERLEVEL2 - No Trigger branch in Level0 tree"; break;
870 mocchiut 1.18 case -403: message += " TRIGGERLEVEL2 - DB connection problems"; break;
871 mocchiut 1.1 //
872     case -500: message += " S4LEVEL2 - No level2 file"; break;
873     case -501: message += " S4LEVEL2 - Cannot open file for writing"; break;
874     case -502: message += " S4LEVEL2 - No result from GL_S4_CALIB"; break;
875     case -503: message += " S4LEVEL2 - No S4 branch in Level0 tree"; break;
876 mocchiut 1.18 case -504: message += " S4LEVEL2 - DB connection problems"; break;
877 mocchiut 1.1 //
878     case -600: message += " NDLEVEL2 - No level2 file"; break;
879     case -601: message += " NDLEVEL2 - Cannot open file for writing"; break;
880     case -603: message += " NDLEVEL2 - No S4Level2 branch in Level0 tree"; break;
881 mocchiut 1.18 case -604: message += " NDLEVEL2 - DB connection problems"; break;
882 mocchiut 1.1 //
883 mocchiut 1.17 case -701: message += " ACLEVEL2 - Cannot open file for writing"; break;
884     case -704: message += " ACLEVEL2 - No Anticounter branch in Level0 tree"; break;
885 mocchiut 1.18 case -705: message += " ACLEVEL2 - DB connection problems"; break;
886 mocchiut 1.1 //
887     case -800: message += " RUNINFO - No such run in the RunInfo list"; break;
888     case -801: message += " RUNINFO - No RunInfo tree in Level2 file"; break;
889     case -802: message += " RUNINFO - Cannot open file for writing"; break;
890     case -803: message += " RUNINFO - Updating but no RunInfo tree in Level2 file"; break;
891     case -804: message += " RUNINFO - Unknown detector"; break;
892 mocchiut 1.2 case -805: message += " RUNINFO - Reprocessing data but no RunInfo tree in Level2 file"; break;
893 mocchiut 1.7 case -806: message += " RUNINFO - Can not handle more than 500 runs"; break;
894 mocchiut 1.18 case -807: message += " RUNINFO - DB connection problems"; break;
895     //
896 mocchiut 1.1 default: message += "Unidentified error or warning"; break;
897     };
898     printf("\n");
899     if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl;
900     }
901 mocchiut 1.12 //
902 mocchiut 1.15 // Warnings from XCore routines and from DV:
903     //
904     if ( debug && DVSGN ) printf(" DVSGN = %i \n",DVSGN);
905     if ( DVSGN ) printf("\n WARNING DarthVader: \n");
906     if ( DVSGN & (1 << 0) ) printf(" - No tracker in the acquisition\n");
907     if ( DVSGN & (1 << 1) ) printf(" - No ToF in the acquisition\n");
908     if ( DVSGN & (1 << 2) ) printf(" - No calorimeter in the acquisition\n");
909     if ( DVSGN & (1 << 3) ) printf(" - No anticounters in the acquisition\n");
910     if ( DVSGN & (1 << 4) ) printf(" - No S4 in the acquisition\n");
911     if ( DVSGN & (1 << 5) ) printf(" - No neutron detector in the acquisition\n");
912     //
913     // CaloCore:
914 mocchiut 1.12 //
915 mocchiut 1.1 switch(CALSGN){
916 mocchiut 1.13 case 100: printf("\n WARNING CALORIMETER - Data with no associated calibration\n");
917     case 101: printf("\n WARNING CALORIMETER - No tracks or good events in this run\n");
918 mocchiut 1.1 };
919     //
920 mocchiut 1.15 // no other at the moment
921     //
922     //
923 mocchiut 1.1 // Close the DB connection
924     //
925     if ( dbc ){
926     if ( debug ) printf("\nClose the connection to the database... \n");
927     dbc->Close();
928     if ( debug ) printf("...connection terminated!\n\n");
929     };
930     if ( processFile ){
931     processFile->cd();
932 mocchiut 1.24 processFile->WriteStreamerInfo();
933 mocchiut 1.1 processFile->Close();
934     };
935     //
936 mocchiut 1.19 // print benchmark results (if the case)
937     //
938     dvtimer.Stop();
939     dvtime = dvtimer.RealTime();
940     cdvtime = dvtimer.CpuTime();
941     if ( bench ){
942     Float_t runrt = 0.;
943     Float_t trkrt = 0.;
944     Float_t calrt = 0.;
945     Float_t tofrt = 0.;
946     Float_t trgrt = 0.;
947     Float_t acrt = 0.;
948     Float_t s4rt = 0.;
949     Float_t ndrt = 0.;
950     Float_t orbrt = 0.;
951     Float_t dvrt = nevents/dvtime;
952     if ( RUN ) runrt = nruns/runtime;
953     if ( TRK ) trkrt = nevents/trktime;
954     if ( CAL ) calrt = nevents/caltime;
955     if ( TOF ) tofrt = nevents/toftime;
956     if ( TRG ) trgrt = nevents/trgtime;
957     if ( AC ) acrt = nevents/actime;
958     if ( S4 ) s4rt = nevents/s4time;
959     if ( ND ) ndrt = nevents/ndtime;
960     if ( ORB ) orbrt = nevents/orbtime;
961     //
962     printf("\n\n################################################################################\n");
963     printf("# Benchmark results: nevents = %10u runs = %3u #\n",nevents,nruns);
964     printf("################################################################################\n");
965     printf("# Detector # Core routine called # Real Time # CPU time # Events/s #\n");
966     printf("################################################################################\n");
967     printf("# RUN # %i # %8.2f # %8.2f # %8.2f #\n",RUN,fabs(runtime),fabs(cruntime),runrt);
968     printf("# TRK # %i # %8.2f # %8.2f # %8.2f #\n",TRK,fabs(trktime),fabs(ctrktime),trkrt);
969     printf("# CAL # %i # %8.2f # %8.2f # %8.2f #\n",CAL,fabs(caltime),fabs(ccaltime),calrt);
970     printf("# TOF # %i # %8.2f # %8.2f # %8.2f #\n",TOF,fabs(toftime),fabs(ctoftime),tofrt);
971     printf("# TRG # %i # %8.2f # %8.2f # %8.2f #\n",TRG,fabs(trgtime),fabs(ctrgtime),trgrt);
972     printf("# AC # %i # %8.2f # %8.2f # %8.2f #\n",AC,fabs(actime),fabs(cactime),acrt);
973     printf("# S4 # %i # %8.2f # %8.2f # %8.2f #\n",S4,fabs(s4time),fabs(cs4time),s4rt);
974     printf("# ND # %i # %8.2f # %8.2f # %8.2f #\n",ND,fabs(ndtime),fabs(cndtime),ndrt);
975     printf("# ORB # %i # %8.2f # %8.2f # %8.2f #\n",ORB,fabs(orbtime),fabs(corbtime),orbrt);
976     printf("################################################################################\n");
977     printf("# Total # # %8.2f # %8.2f # %8.2f #\n",fabs(dvtime),fabs(cdvtime),dvrt);
978     printf("################################################################################\n");
979     };
980     //
981     //
982 mocchiut 1.1 if ( error != 0 ) printf("\n\n WARNING: exiting with signal %i \n\n",error);
983 mocchiut 1.15 //
984     //
985     //
986     if ( remfile && error < 0 ){
987     printf(" -c or --clean option used, deleting file %s \n\n",filename.Data());
988     gSystem->Unlink(filename.Data());
989     };
990     //
991     printf("\n Finished, exiting...\n\n");
992 mocchiut 1.1 //
993     // Close redirection if the case.
994     //
995     if ( !beverbose ) close(nul);
996     //
997     //
998     exit(error);
999     }

  ViewVC Help
Powered by ViewVC 1.1.23