--- YodaProfiler/src/R2-D2.cpp 2006/11/27 14:25:35 1.5 +++ YodaProfiler/src/R2-D2.cpp 2007/01/11 16:04:16 1.10 @@ -28,30 +28,31 @@ // void r2d2usage(){ printf("\nUsage:\n"); - printf("\n R2-D2 [-h | --help] [--version] [-idRun ID_RUN] [-filename filename]\n"); - printf("\n [-host host] [-user username] [-psw password] \n"); - printf("\n --version print informations about compilation and exit\n"); - printf("\n -h | --help print this help and exit \n"); - printf("\n -v | --verbose be verbose [default: print nothing on STDOUT]\n"); - printf("\n -idRun run ID_RUN: ID number of the run \n"); - printf("\n -filename file output yoda filename \n"); - printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); - printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); - printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); - printf("\n -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); - printf("\n -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); - printf("\n -runat date returns run number which contains the given date,\n"); - printf("\n for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); - printf("\n -runatDB time returns run number which contains the given DB time\n"); - printf("\n -tsfile file yoda filename for the time sync (to be used with -obt)\n"); - printf("\n -obt OBT OBT in ms returns a date (to be used with -tsfile)\n"); - printf("\n -getRTime OBT OBT in ms returns Resurs time (to be used with -tsfile)\n"); - printf("\n -dumpTLEfor date save into file tle.txt the TLE for the given date,\n"); - printf("\n for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); + printf("\n R2-D2 [ options ]\n"); + printf("\n Options are:\n\n"); + printf(" --version print informations about compilation and exit\n"); + printf(" -h | --help print this help and exit \n"); + printf(" -v | --verbose be verbose [default: print nothing on STDOUT]\n"); + printf(" -idRun run ID_RUN: ID number of the run \n"); + printf(" -filename file output yoda filename \n"); + printf(" -l2filename file output amidala filename \n"); + printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); + printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n"); + printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n"); + printf(" -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); + printf(" -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); + printf(" -runat date returns run number which contains the given date,\n"); + printf(" for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); + printf(" -runatDB time returns run number which contains the given DB time\n"); + printf(" -tsfile file yoda filename for the time sync (to be used with -obt)\n"); + printf(" -obt OBT OBT in ms returns a date (to be used with -tsfile)\n"); + printf(" -getRTime OBT OBT in ms returns Resurs time (to be used with -tsfile)\n"); + printf(" -dumpTLEfor date save into file tle.txt the TLE for the given date,\n"); + printf(" for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); printf("\nExamples: \n"); - printf("\n R2-D2 -idRun 1085 \n"); - printf("\n R2-D2 -filename DW_050208_00900.root \n"); - printf("\n R2-D2 -idRun 1085 -filename DW_050208_00900.root \n"); + printf(" R2-D2 -idRun 1085 \n"); + printf(" R2-D2 -filename DW_050208_00900.root \n"); + printf(" R2-D2 -idRun 1085 -filename DW_050208_00900.root \n\n"); }; // // Here the main @@ -66,6 +67,7 @@ UInt_t run = 0ULL; // TString filename = ""; + TString l2filename = ""; // TSQLServer *dbc = 0; TString host = "mysql://localhost/pamelaprod"; @@ -134,6 +136,13 @@ }; filename = (TString)inps[i+1]; }; + if ( !strcmp(inps[i],"-l2filename") ) { + if ( numinp-1 < i+1 ){ + r2d2usage(); + exit(-3); + }; + l2filename = (TString)inps[i+1]; + }; if ( !strcmp(inps[i],"-host") ) { if ( numinp-1 < i+1 ){ r2d2usage(); @@ -259,6 +268,8 @@ GL_ROOT *glroot = new GL_ROOT(); GL_RUN *glrun = new GL_RUN(); GL_TIMESYNC *dbtime = new GL_TIMESYNC(); + UInt_t nr = 0; + UInt_t rlist[500]; // // At which date correspond the DB time "dbti"? // @@ -469,7 +480,7 @@ exit(-4); }; printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); - filename = glroot->NAME; + //filename = glroot->NAME; found = true; }; // @@ -568,6 +579,83 @@ }; }; // + // Which runs are contained in the file "l2filename"? + // + if ( strcmp(l2filename.Data(),"") ){ + // ---------------- + Bool_t found = false; + Int_t ID = 0; + Int_t ID_RAW = 0; + // + const char *rawpath = ""; + const char *rawname = ""; + // + myquery.str(""); + myquery << "select "; + myquery << " ID"; + myquery << ",ID_RAW"; + myquery << ",PATH"; + myquery << ",NAME"; + myquery << " from GL_ROOT where NAME=\"" << l2filename.Data() << "\";"; + pResult = dbc->Query(myquery.str().c_str()); + for( r=0; r < 1000; r++){ + Row = pResult->Next(); + if( Row == NULL ) break; + for( t = 0; t < pResult->GetFieldCount(); t++){ + if(t==0) ID = atoi(Row->GetField(t)); + if(t==1) ID_RAW = atoi(Row->GetField(t)); + }; + }; + delete pResult; + if ( !ID ){ + printf("\n No file with name %s in the DB!\n",l2filename.Data()); + } else { + nr = 0; + rlist[0] = 0; + myquery.str(""); + myquery << "select "; + myquery << " ID,ID_ROOT_L0 "; + myquery << " from GL_RUN where ID_ROOT_L2=" << ID << ";"; + pResult = dbc->Query(myquery.str().c_str()); + for( r=0; r < pResult->GetRowCount(); r++){ + Row = pResult->Next(); + if( Row == NULL ) break; + found = true; + if ( !r ) printf("\n File %s contains the following runs: \n\n",l2filename.Data()); + printf(" %u ",(UInt_t)atoll(Row->GetField(0))); + if ( r < (pResult->GetRowCount()-1) ){ + printf("-"); + } else { + printf("\n\n"); + }; + if ( (UInt_t)atoll(Row->GetField(1)) != rlist[nr] ){ + nr++; + rlist[nr] = (UInt_t)atoll(Row->GetField(1)); + }; + }; + delete pResult; + // + printf("\n File %s contains runs from L0 files: \n\n",l2filename.Data()); + for (UInt_t l=1; lQuery(myquery.str().c_str()); + for( r=0; r < pResult->GetRowCount(); r++){ + Row = pResult->Next(); + if( Row == NULL ) break; + for( t = 0; t < pResult->GetFieldCount(); t++){ + if(t==0) rawpath = Row->GetField(t); + if(t==1) rawname = Row->GetField(t); + }; + printf(" %s/%s \n",rawpath,rawname); + }; + delete pResult; + }; + }; + }; + // // Close the DB connection // if ( dbc ) dbc->Close();