/[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.12 by mocchiut, Tue Oct 31 15:36:05 2006 UTC
# Line 29  void usage(){ Line 29  void usage(){
29    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");
30    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");
31    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");
32    //
33      printf("\n -remove file    remove file and all related runs and calibrations from DB\n");
34      printf("\n                 file must be the YODA filename (full path is not needed)\n");
35      printf("\n                 'same' can be used if in conjuction with -yodaFile\n");
36      printf("\n -validate file  validates runs between the two closest calibration to file \n");
37      printf("\n                 not belonging to file itself. File must be the YODA filename\n");
38      printf("\n                 'same' can be used if in conjuction with -yodaFile\n");
39      printf("\n -cleanfrag file clean run fragments for file only\n");
40      printf("\n                 File must be the YODA filename\n");
41      printf("\n                 'same' can be used if in conjuction with -yodaFile\n");
42      printf("\n -nofrag         do not leave runs in the fragment table and look for fragments\n");
43      printf("\n                 in the GL_RUN table.\n");
44      printf("\n -force          to be used to reprocess a file or to process a file\n");
45      printf("\n                 when already validated the surroundings, it is equivalent to:\n");
46      printf("\n                 -remove same -validate same -cleanfrag same -nofrag\n");
47    //      
48    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");
49    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");
50    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 63  int main(int numinp, char *inps[]){
63    UInt_t boot = 0;    UInt_t boot = 0;
64    UInt_t tsync = 0;    UInt_t tsync = 0;
65    UInt_t obt0 = 0;    UInt_t obt0 = 0;
66    //  Long64_t olderthan = 864000LL;    Long64_t olderthan = -1LL;  
   Long64_t olderthan = -1LL;  
     
67    //    //
68    //    //
69    TString filerawname  = "";    TString filerawname  = "";
# Line 60  int main(int numinp, char *inps[]){ Line 74  int main(int numinp, char *inps[]){
74    TString password = "";    TString password = "";
75    //    //
76    TString tlefilename = "";    TString tlefilename = "";
77      //
78    const char *pamdbhost = gSystem->Getenv("PAM_DBHOST");    const char *pamdbhost = gSystem->Getenv("PAM_DBHOST");
79    const char *pamdbuser = gSystem->Getenv("PAM_DBUSER");    const char *pamdbuser = gSystem->Getenv("PAM_DBUSER");
80    const char *pamdbpsw = gSystem->Getenv("PAM_DBPSW");    const char *pamdbpsw = gSystem->Getenv("PAM_DBPSW");
# Line 74  int main(int numinp, char *inps[]){ Line 88  int main(int numinp, char *inps[]){
88    //        //    
89    Bool_t beverbose = true;    Bool_t beverbose = true;
90    Bool_t debug = false;    Bool_t debug = false;
91      //
92      Bool_t remove = false;
93      TString remfile = "";
94      //
95      Bool_t forceclean = false;
96      TString fcleanfile = "";
97      //
98      Bool_t validate = false;
99      TString validfile = "";
100      //
101      Bool_t nofrag = false;
102      //
103      Bool_t force = false;
104    //    //
105    Int_t i = 0;    Int_t i = 0;
106    //    //
# Line 102  int main(int numinp, char *inps[]){ Line 129  int main(int numinp, char *inps[]){
129          };          };
130          filerootname = (TString)inps[i+1];                filerootname = (TString)inps[i+1];      
131        };        };
132          if ( !strcmp(inps[i],"-remove") ) {
133            if ( numinp-1 < i+1 ){
134              usage();
135              exit(1);
136            };
137            remfile = (TString)inps[i+1];  
138            remove = true;
139          };
140         if ( !strcmp(inps[i],"-cleanfrag") ) {
141            if ( numinp-1 < i+1 ){
142              usage();
143              exit(1);
144            };
145            fcleanfile = (TString)inps[i+1];        
146            forceclean = true;
147          };
148         if ( !strcmp(inps[i],"-validate") ) {
149            if ( numinp-1 < i+1 ){
150              usage();
151              exit(1);
152            };
153            validfile = (TString)inps[i+1];
154            validate = true;
155          };
156        if ( !strcmp(inps[i],"-boot") ) {        if ( !strcmp(inps[i],"-boot") ) {
157          if ( numinp-1 < i+1 ){          if ( numinp-1 < i+1 ){
158            usage();            usage();
# Line 151  int main(int numinp, char *inps[]){ Line 202  int main(int numinp, char *inps[]){
202          };          };
203          password = (TString)inps[i+1];            password = (TString)inps[i+1];  
204        };        };
   
205        if ( !strcmp(inps[i],"-tle") ) {        if ( !strcmp(inps[i],"-tle") ) {
206          if ( numinp-1 < i+1 ){          if ( numinp-1 < i+1 ){
207            usage();            usage();
# Line 159  int main(int numinp, char *inps[]){ Line 209  int main(int numinp, char *inps[]){
209          };          };
210          tlefilename = (TString)inps[i+1];          tlefilename = (TString)inps[i+1];
211        };        };
   
212        //        //
213        if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;        if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;
214        //        //
# Line 167  int main(int numinp, char *inps[]){ Line 216  int main(int numinp, char *inps[]){
216        //        //
217        if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;        if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;
218        //        //
219          if ( !strcmp(inps[i],"-f") || !strcmp(inps[i],"-force") ) force = true;
220          //
221          if ( !strcmp(inps[i],"-nofrag") ) nofrag = true;
222          //
223        i++;        i++;
224      };      };
225    } else {    } else {
# Line 187  int main(int numinp, char *inps[]){ Line 240  int main(int numinp, char *inps[]){
240      dup2(nul,2);      dup2(nul,2);
241    };    };
242    //    //
243      if ( !strcmp(filerootname.Data(),"") ){
244        if ( (validate && !strcmp(validfile.Data(),"same")) ||
245             (remove && !strcmp(remfile.Data(),"same")) ||
246             (forceclean && !strcmp(fcleanfile.Data(),"same")) || force ){
247          printf("\n ERROR IN INPUT PARAMETERS \n");
248          usage();
249          exit(1);  
250        };
251      } else {
252        if ( validate && !strcmp(validfile.Data(),"same") ) validfile =  (TString)gSystem->BaseName(filerootname.Data());
253        if ( remove && !strcmp(remfile.Data(),"same") ) remfile =  (TString)gSystem->BaseName(filerootname.Data());
254        if ( forceclean && !strcmp(fcleanfile.Data(),"same") ) fcleanfile =  (TString)gSystem->BaseName(filerootname.Data());
255      };
256      //
257      if ( force ){
258        nofrag = true;
259        forceclean = true;
260        remove = true;
261        validate = true;    
262        fcleanfile = (TString)gSystem->BaseName(filerootname.Data());
263        remfile = fcleanfile;
264        validfile = fcleanfile;
265      };
266      //
267    // Start:    // Start:
268    //    //
269    TString message;    TString message;
270    char *version = YodaProfilerInfo(false);    char *version = YodaProfilerInfo(false);
271    PamelaDBOperations *pamDB = 0;    PamelaDBOperations *pamDB = 0;
272    UInt_t sizeofwar = 11;    UInt_t sizeofwar = 12;
273    UInt_t WAR[11];    UInt_t WAR[12];
274    memset(WAR, 0, 11*sizeof(UInt_t));    memset(WAR, 0, sizeofwar*sizeof(UInt_t));
275    //    //
276    printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version);    printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version);
277    try{    try{
# Line 207  int main(int numinp, char *inps[]){ Line 284  int main(int numinp, char *inps[]){
284      pamDB->CheckConnection();      pamDB->CheckConnection();
285      //-------------------------------------------------------------------------------------------      //-------------------------------------------------------------------------------------------
286      //      //
287        pamDB->SetNoFrag(nofrag);
288      if(pamDB->InsertRaw()){      //
289        if ( remove ){
290          //-------------------------------------------------------------------------------------------
291          // Remove a file and, on cascade, all that follows from the DB
292          //-------------------------------------------------------------------------------------------
293          if ( beverbose ) printf(" X => Remove file %s from DB \n",((TString)gSystem->BaseName(remfile)).Data());
294          WAR[11] = pamDB->removeFile((TString)gSystem->BaseName(remfile.Data()));
295          //-------------------------------------------------------------------------------------------
296        };    
297        //
298        if( pamDB->InsertRaw() ){
299        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
300        //Insert a Raw file in GL_RAW        //Insert a Raw file in GL_RAW
301        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
# Line 216  int main(int numinp, char *inps[]){ Line 303  int main(int numinp, char *inps[]){
303        WAR[0] = pamDB->insertPamelaRawFile();        WAR[0] = pamDB->insertPamelaRawFile();
304        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
305      };      };
306        //
307      if(pamDB->InsertRoot()){      if( pamDB->InsertRoot() ){
308                    //          
309        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");
310        pamDB->CheckFile();        pamDB->CheckFile();
311        //-------------------------------------------------------------------------------------------          //-------------------------------------------------------------------------------------------  
312        //Update a single GL_RAW record with its BOOT_NUMBER        //Update a single GL_RAW record with its BOOT_NUMBER
# Line 273  int main(int numinp, char *inps[]){ Line 360  int main(int numinp, char *inps[]){
360        //-------------------------------------------------------------------------------------------            //-------------------------------------------------------------------------------------------    
361      };      };
362      //      //
363        if ( forceclean ){
364          //-------------------------------------------------------------------------------------------
365          //Clean the GL_RUN_FRAGMENTS for the given file
366          //-------------------------------------------------------------------------------------------
367          if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table for file %s \n",fcleanfile.Data());
368          WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS((TString)gSystem->BaseName(fcleanfile.Data()));
369        };
370        //
371        //
372        if ( validate ){
373          //-------------------------------------------------------------------------------------------
374          //Validate runs
375          //-------------------------------------------------------------------------------------------
376          if ( beverbose ) printf(" 11 => Validate runs table for file %s \n",validfile.Data());
377          WAR[9] = pamDB->ValidateRuns((TString)gSystem->BaseName(validfile.Data()));
378          //-------------------------------------------------------------------------------------------    
379        };
380        //
381      pamDB->CheckValidate(olderthan);      pamDB->CheckValidate(olderthan);
382      //      //
383      if(pamDB->Validate()){        if( pamDB->Validate() ){  
384        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
385        //Clean the GL_RUN_FRAGMENTS        //Clean the GL_RUN_FRAGMENTS
386        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
387        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() );
388        WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS();        WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS();
389        //-------------------------------------------------------------------------------------------            //-------------------------------------------------------------------------------------------    
           
390        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
391        //Validate runs        //Validate runs
392        //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
# Line 433  int main(int numinp, char *inps[]){ Line 537  int main(int numinp, char *inps[]){
537          for (UInt_t bit=0; bit<32; bit++){          for (UInt_t bit=0; bit<32; bit++){
538            if ( WAR[j] & (1 << bit) ){            if ( WAR[j] & (1 << bit) ){
539              if      ( bit == 0 ) message += "=> Skip the GL_RUN_FRAGMENTS table cleaning\n";              if      ( bit == 0 ) message += "=> Skip the GL_RUN_FRAGMENTS table cleaning\n";
540                if      ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
541              else  message += "=> Unidentified CleanGL_RUN_FRAGMENTS warning\n";              else  message += "=> Unidentified CleanGL_RUN_FRAGMENTS warning\n";
542            };            };
543          };          };
# Line 442  int main(int numinp, char *inps[]){ Line 547  int main(int numinp, char *inps[]){
547          for (UInt_t bit=0; bit<32; bit++){          for (UInt_t bit=0; bit<32; bit++){
548            if ( WAR[j] & (1 << bit) ){            if ( WAR[j] & (1 << bit) ){
549              if      ( bit == 0 ) message += "=> Skip the run validation \n";              if      ( bit == 0 ) message += "=> Skip the run validation \n";
550                if      ( bit == 1 ) message += "=> Problems retrieving ROOT ID from DB\n";
551              else  message += "=> Unidentified ValidateRuns warning\n";              else  message += "=> Unidentified ValidateRuns warning\n";
552            };            };
553          };          };
# Line 456  int main(int numinp, char *inps[]){ Line 562  int main(int numinp, char *inps[]){
562            };            };
563          };          };
564        };        };
565          //
566          if ( j == 11 ){ // removeFile
567            for (UInt_t bit=0; bit<32; bit++){
568              if ( WAR[j] & (1 << bit) ){
569                if      ( bit == 0 ) message += "=> No file to delete from DB \n";
570                else  message += "=> Unidentified populateTle warning\n";
571              };
572            };
573          };
574      };      };
575    };    };
576    //    //

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

  ViewVC Help
Powered by ViewVC 1.1.23