/[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.11 - (show annotations) (download)
Mon Dec 28 08:39:25 2009 UTC (14 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v9r00, v9r01
Changes since 1.10: +1 -0 lines
Bug in YP gpamela conflict between processes fixed, Q2TH ROOT 5.26 compat bug 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 pedantic = false;
395 };
396 //
397 if ( filerawname == "" && filerootname != "" ){
398 filerawname = "/not_given/"+(TString)gSystem->BaseName(filerootname.Data());
399 filerawname = filerawname.ReplaceAll(".root",5,".pam",4);
400 // printf("filerawname %s \n",filerawname.Data());
401 };
402 //
403 // Start:
404 TString message;
405 char *version = YodaProfilerInfo(false);
406 PamelaDBOperations *pamDB = 0;
407 UInt_t sizeofwar = 12;
408 UInt_t WAR[12];
409 memset(WAR, 0, sizeofwar*sizeof(UInt_t));
410 //
411 printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version);
412 try{
413 //
414 //-------------------------------------------------------------------------------------------
415 // Create pamDB object and open SQL connection
416 //-------------------------------------------------------------------------------------------
417 if ( beverbose ) printf(" 1 => Initialize and open SQL connection \n");
418 pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug,tlefilename,dwinput,staticp,gpamela,keepenv);
419 pamDB->CheckConnection();
420 pamDB->LockTables();
421 if ( !pamDB->IsChewbacca() ) pamDB->NotChewbacca(boot,tsync,obt0,gpamela);
422 if ( filerootname != "" ) pamDB->OpenL0File(filerootname);
423 pamDB->SetTag(tag);
424 //-------------------------------------------------------------------------------------------
425 //
426 //
427 pamDB->SetNoFrag(nofrag);
428 pamDB->SetAutoBoot(autoboot);
429 pamDB->SetPedantic(pedantic);
430 pamDB->SetRelaxed(relaxed);
431 //
432 if ( remove ){
433 //-------------------------------------------------------------------------------------------
434 // Remove a file and, on cascade, all that follows from the DB
435 //-------------------------------------------------------------------------------------------
436 if ( beverbose ) printf(" X => Remove file %s from DB \n",((TString)gSystem->BaseName(remfile)).Data());
437 WAR[11] = pamDB->removeFile((TString)gSystem->BaseName(remfile.Data()));
438 //-------------------------------------------------------------------------------------------
439 };
440 //
441 if( pamDB->InsertRaw() ){
442 //-------------------------------------------------------------------------------------------
443 //Insert a Raw file in GL_RAW
444 //-------------------------------------------------------------------------------------------
445 if ( beverbose ) printf(" 2 => Insert a RAW file in GL_RAW \n");
446 WAR[0] = pamDB->insertPamelaRawFile();
447 //-------------------------------------------------------------------------------------------
448 };
449 //
450 if( pamDB->InsertRoot() ){
451 //
452 if( !pamDB->InsertRaw() && !chewbacca ) printf("=> RAW file not inserted --- the DB might not ( yet ) be filled correctly \n");
453 pamDB->CheckFile();
454 //
455 // Set upper and lower limits (taken out from insertPamelaGL_TIMESYNC())
456 //
457 WAR[1] = pamDB->SetUpperLimits();
458 //-------------------------------------------------------------------------------------------
459 //Insert an entry in GL_TIMESYNC
460 //-------------------------------------------------------------------------------------------
461 if ( beverbose ) printf(" 3 => Insert an entry in GL_TIMESYNC \n");
462 WAR[1] += pamDB->insertPamelaGL_TIMESYNC();
463 //-------------------------------------------------------------------------------------------
464 //
465 //-------------------------------------------------------------------------------------------
466 //Update a single GL_RAW record with its BOOT_NUMBER
467 //-------------------------------------------------------------------------------------------
468 if ( beverbose ) printf(" 4 => Update a single GL_RAW record with its BOOT_NUMBER \n");
469 WAR[3] = pamDB->assignBOOT_NUMBER();
470 if ( WAR[3] && WAR[3] != 1 && WAR[3] != 8 ) throw -9;
471 //-------------------------------------------------------------------------------------------
472 //
473 //-------------------------------------------------------------------------------------------
474 //Insert unpack ROOT file in GL_ROOT
475 //-------------------------------------------------------------------------------------------
476 if ( beverbose ) printf(" 5 => Insert unpacked ROOT file in GL_ROOT \n");
477 WAR[2] = pamDB->insertPamelaRootFile();
478 //-------------------------------------------------------------------------------------------
479 //
480 //-------------------------------------------------------------------------------------------
481 //Insert in GL_RUN runs information records relative to a single unpack
482 //-------------------------------------------------------------------------------------------
483 if ( beverbose ) printf(" 6 => Scan physics and store runs in the GL_RUN table\n");
484 WAR[4] = pamDB->insertPamelaRUN();
485 //-------------------------------------------------------------------------------------------
486
487 //-------------------------------------------------------------------------------------------
488 //Insert in GL_CALO_CALIB calibration information records relative to a single unpack
489 //-------------------------------------------------------------------------------------------
490 if ( beverbose ) printf(" 7 => Insert calorimeter calibrations in the GL_CALO_CALIB table\n");
491 WAR[5] = pamDB->insertCALO_CALIB();
492 //-------------------------------------------------------------------------------------------
493
494 if ( !gpamela ){
495 //---------------------------------------------------------------------------------------------------------------------
496 //Insert in GL_CALOPULSE_CALIB calibration PULSE information records relative to a single unpack (only for real data!)
497 //---------------------------------------------------------------------------------------------------------------------
498 if ( beverbose ) printf(" 7b => Insert calorimeter pulse calibrations in the GL_CALOPULSE_CALIB table\n");
499 WAR[5] += pamDB->insertCALOPULSE_CALIB();
500 //-------------------------------------------------------------------------------------------
501 };
502
503 //-------------------------------------------------------------------------------------------
504 //Insert in GL_TRK_CALIB calibration information records relative to a single unpack
505 //-------------------------------------------------------------------------------------------
506 if ( beverbose ) printf(" 8 => Insert tracker calibrations in the GL_TRK_CALIB table\n");
507 WAR[6] = pamDB->insertTRK_CALIB();
508 //-------------------------------------------------------------------------------------------
509
510 //-------------------------------------------------------------------------------------------
511 //Insert in GL_S4_CALIB calibration information records relative to a single unpack
512 //-------------------------------------------------------------------------------------------
513 if ( beverbose ) printf(" 9 => Insert S4 calibrations in the GL_S4_CALIB table\n");
514 WAR[7] = pamDB->insertS4_CALIB();
515 //-------------------------------------------------------------------------------------------
516 };
517 //
518 if ( forceclean ){
519 //-------------------------------------------------------------------------------------------
520 //Clean the GL_RUN_FRAGMENTS for the given file
521 //-------------------------------------------------------------------------------------------
522 if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table for file %s \n",fcleanfile.Data());
523 WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS((TString)gSystem->BaseName(fcleanfile.Data()),runpieces);
524 };
525 //
526 //
527 if ( validate ){
528 //-------------------------------------------------------------------------------------------
529 //Validate runs
530 //-------------------------------------------------------------------------------------------
531 if ( beverbose ) printf(" 11 => Validate runs table for file %s \n",validfile.Data());
532 WAR[9] = pamDB->ValidateRuns((TString)gSystem->BaseName(validfile.Data()));
533 //-------------------------------------------------------------------------------------------
534 };
535 //
536 pamDB->CheckValidate(olderthan);
537 //
538 if( pamDB->Validate() ){
539 //-------------------------------------------------------------------------------------------
540 //Clean the GL_RUN_FRAGMENTS
541 //-------------------------------------------------------------------------------------------
542 if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table (earlier than %s) \n",pamDB->GetCleanTime() );
543 WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS(runpieces);
544 //-------------------------------------------------------------------------------------------
545 //-------------------------------------------------------------------------------------------
546 //Validate runs
547 //-------------------------------------------------------------------------------------------
548 if ( beverbose ) printf(" 11 => Validate runs (earlier than %s)\n",pamDB->GetCleanTime());
549 WAR[9] = pamDB->ValidateRuns();
550 //-------------------------------------------------------------------------------------------
551 };
552
553 if(! tlefilename.IsNull() ) {
554 //----------------------------------------------
555 //Populate GL_TLE table using the file provided
556 //----------------------------------------------
557 if ( beverbose ) printf(" 12 => Insert TLE elements in the GL_TLE table from file %s \n",tlefilename.Data());
558 WAR[10] = pamDB->populateTLE();
559 }
560
561 if ( check ){
562 //----------------------------------------------
563 //Check GL_RUN table consistency
564 //----------------------------------------------
565 if ( beverbose ) printf(" 13 => Check GL_RUN table consistency\n");
566 UInt_t ch = pamDB->Check(chfrom,chto);
567 if ( !ch ){
568 printf(" GL_RUN table seems ok!\n");
569 } else {
570 printf(" Problems found in the GL_RUN table!\n");
571 };
572 };
573
574 } catch (Int_t exc) {
575 // signal = exc;
576 signal = 1;
577 switch(exc){
578 case -1: message += " DB connection failure"; break;
579 case -2: message += " Connection failure"; break;
580 case -3: message += " Cannot determine the timesync, use the -tsync and -obt0 options to override"; break;
581 case -4: message += " Error querying DB"; break;
582 case -5: message += " Inconsistent OBT/pkt_num"; break;
583 case -6: message += " The file is not in the database"; break;
584 case -7: message += " Cannot open TLE file"; break;
585 case -8: message += " Event file is empty"; break;
586 case -9: message += " No VarDump no BOOT number, use the -boot option to override"; break;
587 case -10: message += " No results from DB"; break;
588 case -11: message += " Raw file not found"; break;
589 case -12: message += " Cannot open Level0 file"; break;
590 case -13: message += " No consistent OBT/PKT_NUM information"; break;
591 case -14: message += " Not supported yet: run with no events, no runtrailer, no runheader"; break;
592 case -15: message += " Not supported yet: run with no runheader at the beginning/end of file not recognized as run fragment"; break;
593 case -16: message += " No Physics tree in Level0 file"; break;
594 case -17: message += " No RunHeader tree in Level0 file"; break;
595 case -18: message += " No RunTrailer tree in Level0 file"; break;
596 case -19: message += " No Mcmd tree in Level0 file"; break;
597 case -20: message += " No VarDump tree in Level0 file"; break;
598 case -21: message += " No CalibCalPed tree in Level0 file"; break;
599 case -22: message += " No CalibTrk1 tree in Level0 file"; break;
600 case -23: message += " No CalibTrk2 tree in Level0 file"; break;
601 case -24: message += " No CalibS4 tree in Level0 file"; break;
602 case -25: message += " Cannot find the run just inserted"; break;
603 case -26: message += " Raw file not found looking for VarDump"; break;
604 case -27: message += " Cannot determine downlink orbit, wrong filename format?"; break;
605 case -28: message += " Cannot assign a RUN ID unique number!"; break;
606 case -29: message += " No VarDump and impossible to find a consistent BOOT number, use the -boot option to override"; break;
607 case -30: message += " Old database selected, no GL_CALOPULSE_CALIB table in the DB!"; break;
608 case -31: message += " No CalibCalPulse1 tree in Level0 file"; break;
609 case -32: message += " No CalibCalPulse2 tree in Level0 file"; break;
610 case -66: message += " PEDANTIC: REPETITION"; break;
611 case -67: message += " PEDANTIC: TIMESYNC ALREADY INSERTED"; break;
612 case -68: message += " PEDANTIC: NO TIMESYNC IN THE FILE"; break;
613 case -69: message += " PEDANTIC: RUN FRAGMENT ALREADY INSERTED"; break;
614 case -70: message += " PEDANTIC: RUN ALREADY INSERTED"; break;
615 case -71: message += " PEDANTIC: OVERLAPPING RUNS (FIRST)"; break;
616 case -72: message += " PEDANTIC: OVERLAPPING RUNS (LAST)"; break;
617 case -73: message += " PEDANTIC: CALO CALIB ALREADY INSERTED"; break;
618 case -74: message += " PEDANTIC: CALO CALIB REPEATED"; break;
619 case -75: message += " PEDANTIC: CALOPULSE1 CALIB ALREADY INSERTED"; break;
620 case -76: message += " PEDANTIC: CALOPULSE1 CALIB REPEATED"; break;
621 case -77: message += " PEDANTIC: CALOPULSE2 CALIB ALREADY INSERTED"; break;
622 case -78: message += " PEDANTIC: CALOPULSE2 CALIB REPEATED"; break;
623 case -79: message += " PEDANTIC: TRK1 CALIB REPEATED"; break;
624 case -80: message += " PEDANTIC: TRK CALIB ALREADY INSERTED"; break;
625 case -81: message += " PEDANTIC: S4 CALIB ALREADY INSERTED"; break;
626 case -82: message += " PEDANTIC: S4 CALIB REPEATED"; break;
627 case -83: message += " PEDANTIC: CLEANING ERROR, RUN ALREADY INSERTED IN THE GL_RUN TABLE"; break;
628 case -84: message += " CHEWBACCA: problems querying the ROOT_TABLE_MERGING table"; break;
629 case -85: message += " CHEWBACCA: problems querying the ROOT_TABLE table"; break;
630 case -86: message += " PEDANTIC: RUN ALREADY INSERTED IN THE GL_RUN TABLE"; break;
631 case -87: message += " PEDANTIC: THE RUN SHOULD HAVE ALREADY BEEN TREATED BY HANDLERUN()!"; break;
632 case -88: message += " PEDANTIC: INCONSISTENT PKT/OBT SEQUENCE"; break;
633 case -89: message += " PEDANTIC: CANNOT FIND PKT/OBT SEQUENCE IN THE POINTED FILE"; break;
634 case -90: message += " No PhysEndRun tree in the file"; break;
635 case -91: message += " PEDANTIC: Repetition of PhysEndRun data"; break;
636 case -92: message += " CHEWBACCA: cannot find Resurs time zero used by chewbacca in the GL_RESURS_OFFSET table"; break;
637 case -100: message += " Cannot open calibration files to check repeated calibration"; break;
638 default: message += " Unidentified error"; break;
639 };
640 printf("\n");
641 printf(" ERROR (%i) %s \n",exc,message.Data());
642 printf("\n");
643 }
644 //
645 // warnings handlers
646 //
647 Bool_t printwarning = false;
648 message="";
649 for (UInt_t j=0; j<sizeofwar; j++){
650 if ( WAR[j] ){
651 printwarning = true;
652 //
653 if ( j == 0 ){ // insertPamelaRaw warnings
654 for (UInt_t bit=0; bit<32; bit++){
655 if ( WAR[j] & (1 << bit) ){
656 if ( bit == 0 ) message += "=> RAW file already inserted\n";
657 else message += "=> Unidentified insertPamelaRaw warning\n";
658 };
659 };
660 };
661 //
662 if ( j == 1 ){ // insertTimeSync warnings
663 for (UInt_t bit=0; bit<32; bit++){
664 if ( WAR[j] & (1 << bit) ){
665 if ( bit == 0 ) message += "=> TIMESYNC already inserted\n";
666 else if ( bit == 1 ) message += "=> No mcmd timesync in the file\n";
667 else if ( bit == 2 ) message += "=> No runheaders in the file\n";
668 else if ( bit == 3 ) message += "=> No runtrailers in the file\n";
669 else if ( bit == 4 ) message += "=> No mcmd inclination in the file\n";
670 else if ( bit == 5 ) message += "=> Inconsistent PKT/OBT sequence\n";
671 else if ( bit == 6 ) message += "=> No physics events in the file\n";
672 else if ( bit == 7 ) message += "=> Less than 2 physics events in the file\n";
673 else message += "=> Unidentified insertTimeSync warning\n";
674 };
675 };
676 };
677 //
678 if ( j == 2 ){ // insertPamelaRoot warnings
679 for (UInt_t bit=0; bit<32; bit++){
680 if ( WAR[j] & (1 << bit) ){
681 if ( bit == 0 ) message += "=> ROOT file already inserted\n";
682 else message += "=> Unidentified insertPamelaRoot warning\n";
683 };
684 };
685 };
686 //
687 if ( j == 3 ){ // assignBOOTnumber warnings
688 for (UInt_t bit=0; bit<32; bit++){
689 if ( WAR[j] & (1 << bit) ){
690 if ( bit == 0 ) message += "=> BOOT number already inserted\n";//
691 else if ( bit == 1 ) message += "=> VarDump event tree is empty, use the -boot option to override\n";//
692 else if ( bit == 2 ) message += "=> No BOOT number in VarDump(!), use the -boot option to override\n";//
693 else if ( bit == 3 ) message += "=> No VarDump! autoboot option used\n";//
694 else if ( bit == 4 ) message += "=> The file is not in the database looking for VarDump, use the -boot option to override\n";//
695 else message += "=> Unidentified assignBOOTnumber warning\n";
696 };
697 };
698 };
699 //
700 if ( j == 4 ){ // insertPamelaRUN
701 for (UInt_t bit=0; bit<32; bit++){
702 if ( WAR[j] & (1 << bit) ){
703 if ( bit == 0 ) message += "=> Inconsistent PKT/OBT sequence\n";
704 else if ( bit == 1 ) message += "=> No physics events in the file\n";
705 else if ( bit == 2 ) message += "=> Less than 2 physics events in the file\n";
706 else if ( bit == 3 ) message += "=> Not supported yet: run with no events, no runtrailer, no runheader\n";
707 else if ( bit == 4 ) message += "=> File with no events, no runtrailers, no runheaders\n";
708 else message += "=> Unidentified insertPamelaRun warning\n";
709 };
710 };
711 };
712 //
713 if ( j == 5 ){ // insertCALO_CALIB
714 for (UInt_t bit=0; bit<32; bit++){
715 if ( WAR[j] & (1 << bit) ){
716 if ( bit == 0 ) message += "=> No calorimeter calibrations in the file\n";
717 else message += "=> Unidentified insertCaloCalib warning\n";
718 };
719 };
720 };
721 //
722 //
723 if ( j == 6 ){ // insertTRACKER_CALIB
724 for (UInt_t bit=0; bit<32; bit++){
725 if ( WAR[j] & (1 << bit) ){
726 if ( bit == 0 ) message += "=> No tracker calibrations in the file\n";
727 else message += "=> Unidentified insertTrkCalib warning\n";
728 };
729 };
730 };
731 //
732 //
733 if ( j == 7 ){ // insertS4_CALIB
734 for (UInt_t bit=0; bit<32; bit++){
735 if ( WAR[j] & (1 << bit) ){
736 if ( bit == 0 ) message += "=> No s4 calibrations in the file\n";
737 else message += "=> Unidentified insertS4calib warning\n";
738 };
739 };
740 };
741 //
742 //
743 if ( j == 8 ){ // CleanGL_RUN_FRAGMENTS
744 for (UInt_t bit=0; bit<32; bit++){
745 if ( WAR[j] & (1 << bit) ){
746 if ( bit == 0 ) message += "=> Skip the GL_RUN_FRAGMENTS table cleaning\n";
747 if ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
748 else message += "=> Unidentified CleanGL_RUN_FRAGMENTS warning\n";
749 };
750 };
751 };
752 //
753 if ( j == 9 ){ // ValidateRuns
754 for (UInt_t bit=0; bit<32; bit++){
755 if ( WAR[j] & (1 << bit) ){
756 if ( bit == 0 ) message += "=> Skip the run validation \n";
757 if ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
758 else message += "=> Unidentified ValidateRuns warning\n";
759 };
760 };
761 };
762 //
763 if ( j == 10 ){ // populateTLE
764 for (UInt_t bit=0; bit<32; bit++){
765 if ( WAR[j] & (1 << bit) ){
766 if ( bit == 0 ) message += "=> TLE insertion failed\n";
767 if ( bit == 1 ) message += "=> No new TLE available\n";
768 else message += "=> Unidentified populateTle warning\n";
769 };
770 };
771 };
772 //
773 if ( j == 11 ){ // removeFile
774 for (UInt_t bit=0; bit<32; bit++){
775 if ( WAR[j] & (1 << bit) ){
776 if ( bit == 0 ) message += "=> No file to delete from DB \n";
777 else message += "=> Unidentified populateTle warning\n";
778 };
779 };
780 };
781 };
782 };
783 //
784 if ( printwarning ){
785 printf("\n");
786 printf(" WARNING(s):\n%s\n",message.Data());
787 printf("\n");
788 // if ( !signal ) signal = 1;
789 if ( !signal ) signal = 255;
790 };
791 //
792 //---------------------------------------------------------------------------------------
793 // Close and exit
794 //---------------------------------------------------------------------------------------
795 if ( beverbose ) printf(" 13 => Free objects and close SQL connection \n");
796 pamDB->UnLockTables();
797 pamDB->Close();
798 //
799 if ( debug ) printf(" Total number of queries through GLTABLES: %u \n",glt->GetNqueries());
800 delete glt;
801 //
802 printf("\n");
803 printf(" Finished, exiting...\n");
804 printf("\n");
805 //
806 // Close redirection if the case.
807 //
808 if ( !beverbose ) close(nul);
809 //
810 exit(signal);
811 //
812 }

  ViewVC Help
Powered by ViewVC 1.1.23