/[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.5 - (show annotations) (download)
Mon Dec 22 10:38:15 2008 UTC (15 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r00
Changes since 1.4: +11 -4 lines
New 'special files' in the db, yp defaults changed, patch to recover boot_number

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

  ViewVC Help
Powered by ViewVC 1.1.23