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

Contents of /DarthVader/src/DarthVader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.46 - (show annotations) (download)
Wed Mar 6 14:20:27 2013 UTC (11 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.45: +1 -0 lines
Simulation flag (Valerio's style) added for Tracker

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

  ViewVC Help
Powered by ViewVC 1.1.23