/[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.2 by mocchiut, Fri Sep 1 12:47:13 2006 UTC revision 1.8 by mocchiut, Tue Sep 12 07:30:46 2006 UTC
# Line 20  void usage(){ Line 20  void usage(){
20    printf("\n Options can be: \n");    printf("\n Options can be: \n");
21    printf("\n --version       print informations about compilation and exit\n");    printf("\n --version       print informations about compilation and exit\n");
22    printf("\n -h | --help     print this help and exit \n");    printf("\n -h | --help     print this help and exit \n");
23    printf("\n -v | --verbose  be verbose [default: print nothing on STDOUT]\n");    printf("\n -v | --verbose  be verbose [default]\n");
24      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 -tsync number   timesync (s) [default = taken from data]\n");    printf("\n -tsync number   timesync (s) [default = taken from data]\n");
28    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");
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 = 864000 (10 days)],\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    printf("\n -host           name for the host [default = mysql://localhost/pamelaprod]\n");    printf("\n -host           name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
33    printf("\n -user           username for the DB [default = anonymous] \n");    printf("\n -user           username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n");
34    printf("\n -psw            password for the DB [default = \"\"]\n");    printf("\n -psw            password for the DB [default = $PAM_DBPSW or \"\"]\n");
35    printf("\n The order of input files and options does not matter. \n");    printf("\n The order of input files and options does not matter. \n");
36    printf("\nExample: \n");    printf("\nExample: \n");
37    printf("\n YodaProfiler -yodaFile /path/to/raw/files/000_000_00000_cln2.pam -rawFile /path/to/filesfromyoda/000_000_00000_cln2.root -v \n\n");    printf("\n YodaProfiler -yodaFile /path/to/raw/files/000_000_00000_cln2.pam -rawFile /path/to/filesfromyoda/000_000_00000_cln2.root -v \n\n");
# Line 45  int main(int numinp, char *inps[]){ Line 46  int main(int numinp, char *inps[]){
46    UInt_t boot = 0;    UInt_t boot = 0;
47    UInt_t tsync = 0;    UInt_t tsync = 0;
48    UInt_t obt0 = 0;    UInt_t obt0 = 0;
49    Long64_t olderthan = 864000LL;    //  Long64_t olderthan = 864000LL;
50      Long64_t olderthan = -1LL;
51      
52      //
53      //
54      TString filerawname  = "";
55      TString filerootname = "";
56      //
57      TString host = "mysql://localhost/pamelaprod";
58      TString user = "anonymous";
59      TString password = "";
60      //
61      const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
62      const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
63      const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
64      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
65      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
66      if ( strcmp(pamdbpsw,"") ) password = pamdbpsw;
67    //    //
   //  
   TString filerawname;  
   //  
   TString host;  
   TString user;  
   TString password;  
   //  
   TString filerootname;  
68    //        //    
69    Bool_t beverbose = false;    Bool_t beverbose = true;
70    Bool_t debug = false;    Bool_t debug = false;
71    Int_t i = 0;    Int_t i = 0;
72    //    //
# Line 67  int main(int numinp, char *inps[]){ Line 77  int main(int numinp, char *inps[]){
77          exit(0);          exit(0);
78        };        };
79        if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){        if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){
80    
81          usage();          usage();
82          exit(0);          exit(0);
83        };        };
# Line 136  int main(int numinp, char *inps[]){ Line 147  int main(int numinp, char *inps[]){
147        //        //
148        if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;        if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;
149        //        //
150          if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ) beverbose = false;
151          //
152        if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;        if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ) debug = true;
153        //        //
154        i++;        i++;
# Line 175  int main(int numinp, char *inps[]){ Line 188  int main(int numinp, char *inps[]){
188      //-------------------------------------------------------------------------------------------      //-------------------------------------------------------------------------------------------
189      if ( beverbose ) printf(" 1 => Initialize and open SQL connection \n");      if ( beverbose ) printf(" 1 => Initialize and open SQL connection \n");
190      pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug);      pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug);
191      pamDB->CheckFile();      pamDB->CheckConnection();
     pamDB->SetOlderThan(olderthan);  
192      //-------------------------------------------------------------------------------------------      //-------------------------------------------------------------------------------------------
193      //      //
194      //-------------------------------------------------------------------------------------------  
195      //Insert a Raw file in GL_RAW      if(pamDB->InsertRaw()){
196      //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
197      if ( beverbose ) printf(" 2 => Insert a RAW file in GL_RAW \n");        //Insert a Raw file in GL_RAW
198      WAR[0] = pamDB->insertPamelaRawFile();        //-------------------------------------------------------------------------------------------
199      //-------------------------------------------------------------------------------------------        if ( beverbose ) printf(" 2 => Insert a RAW file in GL_RAW \n");
200      //-------------------------------------------------------------------------------------------          WAR[0] = pamDB->insertPamelaRawFile();
201      //Update a single GL_RAW record with its BOOT_NUMBER        //-------------------------------------------------------------------------------------------
202      //-------------------------------------------------------------------------------------------      };
203      if ( beverbose ) printf(" 3 => Update a single GL_RAW record with its BOOT_NUMBER \n");  
204      WAR[3] = pamDB->assignBOOT_NUMBER();      if(pamDB->InsertRoot()){
205      //    if ( WAR[3] ) pamDB->SetNOBOOT(true);            
206      if ( WAR[3] && WAR[3] != 1 ) throw -9;        if(!pamDB->InsertRaw())printf("=> RAW file not inserted --- the DB might not ( yet ) be filled correctly \n");
207      //-------------------------------------------------------------------------------------------        pamDB->CheckFile();
208      //        //-------------------------------------------------------------------------------------------  
209      //-------------------------------------------------------------------------------------------        //Update a single GL_RAW record with its BOOT_NUMBER
210      //Insert an entry in GL_TIMESYNC        //-------------------------------------------------------------------------------------------
211      //-------------------------------------------------------------------------------------------        if ( beverbose ) printf(" 3 => Update a single GL_RAW record with its BOOT_NUMBER \n");
212      if ( beverbose ) printf(" 4 => Insert an entry in GL_TIMESYNC \n");        WAR[3] = pamDB->assignBOOT_NUMBER();
213      WAR[1] = pamDB->insertPamelaGL_TIMESYNC();        //    if ( WAR[3] ) pamDB->SetNOBOOT(true);
214      //-------------------------------------------------------------------------------------------        if ( WAR[3] && WAR[3] != 1 ) throw -9;
215          //-------------------------------------------------------------------------------------------
216          //
217          //-------------------------------------------------------------------------------------------
218          //Insert an entry in GL_TIMESYNC
219          //-------------------------------------------------------------------------------------------
220          if ( beverbose ) printf(" 4 => Insert an entry in GL_TIMESYNC \n");
221          WAR[1] = pamDB->insertPamelaGL_TIMESYNC();
222          //-------------------------------------------------------------------------------------------
223          //
224          //-------------------------------------------------------------------------------------------
225          //Insert unpack ROOT file in GL_ROOT  
226          //-------------------------------------------------------------------------------------------
227          if ( beverbose ) printf(" 5 => Insert unpack ROOT file in GL_ROOT \n");
228          WAR[2] = pamDB->insertPamelaRootFile();
229          //-------------------------------------------------------------------------------------------
230          //
231          //-------------------------------------------------------------------------------------------      
232          //Insert in GL_RUN runs information records relative to a single unpack
233          //-------------------------------------------------------------------------------------------
234          if ( beverbose ) printf(" 6 => Scan physics and store runs in the GL_RUN table\n");
235          WAR[4] = pamDB->insertPamelaRUN();
236          //-------------------------------------------------------------------------------------------    
237            
238          //-------------------------------------------------------------------------------------------
239          //Insert in GL_CALO_CALIB calibration information records relative to a single unpack
240          //-------------------------------------------------------------------------------------------
241          if ( beverbose ) printf(" 7 => Insert calorimeter calibrations in the GL_CALO_CALIB table\n");
242          WAR[5] = pamDB->insertCALO_CALIB();
243          //-------------------------------------------------------------------------------------------    
244            
245          //-------------------------------------------------------------------------------------------
246          //Insert in GL_TRK_CALIB calibration information records relative to a single unpack
247          //-------------------------------------------------------------------------------------------
248          if ( beverbose ) printf(" 8 => Insert tracker calibrations in the GL_TRK_CALIB table\n");
249          WAR[6] = pamDB->insertTRK_CALIB();
250          //-------------------------------------------------------------------------------------------    
251            
252          //-------------------------------------------------------------------------------------------
253          //Insert in GL_S4_CALIB calibration information records relative to a single unpack
254          //-------------------------------------------------------------------------------------------
255          if ( beverbose ) printf(" 9 => Insert S4 calibrations in the GL_S4_CALIB table\n");
256          WAR[7] = pamDB->insertS4_CALIB();
257          //-------------------------------------------------------------------------------------------    
258        };
259      //      //
260      //-------------------------------------------------------------------------------------------      pamDB->CheckValidate(olderthan);
     //Insert unpack ROOT file in GL_ROOT    
     //-------------------------------------------------------------------------------------------  
     if ( beverbose ) printf(" 5 => Insert unpack ROOT file in GL_ROOT \n");  
     WAR[2] = pamDB->insertPamelaRootFile();  
     //-------------------------------------------------------------------------------------------  
261      //      //
262        if(pamDB->Validate()){  
263      //-------------------------------------------------------------------------------------------              //-------------------------------------------------------------------------------------------
264      //Insert in GL_RUN runs information records relative to a single unpack        //Clean the GL_RUN_FRAGMENTS
265      //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
266      if ( beverbose ) printf(" 6 => Scan physics and store runs in the GL_RUN table\n");        if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table (earlier than %s) \n",pamDB->GetCleanTime() );
267      WAR[4] = pamDB->insertPamelaRUN();        WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS();
268      //-------------------------------------------------------------------------------------------            //-------------------------------------------------------------------------------------------    
269            
270      //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
271      //Insert in GL_CALO_CALIB calibration information records relative to a single unpack        //Validate runs
272      //-------------------------------------------------------------------------------------------        //-------------------------------------------------------------------------------------------
273      if ( beverbose ) printf(" 7 => Insert calorimeter calibrations in the GL_CALO_CALIB table\n");        if ( beverbose ) printf(" 11 => Validate runs (earlier than %s)\n",pamDB->GetCleanTime());
274      WAR[5] = pamDB->insertCALO_CALIB();        WAR[9] = pamDB->ValidateRuns();
275      //-------------------------------------------------------------------------------------------            //-------------------------------------------------------------------------------------------    
276        };
277      //-------------------------------------------------------------------------------------------          
     //Insert in GL_TRK_CALIB calibration information records relative to a single unpack  
     //-------------------------------------------------------------------------------------------  
     if ( beverbose ) printf(" 8 => Insert tracker calibrations in the GL_TRK_CALIB table\n");  
     WAR[6] = pamDB->insertTRK_CALIB();  
     //-------------------------------------------------------------------------------------------      
   
     //-------------------------------------------------------------------------------------------  
     //Insert in GL_S4_CALIB calibration information records relative to a single unpack  
     //-------------------------------------------------------------------------------------------  
     if ( beverbose ) printf(" 9 => Insert S4 calibrations in the GL_S4_CALIB table\n");  
     WAR[7] = pamDB->insertS4_CALIB();  
     //-------------------------------------------------------------------------------------------      
   
     //-------------------------------------------------------------------------------------------  
     //Clean the GL_RUN_FRAGMENTS  
     //-------------------------------------------------------------------------------------------  
     if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table\n");  
     WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS();  
     //-------------------------------------------------------------------------------------------      
   
     //-------------------------------------------------------------------------------------------  
     //Validate runs  
     //-------------------------------------------------------------------------------------------  
     if ( beverbose ) printf(" 11 => Validate runs\n");  
     WAR[9] = pamDB->ValidateRuns();  
     //-------------------------------------------------------------------------------------------      
       
278    } catch (Int_t exc) {    } catch (Int_t exc) {
279      signal = exc;      signal = exc;
280      switch(exc){      switch(exc){

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.23