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

Contents of /DarthVader/src/DarthVader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.43 - (show annotations) (download)
Thu Apr 12 12:30:04 2012 UTC (12 years, 7 months ago) by mocchiut
Branch: MAIN
Changes since 1.42: +16 -13 lines
New TrigLevel2, ToFLevel2, OrbitalInfo classes, new order in DV processing (trigger first), ToF bugs fixed, new tof calibration, new variables in ToF and OrbitalInfo

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

  ViewVC Help
Powered by ViewVC 1.1.23