/[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.4 by mocchiut, Mon Nov 20 09:11:59 2006 UTC revision 1.10 by mocchiut, Thu Jan 11 16:04:16 2007 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(" -l2filename file output amidala filename \n");
39    printf("\n -user            username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n");    printf(" -host            name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n");
40    printf("\n -psw             password for the DB [default = $PAM_DBPSW or \"\"]\n");    printf(" -user            username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n");
41    printf("\n -tzone timezone  the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n");    printf(" -psw             password for the DB connection [default = $PAM_DBPSW or \"\"]\n");
42    printf("\n -convert dbtime  convert the dbtime given in seconds (from the DB) to a string\n");    printf(" -tzone timezone  the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n");
43    printf("\n -runat date      returns run number which contains the given date,\n");    printf(" -convert dbtime  convert the dbtime given in seconds (from the DB) to a string\n");
44    printf("\n                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");    printf(" -runat date      returns run number which contains the given date,\n");
45    printf("\n -runatDB time    returns run number which contains the given DB time\n");    printf("                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");
46    printf("\n -tsfile file     yoda filename for the time sync (to be used with -obt)\n");    printf(" -runatDB time    returns run number which contains the given DB time\n");
47    printf("\n -obt OBT         OBT in ms returns a date (to be used with -tsfile)\n");    printf(" -tsfile file     yoda filename for the time sync (to be used with -obt)\n");
48    printf("\n -getRTime OBT    OBT in ms returns Resurs time (to be used with -tsfile)\n");    printf(" -obt OBT         OBT in ms returns a date (to be used with -tsfile)\n");
49    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");
50    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");
51      printf("                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");
52    printf("\nExamples: \n");    printf("\nExamples: \n");
53    printf("\n R2-D2 -idRun 1085 \n");    printf("      R2-D2 -idRun 1085 \n");
54    printf("\n R2-D2 -filename DW_050208_00900.root \n");    printf("      R2-D2 -filename DW_050208_00900.root \n");
55    printf("\n R2-D2 -idRun 1085 -filename DW_050208_00900.root \n");    printf("      R2-D2 -idRun 1085 -filename DW_050208_00900.root \n\n");
56  };  };
57  //  //
58  // Here the main  // Here the main
# Line 66  int main(int numinp, char *inps[]){ Line 67  int main(int numinp, char *inps[]){
67    UInt_t run = 0ULL;    UInt_t run = 0ULL;
68    //    //
69    TString filename = "";    TString filename = "";
70      TString l2filename = "";
71    //    //
72    TSQLServer *dbc = 0;    TSQLServer *dbc = 0;
73    TString host = "mysql://localhost/pamelaprod";    TString host = "mysql://localhost/pamelaprod";
# Line 134  int main(int numinp, char *inps[]){ Line 136  int main(int numinp, char *inps[]){
136          };          };
137          filename = (TString)inps[i+1];            filename = (TString)inps[i+1];  
138        };        };
139          if ( !strcmp(inps[i],"-l2filename") ) {
140            if ( numinp-1 < i+1 ){
141              r2d2usage();
142              exit(-3);
143            };
144            l2filename = (TString)inps[i+1];        
145          };
146        if ( !strcmp(inps[i],"-host") ) {        if ( !strcmp(inps[i],"-host") ) {
147          if ( numinp-1 < i+1 ){          if ( numinp-1 < i+1 ){
148            r2d2usage();            r2d2usage();
# Line 259  int main(int numinp, char *inps[]){ Line 268  int main(int numinp, char *inps[]){
268    GL_ROOT *glroot = new GL_ROOT();    GL_ROOT *glroot = new GL_ROOT();
269    GL_RUN *glrun = new GL_RUN();    GL_RUN *glrun = new GL_RUN();
270    GL_TIMESYNC *dbtime = new GL_TIMESYNC();    GL_TIMESYNC *dbtime = new GL_TIMESYNC();
271      UInt_t nr = 0;
272      UInt_t rlist[500];
273    //    //
274    // At which date correspond the DB time "dbti"?    // At which date correspond the DB time "dbti"?
275    //    //
# Line 469  int main(int numinp, char *inps[]){ Line 480  int main(int numinp, char *inps[]){
480          exit(-4);          exit(-4);
481        };        };
482        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());
483          //filename = glroot->NAME;
484        found = true;        found = true;
485      };      };
486      //      //
# Line 521  int main(int numinp, char *inps[]){ Line 533  int main(int numinp, char *inps[]){
533      } else {      } else {
534        myquery.str("");        myquery.str("");
535        myquery << "select ";        myquery << "select ";
536        myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME ";        myquery << " ID,RUNHEADER_TIME,RUNTRAILER_TIME,NEVENTS ";
537        myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";";            myquery << " from GL_RUN where ID_ROOT_L0=" << ID << ";";    
538        pResult = dbc->Query(myquery.str().c_str());        pResult = dbc->Query(myquery.str().c_str());
539        for( r=0; r < 1000; r++){        for( r=0; r < 1000; r++){
# Line 529  int main(int numinp, char *inps[]){ Line 541  int main(int numinp, char *inps[]){
541          if( Row == NULL ) break;          if( Row == NULL ) break;
542          found = true;          found = true;
543          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());
544          TString UTC="UTC";          TString UTC=tzone.Data();
545          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)));
546        };        };
547        delete pResult;          delete pResult;  
548        myquery.str("");        myquery.str("");
# Line 542  int main(int numinp, char *inps[]){ Line 554  int main(int numinp, char *inps[]){
554          Row = pResult->Next();                Row = pResult->Next();      
555          if( Row == NULL ) break;          if( Row == NULL ) break;
556          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());
557          TString UTC="UTC";          TString UTC=tzone.Data();
558          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());
559        };        };
560        //        //
561        if ( !found ){        if ( !found ){
# Line 567  int main(int numinp, char *inps[]){ Line 579  int main(int numinp, char *inps[]){
579      };      };
580    };      };  
581    //    //
582      // Which runs are contained in the file "l2filename"?
583      //
584      if ( strcmp(l2filename.Data(),"") ){
585        // ----------------
586        Bool_t found = false;
587        Int_t ID = 0;
588        Int_t ID_RAW = 0;
589        //    
590        const char *rawpath = "";
591        const char *rawname = "";
592        //
593        myquery.str("");
594        myquery << "select ";
595        myquery << " ID";
596        myquery << ",ID_RAW";
597        myquery << ",PATH";
598        myquery << ",NAME";
599        myquery << " from GL_ROOT where NAME=\"" << l2filename.Data() << "\";";    
600        pResult = dbc->Query(myquery.str().c_str());
601        for( r=0; r < 1000; r++){
602          Row = pResult->Next();      
603          if( Row == NULL ) break;
604          for( t = 0; t < pResult->GetFieldCount(); t++){
605            if(t==0) ID     = atoi(Row->GetField(t));
606            if(t==1) ID_RAW = atoi(Row->GetField(t));
607          };
608        };
609        delete pResult;  
610        if ( !ID ){
611          printf("\n No file with name %s in the DB!\n",l2filename.Data());
612        } else {
613          nr = 0;
614          rlist[0] = 0;
615          myquery.str("");
616          myquery << "select ";
617          myquery << " ID,ID_ROOT_L0 ";
618          myquery << " from GL_RUN where ID_ROOT_L2=" << ID << ";";    
619          pResult = dbc->Query(myquery.str().c_str());
620          for( r=0; r < pResult->GetRowCount(); r++){
621            Row = pResult->Next();      
622            if( Row == NULL ) break;
623            found = true;
624            if ( !r ) printf("\n File %s contains the following runs: \n\n",l2filename.Data());
625            printf(" %u ",(UInt_t)atoll(Row->GetField(0)));
626            if ( r < (pResult->GetRowCount()-1) ){
627              printf("-");
628            } else {
629              printf("\n\n");
630            };
631            if ( (UInt_t)atoll(Row->GetField(1)) != rlist[nr] ){
632              nr++;
633              rlist[nr] = (UInt_t)atoll(Row->GetField(1));
634            };
635          };
636          delete pResult;  
637          //
638          printf("\n File %s contains runs from L0 files: \n\n",l2filename.Data());
639          for (UInt_t l=1; l<nr+1; l++){
640            myquery.str("");
641            myquery << "select ";
642            myquery << " PATH,NAME";
643            myquery << " from GL_ROOT where ID=" << rlist[l] << ";";    
644            pResult = dbc->Query(myquery.str().c_str());
645            for( r=0; r < pResult->GetRowCount(); r++){
646              Row = pResult->Next();      
647              if( Row == NULL ) break;
648              for( t = 0; t < pResult->GetFieldCount(); t++){
649                if(t==0) rawpath = Row->GetField(t);
650                if(t==1) rawname = Row->GetField(t);
651            };
652              printf(" %s/%s \n",rawpath,rawname);
653            };
654            delete pResult;  
655          };
656        };
657      };  
658      //
659    // Close the DB connection    // Close the DB connection
660    //    //
661    if ( dbc ) dbc->Close();    if ( dbc ) dbc->Close();

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.23