/[PAMELA software]/chewbacca/YodaProfiler/src/YodaProfiler.cpp
ViewVC logotype

Contents of /chewbacca/YodaProfiler/src/YodaProfiler.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Tue Nov 4 09:44:50 2008 UTC (16 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.2: +19 -2 lines
chewbacca upgrade, YP upgrade

1 //
2 #include <iostream>
3 #include <sstream>
4 #include <errno.h>
5 //
6 #include <TSystem.h>
7 //
8 #include <GLTables.h>
9 #include <PamelaDBOperations.h>
10 #include <YodaProfilerVerl2.h>
11 //
12 using namespace std;
13 //
14 // Usage subroutine
15 //
16 void usage(){
17 printf("\nUsage:\n");
18 printf("\n YodaProfiler [options] -rawFile raw_filename -yodaFile yoda_filename \n");
19 printf("\n -rawFile full path to the raw file\n");
20 printf( " -yodaFile full path to the YODA file OR ID of the file to be processed\n");
21 printf("\n Options are:\n\n");
22 printf(" --version print informations about compilation and exit\n");
23 printf(" -h | --help print this help and exit \n");
24 printf(" -v | --verbose be verbose [default]\n");
25 printf(" -s | --silent print nothing on STDOUT\n");
26 printf(" -g | --debug be very verbose [default: no]\n");
27 printf(" -p | --pedantic be strict in checks, exit with error if any problem is found [default: no]\n");
28 printf(" -tag char set the run tagging in _RUNID_GEN to \"char\" (four letters)[default = 'NONE']\n");
29 printf(" -boot number CPU boot number [default = taken from VarDump]\n");
30 printf(" -autoboot if no VarDump found try to determine the BOOT number\n");
31 printf(" looking at timesync [default]\n");
32 printf(" -no-autoboot disable previous check\n");
33 printf(" -tsync number timesync (s) [default = taken from data]\n");
34 printf(" -obt0 number obt at timesync (ms) [default = taken from data]\n");
35 printf(" -dworbit number number is the downlink orbit number (to be used with non-standard names)\n");
36 printf(" -static use static path inside the DB instead of symbolic names\n");
37 // printf(" -keepenv use environmental variables in the filenames\n");
38 printf(" -k | --keepenv use environmental variables in the filenames\n");
39 // printf(" -gpamela shortcut to \"-clean 0 -obt0 1 -tsync 1 -no-autoboot -boot 1 -dworbit 1 -static\"\n");
40 printf(" -gpamela shortcut to \"-clean 0 -obt0 1 -no-autoboot -dworbit 1 -static\"\n");
41 printf(" -clean number number in seconds after which the fragment table\n");
42 printf(" can be cleaned and runs validated [default = -1 do not clean],\n");
43 printf(" if 0 force cleaning immediatly, if negative do not clean\n");
44 printf(" -remove file remove file and all related runs and calibrations from DB\n");
45 printf(" file must be the YODA filename (full path is not needed)\n");
46 printf(" 'same' can be used if in conjuction with -yodaFile\n");
47 printf(" -validate file validates runs between the two closest calibration to file \n");
48 printf(" not belonging to file itself. File must be the YODA filename\n");
49 printf(" 'same' can be used if in conjuction with -yodaFile\n");
50 printf(" -cleanfrag file clean run fragments for file only\n");
51 printf(" File must be the YODA filename\n");
52 printf(" 'same' can be used if in conjuction with -yodaFile\n");
53 printf(" -runpieces when cleaning fragments check if run are divided in more pieces [default: false in standard case, true for chewbacca files]\n");
54 printf(" -nofrag do not leave runs in the fragment table and look for fragments\n");
55 printf(" in the GL_RUN table.\n");
56 printf(" -f | -force to be used to reprocess a file or to process a file\n");
57 printf(" when already validated the surroundings, it is equivalent to:\n");
58 printf(" -remove same -validate same -cleanfrag same -nofrag\n");
59 printf(" -check performs some test on the GL_RUN table to check its consistency\n");
60 printf(" -checkfrom idrun performs some test on the GL_RUN table to check its consistency starting from run number idrun\n");
61 printf(" -checkto idrun performs some test on the GL_RUN table to check its consistency arriving till run number idrun\n");
62 printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
63 printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n");
64 printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n");
65 printf(" -tle <file> ascii file containing TLE obtained from celestrak.org or space-track.org [default = no]\n");
66 printf("\n The order of input files and options does not matter. \n");
67 printf("\n Example: \n");
68 printf(" YodaProfiler -yodaFile /path/to/raw/files/000_000_00000_cln2.root -rawFile /path/to/filesfromyoda/000_000_00000_cln2.pam -v \n\n");
69 };
70 //
71 int main(int numinp, char *inps[]){
72 //
73 // Variables booking
74 //
75 Int_t signal = 0;
76 Int_t nul = 0;
77 UInt_t boot = 0;
78 UInt_t tsync = 0;
79 UInt_t obt0 = 0;
80 UInt_t dwinput = 0;
81 UInt_t chfrom = 0;
82 UInt_t chto = 0;
83 Long64_t olderthan = -1LL;
84 Bool_t runpieces = false;
85 //
86 //
87 TString tag = "NONE";
88 TString filerawname = "";
89 TString filerootname = "";
90 //
91 TString host = "mysql://localhost/pamelaprod";
92 TString user = "anonymous";
93 TString password = "";
94 //
95 TString tlefilename = "";
96 //
97 const char *pamdbhost = gSystem->Getenv("PAM_DBHOST");
98 const char *pamdbuser = gSystem->Getenv("PAM_DBUSER");
99 const char *pamdbpsw = gSystem->Getenv("PAM_DBPSW");
100 if ( !pamdbhost ) pamdbhost = "";
101 if ( !pamdbuser ) pamdbuser = "";
102 if ( !pamdbpsw ) pamdbpsw = "";
103 if ( strcmp(pamdbhost,"") ) host = pamdbhost;
104 if ( strcmp(pamdbuser,"") ) user = pamdbuser;
105 if ( strcmp(pamdbpsw,"") ) password = pamdbpsw;
106 //
107 //
108 Bool_t chewbacca = false;
109 Bool_t staticp = false;
110 Bool_t keepenv = false;
111 Bool_t beverbose = true;
112 Bool_t debug = false;
113 Bool_t autoboot = true;
114 Bool_t gpamela = false;
115 //
116 Bool_t remove = false;
117 TString remfile = "";
118 //
119 Bool_t forceclean = false;
120 TString fcleanfile = "";
121 //
122 Bool_t validate = false;
123 TString validfile = "";
124 //
125 Bool_t nofrag = false;
126 //
127 Bool_t force = false;
128 //
129 Bool_t check = false;
130 //
131 Bool_t pedantic = false;
132 //
133 Int_t i = 0;
134 //
135 if ( numinp > 1 ){
136 while ( i < numinp ){
137 if ( !strcmp(inps[i],"--version") ){
138 YodaProfilerInfo(true);
139 exit(0);
140 };
141 if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){
142
143 usage();
144 exit(0);
145 };
146 if ( !strcmp(inps[i],"-rawFile") ) {
147 if ( numinp-1 < i+1 ){
148 usage();
149 exit(1);
150 };
151 filerawname = (TString)inps[i+1];
152 };
153 if ( !strcmp(inps[i],"-yodaFile") || !strcmp(inps[i],"-L0File") ) {
154 if ( numinp-1 < i+1 ){
155 usage();
156 exit(1);
157 };
158 filerootname = (TString)inps[i+1];
159 if ( filerootname.IsDigit() ){
160 chewbacca = true;
161 runpieces = true;
162 };
163 };
164 if ( !strcmp(inps[i],"-remove") ) {
165 if ( numinp-1 < i+1 ){
166 usage();
167 exit(1);
168 };
169 remfile = (TString)inps[i+1];
170 remove = true;
171 };
172 if ( !strcmp(inps[i],"-cleanfrag") ) {
173 if ( numinp-1 < i+1 ){
174 usage();
175 exit(1);
176 };
177 fcleanfile = (TString)inps[i+1];
178 forceclean = true;
179 };
180 if ( !strcmp(inps[i],"-tag") ) {
181 if ( numinp-1 < i+1 ){
182 usage();
183 exit(1);
184 };
185 tag = (TString)inps[i+1];
186 };
187 if ( !strcmp(inps[i],"-validate") ) {
188 if ( numinp-1 < i+1 ){
189 usage();
190 exit(1);
191 };
192 validfile = (TString)inps[i+1];
193 validate = true;
194 };
195 if ( !strcmp(inps[i],"-gpamela") ) {
196 gpamela = true;
197 };
198 if ( !strcmp(inps[i],"-runpieces") ) {
199 runpieces = true;
200 };
201 if ( !strcmp(inps[i],"-static") ) {
202 staticp = true;
203 };
204 if ( !strcmp(inps[i],"-k") || !strcmp(inps[i],"--keepenv") ) {
205 keepenv = true;
206 };
207 if ( !strcmp(inps[i],"-autoboot") ) {
208 autoboot = true;
209 };
210 if ( !strcmp(inps[i],"-no-autoboot") ) {
211 autoboot = false;
212 };
213 if ( !strcmp(inps[i],"-boot") ) {
214 if ( numinp-1 < i+1 ){
215 usage();
216 exit(1);
217 };
218 boot = atoi(inps[i+1]);
219 };
220 if ( !strcmp(inps[i],"-checkfrom") ) {
221 if ( numinp-1 < i+1 ){
222 usage();
223 exit(1);
224 };
225 chfrom = atoi(inps[i+1]);
226 check = true;
227 };
228 if ( !strcmp(inps[i],"-checkto") ) {
229 if ( numinp-1 < i+1 ){
230 usage();
231 exit(1);
232 };
233 chto = atoi(inps[i+1]);
234 check = true;
235 };
236 if ( !strcmp(inps[i],"-tsync") ) {
237 if ( numinp-1 < i+1 ){
238 usage();
239 exit(1);
240 };
241 tsync = (UInt_t)atoll(inps[i+1]);
242 };
243 if ( !strcmp(inps[i],"-obt0") ) {
244 if ( numinp-1 < i+1 ){
245 usage();
246 exit(1);
247 };
248 obt0 = (UInt_t)atoll(inps[i+1]);
249 };
250 if ( !strcmp(inps[i],"-dworbit") ) {
251 if ( numinp-1 < i+1 ){
252 usage();
253 exit(1);
254 };
255 dwinput = (UInt_t)atoll(inps[i+1]);
256 };
257 if ( !strcmp(inps[i],"-clean") ) {
258 if ( numinp-1 < i+1 ){
259 usage();
260 exit(1);
261 };
262 olderthan = (Long64_t)atoll(inps[i+1]);
263 };
264 if ( !strcmp(inps[i],"-host") ) {
265 if ( numinp-1 < i+1 ){
266 usage();
267 exit(1);
268 };
269 host = (TString)inps[i+1];
270 };
271 if ( !strcmp(inps[i],"-user") ) {
272 if ( numinp-1 < i+1 ){
273 usage();
274 exit(1);
275 };
276 user = (TString)inps[i+1];
277 };
278 if ( !strcmp(inps[i],"-psw") ) {
279 if ( numinp-1 < i+1 ){
280 usage();
281 exit(1);
282 };
283 password = (TString)inps[i+1];
284 };
285 if ( !strcmp(inps[i],"-tle") ) {
286 if ( numinp-1 < i+1 ){
287 usage();
288 exit(1);
289 };
290 tlefilename = (TString)inps[i+1];
291 };
292 //
293 if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;
294 //
295 if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ) beverbose = false;
296 //
297 if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;
298 //
299 if ( !strcmp(inps[i],"-f") || !strcmp(inps[i],"-force") ) force = true;
300 //
301 if ( !strcmp(inps[i],"-p") || !strcmp(inps[i],"--pedantic") ) pedantic = true;
302 //
303 if ( !strcmp(inps[i],"-nofrag") ) nofrag = true;
304 //
305 if ( !strcmp(inps[i],"-check") ) check = true;
306 //
307 i++;
308 };
309 } else {
310 //
311 // no input parameters exit with error, we need at least the run id.
312 //
313 cout << "\n ERROR: NO INPUT PARAMETERS \n";
314 usage();
315 exit(1);
316 };
317
318 //
319 // If not in verbose mode redirect to /dev/null the stdout and stderr
320 //
321 if ( !beverbose ){
322 nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
323 dup2(nul,1);
324 dup2(nul,2);
325 };
326 //
327 if ( !strcmp(filerootname.Data(),"") ){
328 if ( (validate && !strcmp(validfile.Data(),"same")) ||
329 (remove && !strcmp(remfile.Data(),"same")) ||
330 (forceclean && !strcmp(fcleanfile.Data(),"same")) || force ){
331 printf("\n ERROR IN INPUT PARAMETERS \n");
332 usage();
333 exit(1);
334 };
335 } else {
336 if ( validate && !strcmp(validfile.Data(),"same") ) validfile = (TString)gSystem->BaseName(filerootname.Data());
337 if ( remove && !strcmp(remfile.Data(),"same") ) remfile = (TString)gSystem->BaseName(filerootname.Data());
338 if ( forceclean && !strcmp(fcleanfile.Data(),"same") ) fcleanfile = (TString)gSystem->BaseName(filerootname.Data());
339 };
340 //
341 if ( force ){
342 nofrag = true;
343 forceclean = true;
344 remove = true;
345 validate = true;
346 fcleanfile = (TString)gSystem->BaseName(filerootname.Data());
347 remfile = fcleanfile;
348 validfile = fcleanfile;
349 };
350 //
351 if ( chewbacca ){
352 //
353 // temporary settings
354 //
355 // pedantic = true;
356 // debug = true;
357 // end temporary settings
358 if ( debug ) printf("\n\n WOW! using the new software features \n\n");
359 };
360 //
361 const char *paml0 = gSystem->Getenv("PAM_L0");
362 const char *paml2 = gSystem->Getenv("PAM_L2");
363 const char *pamraw = gSystem->Getenv("PAM_RAW");
364 if ( !paml0 || !paml2 || !pamraw ){
365 printf(" WARNING: to use symbolic paths in DB you must set up PAM_L0, PAM_L2 and PAM_RAW env var!\n Using static paths\n");
366 staticp = true;
367 };
368 //
369 //
370 GL_TABLES *glt = new GL_TABLES(host,user,password);
371 //
372 if ( gpamela ){
373 // // -clean 0 -obt0 1 -tsync 1 -boot 1 -dworbit 1
374 // -clean 0 -obt0 1 -dworbit 1
375 if ( olderthan < 0LL ) olderthan = 0LL;
376 if ( !obt0 ) obt0 = 1;
377 // if ( !tsync ) tsync = 1;
378 // if ( !boot ) boot = 1;
379 if ( !dwinput ) dwinput = 1;
380 staticp = true;
381 autoboot = false;
382 };
383 //
384 if ( filerawname == "" && filerootname != "" ){
385 filerawname = "/not_given/"+(TString)gSystem->BaseName(filerootname.Data());
386 filerawname = filerawname.ReplaceAll(".root",5,".pam",4);
387 // printf("filerawname %s \n",filerawname.Data());
388 };
389 //
390 // Start:
391 TString message;
392 char *version = YodaProfilerInfo(false);
393 PamelaDBOperations *pamDB = 0;
394 UInt_t sizeofwar = 12;
395 UInt_t WAR[12];
396 memset(WAR, 0, sizeofwar*sizeof(UInt_t));
397 //
398 printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version);
399 try{
400 //
401 //-------------------------------------------------------------------------------------------
402 // Create pamDB object and open SQL connection
403 //-------------------------------------------------------------------------------------------
404 if ( beverbose ) printf(" 1 => Initialize and open SQL connection \n");
405 pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug,tlefilename,dwinput,staticp,gpamela,keepenv);
406 pamDB->CheckConnection();
407 pamDB->LockTables();
408 pamDB->OpenL0File(filerootname);
409 pamDB->SetTag(tag);
410 //-------------------------------------------------------------------------------------------
411 //
412 //
413 pamDB->SetNoFrag(nofrag);
414 pamDB->SetAutoBoot(autoboot);
415 pamDB->SetPedantic(pedantic);
416 //
417 if ( remove ){
418 //-------------------------------------------------------------------------------------------
419 // Remove a file and, on cascade, all that follows from the DB
420 //-------------------------------------------------------------------------------------------
421 if ( beverbose ) printf(" X => Remove file %s from DB \n",((TString)gSystem->BaseName(remfile)).Data());
422 WAR[11] = pamDB->removeFile((TString)gSystem->BaseName(remfile.Data()));
423 //-------------------------------------------------------------------------------------------
424 };
425 //
426 if( pamDB->InsertRaw() ){
427 //-------------------------------------------------------------------------------------------
428 //Insert a Raw file in GL_RAW
429 //-------------------------------------------------------------------------------------------
430 if ( beverbose ) printf(" 2 => Insert a RAW file in GL_RAW \n");
431 WAR[0] = pamDB->insertPamelaRawFile();
432 //-------------------------------------------------------------------------------------------
433 };
434 //
435 if( pamDB->InsertRoot() ){
436 //
437 if( !pamDB->InsertRaw() && !chewbacca ) printf("=> RAW file not inserted --- the DB might not ( yet ) be filled correctly \n");
438 pamDB->CheckFile();
439 //
440 // Set upper and lower limits (taken out from insertPamelaGL_TIMESYNC())
441 //
442 WAR[1] = pamDB->SetUpperLimits();
443 //-------------------------------------------------------------------------------------------
444 //Insert an entry in GL_TIMESYNC
445 //-------------------------------------------------------------------------------------------
446 if ( beverbose ) printf(" 3 => Insert an entry in GL_TIMESYNC \n");
447 WAR[1] += pamDB->insertPamelaGL_TIMESYNC();
448 //-------------------------------------------------------------------------------------------
449 //
450 //-------------------------------------------------------------------------------------------
451 //Update a single GL_RAW record with its BOOT_NUMBER
452 //-------------------------------------------------------------------------------------------
453 if ( beverbose ) printf(" 4 => Update a single GL_RAW record with its BOOT_NUMBER \n");
454 WAR[3] = pamDB->assignBOOT_NUMBER();
455 if ( WAR[3] && WAR[3] != 1 && WAR[3] != 8 ) throw -9;
456 //-------------------------------------------------------------------------------------------
457 //
458 //-------------------------------------------------------------------------------------------
459 //Insert unpack ROOT file in GL_ROOT
460 //-------------------------------------------------------------------------------------------
461 if ( beverbose ) printf(" 5 => Insert unpacked ROOT file in GL_ROOT \n");
462 WAR[2] = pamDB->insertPamelaRootFile();
463 //-------------------------------------------------------------------------------------------
464 //
465 //-------------------------------------------------------------------------------------------
466 //Insert in GL_RUN runs information records relative to a single unpack
467 //-------------------------------------------------------------------------------------------
468 if ( beverbose ) printf(" 6 => Scan physics and store runs in the GL_RUN table\n");
469 WAR[4] = pamDB->insertPamelaRUN();
470 //-------------------------------------------------------------------------------------------
471
472 //-------------------------------------------------------------------------------------------
473 //Insert in GL_CALO_CALIB calibration information records relative to a single unpack
474 //-------------------------------------------------------------------------------------------
475 if ( beverbose ) printf(" 7 => Insert calorimeter calibrations in the GL_CALO_CALIB table\n");
476 WAR[5] = pamDB->insertCALO_CALIB();
477 //-------------------------------------------------------------------------------------------
478
479 if ( !gpamela ){
480 //---------------------------------------------------------------------------------------------------------------------
481 //Insert in GL_CALOPULSE_CALIB calibration PULSE information records relative to a single unpack (only for real data!)
482 //---------------------------------------------------------------------------------------------------------------------
483 if ( beverbose ) printf(" 7b => Insert calorimeter pulse calibrations in the GL_CALOPULSE_CALIB table\n");
484 WAR[5] += pamDB->insertCALOPULSE_CALIB();
485 //-------------------------------------------------------------------------------------------
486 };
487
488 //-------------------------------------------------------------------------------------------
489 //Insert in GL_TRK_CALIB calibration information records relative to a single unpack
490 //-------------------------------------------------------------------------------------------
491 if ( beverbose ) printf(" 8 => Insert tracker calibrations in the GL_TRK_CALIB table\n");
492 WAR[6] = pamDB->insertTRK_CALIB();
493 //-------------------------------------------------------------------------------------------
494
495 //-------------------------------------------------------------------------------------------
496 //Insert in GL_S4_CALIB calibration information records relative to a single unpack
497 //-------------------------------------------------------------------------------------------
498 if ( beverbose ) printf(" 9 => Insert S4 calibrations in the GL_S4_CALIB table\n");
499 WAR[7] = pamDB->insertS4_CALIB();
500 //-------------------------------------------------------------------------------------------
501 };
502 //
503 if ( forceclean ){
504 //-------------------------------------------------------------------------------------------
505 //Clean the GL_RUN_FRAGMENTS for the given file
506 //-------------------------------------------------------------------------------------------
507 if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table for file %s \n",fcleanfile.Data());
508 WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS((TString)gSystem->BaseName(fcleanfile.Data()),runpieces);
509 };
510 //
511 //
512 if ( validate ){
513 //-------------------------------------------------------------------------------------------
514 //Validate runs
515 //-------------------------------------------------------------------------------------------
516 if ( beverbose ) printf(" 11 => Validate runs table for file %s \n",validfile.Data());
517 WAR[9] = pamDB->ValidateRuns((TString)gSystem->BaseName(validfile.Data()));
518 //-------------------------------------------------------------------------------------------
519 };
520 //
521 pamDB->CheckValidate(olderthan);
522 //
523 if( pamDB->Validate() ){
524 //-------------------------------------------------------------------------------------------
525 //Clean the GL_RUN_FRAGMENTS
526 //-------------------------------------------------------------------------------------------
527 if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table (earlier than %s) \n",pamDB->GetCleanTime() );
528 WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS(runpieces);
529 //-------------------------------------------------------------------------------------------
530 //-------------------------------------------------------------------------------------------
531 //Validate runs
532 //-------------------------------------------------------------------------------------------
533 if ( beverbose ) printf(" 11 => Validate runs (earlier than %s)\n",pamDB->GetCleanTime());
534 WAR[9] = pamDB->ValidateRuns();
535 //-------------------------------------------------------------------------------------------
536 };
537
538 if(! tlefilename.IsNull() ) {
539 //----------------------------------------------
540 //Populate GL_TLE table using the file provided
541 //----------------------------------------------
542 if ( beverbose ) printf(" 12 => Insert TLE elements in the GL_TLE table from file %s \n",tlefilename.Data());
543 WAR[10] = pamDB->populateTLE();
544 }
545
546 if ( check ){
547 //----------------------------------------------
548 //Check GL_RUN table consistency
549 //----------------------------------------------
550 if ( beverbose ) printf(" 13 => Check GL_RUN table consistency\n");
551 UInt_t ch = pamDB->Check(chfrom,chto);
552 if ( !ch ){
553 printf(" GL_RUN table seems ok!\n");
554 } else {
555 printf(" Problems found in the GL_RUN table!\n");
556 };
557 };
558
559 } catch (Int_t exc) {
560 signal = exc;
561 switch(exc){
562 case -1: message += " DB connection failure"; break;
563 case -2: message += " Connection failure"; break;
564 case -3: message += " Cannot determine the timesync, use the -tsync and -obt0 options to override"; break;
565 case -4: message += " Error querying DB"; break;
566 case -5: message += " Inconsistent OBT/pkt_num"; break;
567 case -6: message += " The file is not in the database"; break;
568 case -7: message += " Cannot open TLE file"; break;
569 case -8: message += " Event file is empty"; break;
570 case -9: message += " No VarDump no BOOT number, use the -boot option to override"; break;
571 case -10: message += " No results from DB"; break;
572 case -11: message += " Raw file not found"; break;
573 case -12: message += " Cannot open Level0 file"; break;
574 case -13: message += " No consistent OBT/PKT_NUM information"; break;
575 case -14: message += " Not supported yet: run with no events, no runtrailer, no runheader"; break;
576 case -15: message += " Not supported yet: run with no runheader at the beginning/end of file not recognized as run fragment"; break;
577 case -16: message += " No Physics tree in Level0 file"; break;
578 case -17: message += " No RunHeader tree in Level0 file"; break;
579 case -18: message += " No RunTrailer tree in Level0 file"; break;
580 case -19: message += " No Mcmd tree in Level0 file"; break;
581 case -20: message += " No VarDump tree in Level0 file"; break;
582 case -21: message += " No CalibCalPed tree in Level0 file"; break;
583 case -22: message += " No CalibTrk1 tree in Level0 file"; break;
584 case -23: message += " No CalibTrk2 tree in Level0 file"; break;
585 case -24: message += " No CalibS4 tree in Level0 file"; break;
586 case -25: message += " Cannot find the run just inserted"; break;
587 case -26: message += " Raw file not found looking for VarDump"; break;
588 case -27: message += " Cannot determine downlink orbit, wrong filename format?"; break;
589 case -28: message += " Cannot assign a RUN ID unique number!"; break;
590 case -29: message += " No VarDump and impossible to find a consistent BOOT number, use the -boot option to override"; break;
591 case -30: message += " Old database selected, no GL_CALOPULSE_CALIB table in the DB!"; break;
592 case -31: message += " No CalibCalPulse1 tree in Level0 file"; break;
593 case -32: message += " No CalibCalPulse2 tree in Level0 file"; break;
594 case -66: message += " PEDANTIC: REPETITION"; break;
595 case -67: message += " PEDANTIC: TIMESYNC ALREADY INSERTED"; break;
596 case -68: message += " PEDANTIC: NO TIMESYNC IN THE FILE"; break;
597 case -69: message += " PEDANTIC: RUN FRAGMENT ALREADY INSERTED"; break;
598 case -70: message += " PEDANTIC: RUN ALREADY INSERTED"; break;
599 case -71: message += " PEDANTIC: OVERLAPPING RUNS (FIRST)"; break;
600 case -72: message += " PEDANTIC: OVERLAPPING RUNS (LAST)"; break;
601 case -73: message += " PEDANTIC: CALO CALIB ALREADY INSERTED"; break;
602 case -74: message += " PEDANTIC: CALO CALIB REPEATED"; break;
603 case -75: message += " PEDANTIC: CALOPULSE1 CALIB ALREADY INSERTED"; break;
604 case -76: message += " PEDANTIC: CALOPULSE1 CALIB REPEATED"; break;
605 case -77: message += " PEDANTIC: CALOPULSE2 CALIB ALREADY INSERTED"; break;
606 case -78: message += " PEDANTIC: CALOPULSE2 CALIB REPEATED"; break;
607 case -79: message += " PEDANTIC: TRK1 CALIB REPEATED"; break;
608 case -80: message += " PEDANTIC: TRK CALIB ALREADY INSERTED"; break;
609 case -81: message += " PEDANTIC: S4 CALIB ALREADY INSERTED"; break;
610 case -82: message += " PEDANTIC: S4 CALIB REPEATED"; break;
611 case -83: message += " PEDANTIC: CLEANING ERROR, RUN ALREADY INSERTED IN THE GL_RUN TABLE"; break;
612 case -84: message += " CHEWBACCA: problems querying the ROOT_TABLE_MERGING table"; break;
613 case -85: message += " CHEWBACCA: problems querying the ROOT_TABLE table"; break;
614 case -86: message += " PEDANTIC: RUN ALREADY INSERTED IN THE GL_RUN TABLE"; break;
615 case -87: message += " PEDANTIC: THE RUN SHOULD HAVE ALREADY BEEN TREATED BY HANDLERUN()!"; break;
616 case -88: message += " PEDANTIC: INCONSISTENT PKT/OBT SEQUENCE"; break;
617 case -89: message += " PEDANTIC: CANNOT FIND PKT/OBT SEQUENCE IN THE POINTED FILE"; break;
618 case -90: message += " No PhysEndRun tree in the file"; break;
619 case -91: message += " PEDANTIC: Repetition of PhysEndRun data"; break;
620 case -100: message += " Cannot open calibration files to check repeated calibration"; break;
621 default: message += " Unidentified error"; break;
622 };
623 printf("\n");
624 printf(" ERROR (%i) %s \n",exc,message.Data());
625 printf("\n");
626 }
627 //
628 // warnings handlers
629 //
630 Bool_t printwarning = false;
631 message="";
632 for (UInt_t j=0; j<sizeofwar; j++){
633 if ( WAR[j] ){
634 printwarning = true;
635 //
636 if ( j == 0 ){ // insertPamelaRaw warnings
637 for (UInt_t bit=0; bit<32; bit++){
638 if ( WAR[j] & (1 << bit) ){
639 if ( bit == 0 ) message += "=> RAW file already inserted\n";
640 else message += "=> Unidentified insertPamelaRaw warning\n";
641 };
642 };
643 };
644 //
645 if ( j == 1 ){ // insertTimeSync warnings
646 for (UInt_t bit=0; bit<32; bit++){
647 if ( WAR[j] & (1 << bit) ){
648 if ( bit == 0 ) message += "=> TIMESYNC already inserted\n";
649 else if ( bit == 1 ) message += "=> No mcmd timesync in the file\n";
650 else if ( bit == 2 ) message += "=> No runheaders in the file\n";
651 else if ( bit == 3 ) message += "=> No runtrailers in the file\n";
652 else if ( bit == 4 ) message += "=> No mcmd inclination in the file\n";
653 else if ( bit == 5 ) message += "=> Inconsistent PKT/OBT sequence\n";
654 else if ( bit == 6 ) message += "=> No physics events in the file\n";
655 else if ( bit == 7 ) message += "=> Less than 2 physics events in the file\n";
656 else message += "=> Unidentified insertTimeSync warning\n";
657 };
658 };
659 };
660 //
661 if ( j == 2 ){ // insertPamelaRoot warnings
662 for (UInt_t bit=0; bit<32; bit++){
663 if ( WAR[j] & (1 << bit) ){
664 if ( bit == 0 ) message += "=> ROOT file already inserted\n";
665 else message += "=> Unidentified insertPamelaRoot warning\n";
666 };
667 };
668 };
669 //
670 if ( j == 3 ){ // assignBOOTnumber warnings
671 for (UInt_t bit=0; bit<32; bit++){
672 if ( WAR[j] & (1 << bit) ){
673 if ( bit == 0 ) message += "=> BOOT number already inserted\n";//
674 else if ( bit == 1 ) message += "=> VarDump event tree is empty, use the -boot option to override\n";//
675 else if ( bit == 2 ) message += "=> No BOOT number in VarDump(!), use the -boot option to override\n";//
676 else if ( bit == 3 ) message += "=> No VarDump! autoboot option used\n";//
677 else if ( bit == 4 ) message += "=> The file is not in the database looking for VarDump, use the -boot option to override\n";//
678 else message += "=> Unidentified assignBOOTnumber warning\n";
679 };
680 };
681 };
682 //
683 if ( j == 4 ){ // insertPamelaRUN
684 for (UInt_t bit=0; bit<32; bit++){
685 if ( WAR[j] & (1 << bit) ){
686 if ( bit == 0 ) message += "=> Inconsistent PKT/OBT sequence\n";
687 else if ( bit == 1 ) message += "=> No physics events in the file\n";
688 else if ( bit == 2 ) message += "=> Less than 2 physics events in the file\n";
689 else if ( bit == 3 ) message += "=> Not supported yet: run with no events, no runtrailer, no runheader\n";
690 else if ( bit == 4 ) message += "=> File with no events, no runtrailers, no runheaders\n";
691 else message += "=> Unidentified insertPamelaRun warning\n";
692 };
693 };
694 };
695 //
696 if ( j == 5 ){ // insertCALO_CALIB
697 for (UInt_t bit=0; bit<32; bit++){
698 if ( WAR[j] & (1 << bit) ){
699 if ( bit == 0 ) message += "=> No calorimeter calibrations in the file\n";
700 else message += "=> Unidentified insertCaloCalib warning\n";
701 };
702 };
703 };
704 //
705 //
706 if ( j == 6 ){ // insertTRACKER_CALIB
707 for (UInt_t bit=0; bit<32; bit++){
708 if ( WAR[j] & (1 << bit) ){
709 if ( bit == 0 ) message += "=> No tracker calibrations in the file\n";
710 else message += "=> Unidentified insertTrkCalib warning\n";
711 };
712 };
713 };
714 //
715 //
716 if ( j == 7 ){ // insertS4_CALIB
717 for (UInt_t bit=0; bit<32; bit++){
718 if ( WAR[j] & (1 << bit) ){
719 if ( bit == 0 ) message += "=> No s4 calibrations in the file\n";
720 else message += "=> Unidentified insertS4calib warning\n";
721 };
722 };
723 };
724 //
725 //
726 if ( j == 8 ){ // CleanGL_RUN_FRAGMENTS
727 for (UInt_t bit=0; bit<32; bit++){
728 if ( WAR[j] & (1 << bit) ){
729 if ( bit == 0 ) message += "=> Skip the GL_RUN_FRAGMENTS table cleaning\n";
730 if ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
731 else message += "=> Unidentified CleanGL_RUN_FRAGMENTS warning\n";
732 };
733 };
734 };
735 //
736 if ( j == 9 ){ // ValidateRuns
737 for (UInt_t bit=0; bit<32; bit++){
738 if ( WAR[j] & (1 << bit) ){
739 if ( bit == 0 ) message += "=> Skip the run validation \n";
740 if ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
741 else message += "=> Unidentified ValidateRuns warning\n";
742 };
743 };
744 };
745 //
746 if ( j == 10 ){ // populateTLE
747 for (UInt_t bit=0; bit<32; bit++){
748 if ( WAR[j] & (1 << bit) ){
749 if ( bit == 0 ) message += "=> TLE insertion failed\n";
750 if ( bit == 1 ) message += "=> No new TLE available\n";
751 else message += "=> Unidentified populateTle warning\n";
752 };
753 };
754 };
755 //
756 if ( j == 11 ){ // removeFile
757 for (UInt_t bit=0; bit<32; bit++){
758 if ( WAR[j] & (1 << bit) ){
759 if ( bit == 0 ) message += "=> No file to delete from DB \n";
760 else message += "=> Unidentified populateTle warning\n";
761 };
762 };
763 };
764 };
765 };
766 //
767 if ( printwarning ){
768 printf("\n");
769 printf(" WARNING(s):\n%s\n",message.Data());
770 printf("\n");
771 if ( !signal ) signal = 1;
772 };
773 //
774 //---------------------------------------------------------------------------------------
775 // Close and exit
776 //---------------------------------------------------------------------------------------
777 if ( beverbose ) printf(" 13 => Free objects and close SQL connection \n");
778 pamDB->UnLockTables();
779 pamDB->Close();
780 //
781 if ( debug ) printf(" Total number of queries through GLTABLES: %u \n",glt->GetNqueries());
782 delete glt;
783 //
784 printf("\n");
785 printf(" Finished, exiting...\n");
786 printf("\n");
787 //
788 // Close redirection if the case.
789 //
790 if ( !beverbose ) close(nul);
791 //
792 exit(signal);
793 //
794 }

  ViewVC Help
Powered by ViewVC 1.1.23