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

Diff of /YodaProfiler/src/YodaProfiler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by mocchiut, Fri Oct 20 11:11:12 2006 UTC revision 1.13 by mocchiut, Mon Nov 27 14:25:36 2006 UTC
# Line 24  void usage(){ Line 24  void usage(){
24    printf("\n -s | --silent   print nothing on STDOUT\n");    printf("\n -s | --silent   print nothing on STDOUT\n");
25    printf("\n -g | --debug    be very verbose [default: no]\n");    printf("\n -g | --debug    be very verbose [default: no]\n");
26    printf("\n -boot number    CPU boot number [default = taken from VarDump]\n");    printf("\n -boot number    CPU boot number [default = taken from VarDump]\n");
27      printf("\n -autoboot       if no VarDump found try to determine the BOOT number\n");
28      printf("\n                 looking at timesync [default]\n");
29      printf("\n -no-autoboot    disable previous check\n");
30    printf("\n -tsync number   timesync (s) [default = taken from data]\n");    printf("\n -tsync number   timesync (s) [default = taken from data]\n");
31    printf("\n -obt0 number    obt at timesync (ms) [default = taken from data]\n");    printf("\n -obt0 number    obt at timesync (ms) [default = taken from data]\n");
32    printf("\n -clean number   number in seconds after which the fragment table\n");    printf("\n -clean number   number in seconds after which the fragment table\n");
33    printf("\n                 can be cleaned and runs validated [default = -1 do not clean],\n");    printf("\n                 can be cleaned and runs validated [default = -1 do not clean],\n");
34    printf("\n                 if 0 force cleaning immediatly, if negative do not clean\n");    printf("\n                 if 0 force cleaning immediatly, if negative do not clean\n");
35    //
36      printf("\n -remove file    remove file and all related runs and calibrations from DB\n");
37      printf("\n                 file must be the YODA filename (full path is not needed)\n");
38      printf("\n                 'same' can be used if in conjuction with -yodaFile\n");
39      printf("\n -validate file  validates runs between the two closest calibration to file \n");
40      printf("\n                 not belonging to file itself. File must be the YODA filename\n");
41      printf("\n                 'same' can be used if in conjuction with -yodaFile\n");
42      printf("\n -cleanfrag file clean run fragments for file only\n");
43      printf("\n                 File must be the YODA filename\n");
44      printf("\n                 'same' can be used if in conjuction with -yodaFile\n");
45      printf("\n -nofrag         do not leave runs in the fragment table and look for fragments\n");
46      printf("\n                 in the GL_RUN table.\n");
47      printf("\n -force          to be used to reprocess a file or to process a file\n");
48      printf("\n                 when already validated the surroundings, it is equivalent to:\n");
49      printf("\n                 -remove same -validate same -cleanfrag same -nofrag\n");
50    //      
51    printf("\n -host           name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");    printf("\n -host           name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
52    printf("\n -user           username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n");    printf("\n -user           username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n");
53    printf("\n -psw            password for the DB [default = $PAM_DBPSW or \"\"]\n");    printf("\n -psw            password for the DB [default = $PAM_DBPSW or \"\"]\n");
# Line 47  int main(int numinp, char *inps[]){ Line 66  int main(int numinp, char *inps[]){
66    UInt_t boot = 0;    UInt_t boot = 0;
67    UInt_t tsync = 0;    UInt_t tsync = 0;
68    UInt_t obt0 = 0;    UInt_t obt0 = 0;
69    //  Long64_t olderthan = 864000LL;    Long64_t olderthan = -1LL;  
   Long64_t olderthan = -1LL;  
     
70    //    //
71    //    //
72    TString filerawname  = "";    TString filerawname  = "";
# Line 60  int main(int numinp, char *inps[]){ Line 77  int main(int numinp, char *inps[]){
77    TString password = "";    TString password = "";
78    //    //
79    TString tlefilename = "";    TString tlefilename = "";
80      //
81    const char *pamdbhost = gSystem->Getenv("PAM_DBHOST");    const char *pamdbhost = gSystem->Getenv("PAM_DBHOST");
82    const char *pamdbuser = gSystem->Getenv("PAM_DBUSER");    const char *pamdbuser = gSystem->Getenv("PAM_DBUSER");
83    const char *pamdbpsw = gSystem->Getenv("PAM_DBPSW");    const char *pamdbpsw = gSystem->Getenv("PAM_DBPSW");
# Line 74  int main(int numinp, char *inps[]){ Line 91  int main(int numinp, char *inps[]){
91    //        //    
92    Bool_t beverbose = true;    Bool_t beverbose = true;
93    Bool_t debug = false;    Bool_t debug = false;
94      Bool_t autoboot = true;
95      //
96      Bool_t remove = false;
97      TString remfile = "";
98      //
99      Bool_t forceclean = false;
100      TString fcleanfile = "";
101      //
102      Bool_t validate = false;
103      TString validfile = "";
104      //
105      Bool_t nofrag = false;
106      //
107      Bool_t force = false;
108    //    //
109    Int_t i = 0;    Int_t i = 0;
110    //    //
# Line 102  int main(int numinp, char *inps[]){ Line 133  int main(int numinp, char *inps[]){
133          };          };
134          filerootname = (TString)inps[i+1];                filerootname = (TString)inps[i+1];      
135        };        };
136          if ( !strcmp(inps[i],"-remove") ) {
137            if ( numinp-1 < i+1 ){
138              usage();
139              exit(1);
140            };
141            remfile = (TString)inps[i+1];  
142            remove = true;
143          };
144         if ( !strcmp(inps[i],"-cleanfrag") ) {
145            if ( numinp-1 < i+1 ){
146              usage();
147              exit(1);
148            };
149            fcleanfile = (TString)inps[i+1];        
150            forceclean = true;
151          };
152         if ( !strcmp(inps[i],"-validate") ) {
153            if ( numinp-1 < i+1 ){
154              usage();
155              exit(1);
156            };
157            validfile = (TString)inps[i+1];
158            validate = true;
159          };
160          if ( !strcmp(inps[i],"-autoboot") ) {
161            autoboot = true;
162          };
163          if ( !strcmp(inps[i],"-no-autoboot") ) {
164            autoboot = false;
165          };
166        if ( !strcmp(inps[i],"-boot") ) {        if ( !strcmp(inps[i],"-boot") ) {
167          if ( numinp-1 < i+1 ){          if ( numinp-1 < i+1 ){
168            usage();            usage();
# Line 151  int main(int numinp, char *inps[]){ Line 212  int main(int numinp, char *inps[]){
212          };          };
213          password = (TString)inps[i+1];            password = (TString)inps[i+1];  
214        };        };
   
215        if ( !strcmp(inps[i],"-tle") ) {        if ( !strcmp(inps[i],"-tle") ) {
216          if ( numinp-1 < i+1 ){          if ( numinp-1 < i+1 ){
217            usage();            usage();
# Line 159  int main(int numinp, char *inps[]){ Line 219  int main(int numinp, char *inps[]){
219          };          };
220          tlefilename = (TString)inps[i+1];          tlefilename = (TString)inps[i+1];
221        };        };
   
222        //        //
223        if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;        if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;
224        //        //
# Line 167  int main(int numinp, char *inps[]){ Line 226  int main(int numinp, char *inps[]){
226        //        //
227        if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;        if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;
228        //        //
229          if ( !strcmp(inps[i],"-f") || !strcmp(inps[i],"-force") ) force = true;
230          //
231          if ( !strcmp(inps[i],"-nofrag") ) nofrag = true;
232          //
233        i++;        i++;
234      };      };
235    } else {    } else {
# Line 187  int main(int numinp, char *inps[]){ Line 250  int main(int numinp, char *inps[]){
250      dup2(nul,2);      dup2(nul,2);
251    };    };
252    //    //
253      if ( !strcmp(filerootname.Data(),"") ){
254        if ( (validate && !strcmp(validfile.Data(),"same")) ||
255             (remove && !strcmp(remfile.Data(),"same")) ||
256             (forceclean && !strcmp(fcleanfile.Data(),"same")) || force ){
257          printf("\n ERROR IN INPUT PARAMETERS \n");
258          usage();
259          exit(1);  
260        };
261      } else {
262        if ( validate && !strcmp(validfile.Data(),"same") ) validfile =  (TString)gSystem->BaseName(filerootname.Data());
263        if ( remove && !strcmp(remfile.Data(),"same") ) remfile =  (TString)gSystem->BaseName(filerootname.Data());
264        if ( forceclean && !strcmp(fcleanfile.Data(),"same") ) fcleanfile =  (TString)gSystem->BaseName(filerootname.Data());
265      };
266      //
267      if ( force ){
268        nofrag = true;
269        forceclean = true;
270        remove = true;
271        validate = true;    
272        fcleanfile = (TString)gSystem->BaseName(filerootname.Data());
273        remfile = fcleanfile;
274        validfile = fcleanfile;
275      };
276      //
277    // Start:    // Start:
278    //    //
279    TString message;    TString message;
280    char *version = YodaProfilerInfo(false);    char *version = YodaProfilerInfo(false);
281    PamelaDBOperations *pamDB = 0;    PamelaDBOperations *pamDB = 0;
282    UInt_t sizeofwar = 11;    UInt_t sizeofwar = 12;
283    UInt_t WAR[11];    UInt_t WAR[12];
284    memset(WAR, 0, 11*sizeof(UInt_t));    memset(WAR, 0, sizeofwar*sizeof(UInt_t));
285    //    //
286    printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version);    printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version);
287    try{    try{
# Line 207  int main(int numinp, char *inps[]){ Line 294  int main(int numinp, char *inps[]){
294      pamDB->CheckConnection();      pamDB->CheckConnection();
295      //-------------------------------------------------------------------------------------------      //-------------------------------------------------------------------------------------------
296      //      //
297        pamDB->SetNoFrag(nofrag);
298      if(pamDB->InsertRaw()){      pamDB->SetAutoBoot(autoboot);
299        //
300        if ( remove ){
301          //-------------------------------------------------------------------------------------------
302          // Remove a file and, on cascade, all that follows from the DB
303          //-------------------------------------------------------------------------------------------
304          if ( beverbose ) printf(" X => Remove file %s from DB \n",((TString)gSystem->BaseName(remfile)).Data());
305          WAR[11] = pamDB->removeFile((TString)gSystem->BaseName(remfile.Data()));
306          //-------------------------------------------------------------------------------------------
307        };    
308        //
309        if( pamDB->InsertRaw() ){
310        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
311        //Insert a Raw file in GL_RAW        //Insert a Raw file in GL_RAW
312        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
# Line 216  int main(int numinp, char *inps[]){ Line 314  int main(int numinp, char *inps[]){
314        WAR[0] = pamDB->insertPamelaRawFile();        WAR[0] = pamDB->insertPamelaRawFile();
315        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
316      };      };
317        //
318      if(pamDB->InsertRoot()){      if( pamDB->InsertRoot() ){
319                    //          
320        if(!pamDB->InsertRaw())printf("=> RAW file not inserted --- the DB might not ( yet ) be filled correctly \n");        if( !pamDB->InsertRaw() )printf("=> RAW file not inserted --- the DB might not ( yet ) be filled correctly \n");
321        pamDB->CheckFile();        pamDB->CheckFile();
       //-------------------------------------------------------------------------------------------    
       //Update a single GL_RAW record with its BOOT_NUMBER  
       //-------------------------------------------------------------------------------------------  
       if ( beverbose ) printf(" 3 => Update a single GL_RAW record with its BOOT_NUMBER \n");  
       WAR[3] = pamDB->assignBOOT_NUMBER();  
       //    if ( WAR[3] ) pamDB->SetNOBOOT(true);  
       if ( WAR[3] && WAR[3] != 1 ) throw -9;  
       //-------------------------------------------------------------------------------------------  
322        //        //
323        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
324        //Insert an entry in GL_TIMESYNC        //Insert an entry in GL_TIMESYNC
325        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
326        if ( beverbose ) printf(" 4 => Insert an entry in GL_TIMESYNC \n");        if ( beverbose ) printf(" 3 => Insert an entry in GL_TIMESYNC \n");
327        WAR[1] = pamDB->insertPamelaGL_TIMESYNC();        WAR[1] = pamDB->insertPamelaGL_TIMESYNC();
328        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
329        //        //
330          //-------------------------------------------------------------------------------------------  
331          //Update a single GL_RAW record with its BOOT_NUMBER
332          //-------------------------------------------------------------------------------------------
333          if ( beverbose ) printf(" 4 => Update a single GL_RAW record with its BOOT_NUMBER \n");
334          WAR[3] = pamDB->assignBOOT_NUMBER();
335          if ( WAR[3] && WAR[3] != 1 && WAR[3] != 8 ) throw -9;
336          //-------------------------------------------------------------------------------------------
337          //
338        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
339        //Insert unpack ROOT file in GL_ROOT          //Insert unpack ROOT file in GL_ROOT  
340        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
# Line 273  int main(int numinp, char *inps[]){ Line 371  int main(int numinp, char *inps[]){
371        //-------------------------------------------------------------------------------------------            //-------------------------------------------------------------------------------------------    
372      };      };
373      //      //
374        if ( forceclean ){
375          //-------------------------------------------------------------------------------------------
376          //Clean the GL_RUN_FRAGMENTS for the given file
377          //-------------------------------------------------------------------------------------------
378          if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table for file %s \n",fcleanfile.Data());
379          WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS((TString)gSystem->BaseName(fcleanfile.Data()));
380        };
381        //
382        //
383        if ( validate ){
384          //-------------------------------------------------------------------------------------------
385          //Validate runs
386          //-------------------------------------------------------------------------------------------
387          if ( beverbose ) printf(" 11 => Validate runs table for file %s \n",validfile.Data());
388          WAR[9] = pamDB->ValidateRuns((TString)gSystem->BaseName(validfile.Data()));
389          //-------------------------------------------------------------------------------------------    
390        };
391        //
392      pamDB->CheckValidate(olderthan);      pamDB->CheckValidate(olderthan);
393      //      //
394      if(pamDB->Validate()){        if( pamDB->Validate() ){  
395        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
396        //Clean the GL_RUN_FRAGMENTS        //Clean the GL_RUN_FRAGMENTS
397        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
398        if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table (earlier than %s) \n",pamDB->GetCleanTime() );        if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table (earlier than %s) \n",pamDB->GetCleanTime() );
399        WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS();        WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS();
400        //-------------------------------------------------------------------------------------------            //-------------------------------------------------------------------------------------------    
           
401        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
402        //Validate runs        //Validate runs
403        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
# Line 330  int main(int numinp, char *inps[]){ Line 445  int main(int numinp, char *inps[]){
445      case -26: message += " Raw file not found looking for VarDump"; break;      case -26: message += " Raw file not found looking for VarDump"; break;
446      case -27: message += " Cannot determine downlink orbit, wrong filename format?"; break;      case -27: message += " Cannot determine downlink orbit, wrong filename format?"; break;
447      case -28: message += " Cannot assign a RUN ID unique number!"; break;      case -28: message += " Cannot assign a RUN ID unique number!"; break;
448        case -29: message += " No VarDump and impossible to find a consistent BOOT number, use the -boot option to override"; break;
449      default: message += " Unidentified error"; break;      default: message += " Unidentified error"; break;
450      };      };
451      printf("\n");      printf("\n");
# Line 382  int main(int numinp, char *inps[]){ Line 498  int main(int numinp, char *inps[]){
498              if ( bit == 0 ) message += "=> BOOT number already inserted\n";//              if ( bit == 0 ) message += "=> BOOT number already inserted\n";//
499              else if ( bit == 1 ) message += "=> VarDump event tree is empty, use the -boot option to override\n";//              else if ( bit == 1 ) message += "=> VarDump event tree is empty, use the -boot option to override\n";//
500              else if ( bit == 2 ) message += "=> No BOOT number in VarDump(!), use the -boot option to override\n";//              else if ( bit == 2 ) message += "=> No BOOT number in VarDump(!), use the -boot option to override\n";//
501                else if ( bit == 3 ) message += "=> No VarDump! autoboot option used\n";//
502              else if ( bit == 4 ) message += "=> The file is not in the database looking for VarDump, use the -boot option to override\n";//              else if ( bit == 4 ) message += "=> The file is not in the database looking for VarDump, use the -boot option to override\n";//
503              else message += "=> Unidentified assignBOOTnumber warning\n";              else message += "=> Unidentified assignBOOTnumber warning\n";
504            };            };
# Line 433  int main(int numinp, char *inps[]){ Line 550  int main(int numinp, char *inps[]){
550          for (UInt_t bit=0; bit<32; bit++){          for (UInt_t bit=0; bit<32; bit++){
551            if ( WAR[j] & (1 << bit) ){            if ( WAR[j] & (1 << bit) ){
552              if      ( bit == 0 ) message += "=> Skip the GL_RUN_FRAGMENTS table cleaning\n";              if      ( bit == 0 ) message += "=> Skip the GL_RUN_FRAGMENTS table cleaning\n";
553                if      ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
554              else  message += "=> Unidentified CleanGL_RUN_FRAGMENTS warning\n";              else  message += "=> Unidentified CleanGL_RUN_FRAGMENTS warning\n";
555            };            };
556          };          };
# Line 442  int main(int numinp, char *inps[]){ Line 560  int main(int numinp, char *inps[]){
560          for (UInt_t bit=0; bit<32; bit++){          for (UInt_t bit=0; bit<32; bit++){
561            if ( WAR[j] & (1 << bit) ){            if ( WAR[j] & (1 << bit) ){
562              if      ( bit == 0 ) message += "=> Skip the run validation \n";              if      ( bit == 0 ) message += "=> Skip the run validation \n";
563                if      ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
564              else  message += "=> Unidentified ValidateRuns warning\n";              else  message += "=> Unidentified ValidateRuns warning\n";
565            };            };
566          };          };
# Line 456  int main(int numinp, char *inps[]){ Line 575  int main(int numinp, char *inps[]){
575            };            };
576          };          };
577        };        };
578          //
579          if ( j == 11 ){ // removeFile
580            for (UInt_t bit=0; bit<32; bit++){
581              if ( WAR[j] & (1 << bit) ){
582                if      ( bit == 0 ) message += "=> No file to delete from DB \n";
583                else  message += "=> Unidentified populateTle warning\n";
584              };
585            };
586          };
587      };      };
588    };    };
589    //    //

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23