--- DarthVader/src/R2-D2.cpp 2006/09/19 09:17:50 1.8 +++ DarthVader/src/R2-D2.cpp 2006/09/25 11:49:39 1.10 @@ -30,8 +30,8 @@ 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 ID_RUN: ID number of the run \n"); - printf("\n -filename output yoda filename \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"); @@ -39,6 +39,8 @@ printf("\n -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); printf("\n -runat time returns run number which contains the given date,\n"); printf("\n for time use the SQL format \"yyyy-mm-dd hh:mm:ss\" \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("\nExamples: \n"); printf("\n R2-D2 -idRun 1085 \n"); printf("\n R2-D2 -filename DW_050208_00900.root \n"); @@ -75,11 +77,16 @@ // // printf(" host %s user %s psw %s \n",host.Data(),user.Data(),psw.Data()); // - TString tzone = "MSK"; + TString tzone = "UTC"; TString runtime = "1970-01-01 00:00:00"; UInt_t dbti = 0; Bool_t convert = false; Bool_t ruti = false; + Bool_t convobt = false; + Bool_t convobtts = false; + // + UInt_t obt = 0; + TString tsfile = ""; // TSQLResult *pResult; TSQLRow *Row; @@ -136,6 +143,25 @@ psw = (TString)inps[i+1]; }; // + if ( !strcmp(inps[i],"-tsfile") ) { + convobtts = true; + if ( numinp-1 < i+1 ){ + r2d2usage(); + exit(-3); + }; + tsfile = (TString)inps[i+1]; + }; + // + if ( !strcmp(inps[i],"-obt") ) { + convobt = true; + if ( numinp-1 < i+1 ){ + r2d2usage(); + exit(-3); + }; + obt = (UInt_t)atoll(inps[i+1]); + }; + // + // if ( !strcmp(inps[i],"-tzone") ) { if ( numinp-1 < i+1 ){ r2d2usage(); @@ -195,6 +221,33 @@ printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data()); }; // + // + // + if ( convobt && convobtts ){ + UInt_t id = 0; + myquery.str(""); + myquery << "select "; + myquery << " ID"; + myquery << " from GL_ROOT where NAME=\"" << tsfile.Data() << "\";"; + pResult = dbc->Query(myquery.str().c_str()); + if ( pResult ){ + Row = pResult->Next(); + if ( Row ){ + id = (UInt_t)atoll(Row->GetField(0)); + delete pResult; + GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc); + UInt_t abtime = ctime->DBabsTime(obt); + TString UTC="UTC"; + TString thetime = dbtime->ConvertTime(tzone,abtime); + 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()); + delete ctime; + }; + }; + }; + if ( (convobt && !convobtts) || (convobtts && !convobt) ){ + printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n"); + }; + // // Which run contains the date "runtime"? // if ( ruti ){