/[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.6 - (show annotations) (download)
Mon Jan 12 18:23:38 2009 UTC (15 years, 10 months ago) by mocchiut
Branch: MAIN
Changes since 1.5: +6 -0 lines
Several small bugs fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23