/[PAMELA software]/YodaProfiler/src/R2-D2.cpp
ViewVC logotype

Diff of /YodaProfiler/src/R2-D2.cpp

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

revision 1.2 by mocchiut, Tue Nov 7 12:17:45 2006 UTC revision 1.7 by mocchiut, Tue Nov 28 13:31:59 2006 UTC
# Line 28  using namespace std; Line 28  using namespace std;
28  //  //
29  void r2d2usage(){  void r2d2usage(){
30    printf("\nUsage:\n");    printf("\nUsage:\n");
31    printf("\n R2-D2 [-h | --help] [--version] [-idRun ID_RUN] [-filename filename]\n");    printf("\n R2-D2 [ options ]\n");
32    printf("\n            [-host host] [-user username] [-psw password] \n");    printf("\n Options are:\n\n");
33    printf("\n --version        print informations about compilation and exit\n");    printf(" --version        print informations about compilation and exit\n");
34    printf("\n -h | --help      print this help and exit \n");    printf(" -h | --help      print this help and exit \n");
35    printf("\n -v | --verbose   be verbose [default: print nothing on STDOUT]\n");    printf(" -v | --verbose   be verbose [default: print nothing on STDOUT]\n");
36    printf("\n -idRun run       ID_RUN: ID number of the run \n");    printf(" -idRun run       ID_RUN: ID number of the run \n");
37    printf("\n -filename file   output yoda filename \n");    printf(" -filename file   output yoda filename \n");
38    printf("\n -host            name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");    printf(" -host            name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
39    printf("\n -user            username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n");    printf(" -user            username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n");
40    printf("\n -psw             password for the DB [default = $PAM_DBPSW or \"\"]\n");    printf(" -psw             password for the DB connection [default = $PAM_DBPSW or \"\"]\n");
41    printf("\n -tzone timezone  the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n");    printf(" -tzone timezone  the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n");
42    printf("\n -convert dbtime  convert the dbtime given in seconds (from the DB) to a string\n");    printf(" -convert dbtime  convert the dbtime given in seconds (from the DB) to a string\n");
43    printf("\n -runat date      returns run number which contains the given date,\n");    printf(" -runat date      returns run number which contains the given date,\n");
44    printf("\n                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");    printf("                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");
45    printf("\n -runatDB time    returns run number which contains the given DB time\n");    printf(" -runatDB time    returns run number which contains the given DB time\n");
46    printf("\n -tsfile file     yoda filename for the time sync (to be used with -obt)\n");    printf(" -tsfile file     yoda filename for the time sync (to be used with -obt)\n");
47    printf("\n -obt OBT         OBT in ms returns a date (to be used with -tsfile)\n");    printf(" -obt OBT         OBT in ms returns a date (to be used with -tsfile)\n");
48    printf("\n -dumpTLEfor date save into file tle.txt the TLE for the given date,\n");    printf(" -getRTime OBT    OBT in ms returns Resurs time (to be used with -tsfile)\n");
49    printf("\n                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");    printf(" -dumpTLEfor date save into file tle.txt the TLE for the given date,\n");
50      printf("                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");
51    printf("\nExamples: \n");    printf("\nExamples: \n");
52    printf("\n R2-D2 -idRun 1085 \n");    printf("      R2-D2 -idRun 1085 \n");
53    printf("\n R2-D2 -filename DW_050208_00900.root \n");    printf("      R2-D2 -filename DW_050208_00900.root \n");
54    printf("\n R2-D2 -idRun 1085 -filename DW_050208_00900.root \n");    printf("      R2-D2 -idRun 1085 -filename DW_050208_00900.root \n");
55  };  };
56  //  //
57  // Here the main  // Here the main
# Line 88  int main(int numinp, char *inps[]){ Line 89  int main(int numinp, char *inps[]){
89    TString tletime = "1970-01-01 00:00:00";    TString tletime = "1970-01-01 00:00:00";
90    UInt_t dbti = 0;    UInt_t dbti = 0;
91    Bool_t convert = false;    Bool_t convert = false;
92      Bool_t convres = false;
93    Bool_t ruti = false;    Bool_t ruti = false;
94    Bool_t dtle = false;    Bool_t dtle = false;
95    Bool_t ruti2 = false;    Bool_t ruti2 = false;
# Line 96  int main(int numinp, char *inps[]){ Line 98  int main(int numinp, char *inps[]){
98    //    //
99    UInt_t runtime2 = 0;    UInt_t runtime2 = 0;
100    UInt_t obt = 0;    UInt_t obt = 0;
101      UInt_t res = 0;
102    TString tsfile = "";    TString tsfile = "";
103    //    //
104    TSQLResult *pResult;    TSQLResult *pResult;
# Line 171  int main(int numinp, char *inps[]){ Line 174  int main(int numinp, char *inps[]){
174          obt = (UInt_t)atoll(inps[i+1]);          obt = (UInt_t)atoll(inps[i+1]);
175        };        };
176        //        //
177         if ( !strcmp(inps[i],"-getRTime") ) {
178            convres = true;
179            if ( numinp-1 < i+1 ){
180              r2d2usage();
181              exit(-3);
182            };
183            res = (UInt_t)atoll(inps[i+1]);
184          };
185          //
186        //        //
187        if ( !strcmp(inps[i],"-tzone") ) {        if ( !strcmp(inps[i],"-tzone") ) {
188          if ( numinp-1 < i+1 ){          if ( numinp-1 < i+1 ){
# Line 254  int main(int numinp, char *inps[]){ Line 266  int main(int numinp, char *inps[]){
266      printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data());      printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data());
267    };    };
268    //    //
269    //    // convert OBT to date
270    //    //
271    if ( convobt && convobtts ){    if ( convobt && convobtts ){
272      UInt_t id = 0;      UInt_t id = 0;
# Line 270  int main(int numinp, char *inps[]){ Line 282  int main(int numinp, char *inps[]){
282          delete pResult;                delete pResult;      
283          GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);          GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);
284          UInt_t abtime = ctime->DBabsTime(obt);          UInt_t abtime = ctime->DBabsTime(obt);
         TString UTC="UTC";  
285          TString thetime = dbtime->ConvertTime(tzone,abtime);          TString thetime = dbtime->ConvertTime(tzone,abtime);
286          printf("\n OBT %u in the file %s corresponds to DBtime %u and date %s %s \n",obt,tsfile.Data(),abtime,thetime.Data(),tzone.Data());          printf("\n OBT %u in the file %s corresponds to DBtime %u and date %s %s \n",obt,tsfile.Data(),abtime,thetime.Data(),tzone.Data());
287          delete ctime;          delete ctime;
288        };        };
289      };      };
290    };    };
291    if ( (convobt && !convobtts) || (convobtts && !convobt) ){    if ( (convobt && !convobtts) ){
292      printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n");      printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n");
293    };    };
294    //    //
295      // convert OBT to Resurs seconds
296      //
297      if ( convres && convobtts ){
298        UInt_t id = 0;
299        myquery.str("");
300        myquery << "select ";
301        myquery << " ID";
302        myquery << " from GL_ROOT where NAME=\"" << tsfile.Data() << "\";";    
303        pResult = dbc->Query(myquery.str().c_str());
304        if ( pResult ){
305          Row = pResult->Next();      
306          if ( Row ){
307            id = (UInt_t)atoll(Row->GetField(0));
308            delete pResult;      
309            GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);
310            UInt_t restime = ctime->ResursTime(res);
311            //UInt_t abtime = ctime->DBabsTime(obt);
312            //
313            //      TString thetime = dbtime->ConvertTime(tzone,abtime);
314            printf("\n OBT %u in the file %s corresponds to Resurs time %u  \n",res,tsfile.Data(),restime);
315            delete ctime;
316          };
317        };
318      };
319      if ( (convres && !convobtts) ){
320        printf("\n To convert a OBT to the Resurs time you must provide both OBT and file to be used for time sync \n");
321      };
322      //
323    // Which run contains the date "runtime"?    // Which run contains the date "runtime"?
324    //    //
325    if ( ruti ){    if ( ruti ){
# Line 338  int main(int numinp, char *inps[]){ Line 377  int main(int numinp, char *inps[]){
377    if ( dtle ){    if ( dtle ){
378      //      //
379      //      //
380      TDatime ti = TDatime(runtime.Data());      TDatime ti = TDatime(tletime.Data());
381      //      //
382      TTimeStamp *time = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);      TTimeStamp *time = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);
383      //      //
# Line 430  int main(int numinp, char *inps[]){ Line 469  int main(int numinp, char *inps[]){
469          exit(-4);          exit(-4);
470        };        };
471        printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data());        printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data());
472          filename = glroot->NAME;
473        found = true;        found = true;
474      };      };
475      //      //
# Line 482  int main(int numinp, char *inps[]){ Line 522  int main(int numinp, char *inps[]){
522      } else {      } else {
523        myquery.str("");        myquery.str("");
524        myquery << "select ";        myquery << "select ";
525        myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME ";        myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME,NEVENTS ";
526        myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";";            myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";";    
527        pResult = dbc->Query(myquery.str().c_str());        pResult = dbc->Query(myquery.str().c_str());
528        for( r=0; r < 1000; r++){        for( r=0; r < 1000; r++){
# Line 490  int main(int numinp, char *inps[]){ Line 530  int main(int numinp, char *inps[]){
530          if( Row == NULL ) break;          if( Row == NULL ) break;
531          found = true;          found = true;
532          if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data());          if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data());
533          TString UTC="UTC";          TString UTC=tzone.Data();
534          printf(" => ID = %i --> the run started at %s UTC ended at %s UTC \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data());          printf(" => ID = %i --> the run started at %s %s ended at %s %s NEV = %u \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data(),(UInt_t)atoll(Row->GetField(3)));
535        };        };
536        delete pResult;          delete pResult;  
537        myquery.str("");        myquery.str("");
# Line 503  int main(int numinp, char *inps[]){ Line 543  int main(int numinp, char *inps[]){
543          Row = pResult->Next();                Row = pResult->Next();      
544          if( Row == NULL ) break;          if( Row == NULL ) break;
545          if ( !r ) printf("\n File %s contains the following DELETED runs: \n\n",filename.Data());          if ( !r ) printf("\n File %s contains the following DELETED runs: \n\n",filename.Data());
546          TString UTC="UTC";          TString UTC=tzone.Data();
547          printf(" => ID = %i --> the run started at %s UTC ended at %s UTC \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data());          printf(" => ID = %i --> the run started at %s %s ended at %s %s \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data());
548        };        };
549        //        //
550        if ( !found ){        if ( !found ){

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

  ViewVC Help
Powered by ViewVC 1.1.23