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

Annotation of /chewbacca/YodaProfiler/src/YodaProfiler.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download)
Wed Dec 23 07:22:04 2009 UTC (14 years, 11 months ago) by mocchiut
Branch: MAIN
Changes since 1.9: +1 -0 lines
-np option is now set by default by gpamela flag

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

  ViewVC Help
Powered by ViewVC 1.1.23