--- YodaProfiler/src/GLTables.cpp 2006/09/06 12:47:18 1.6 +++ YodaProfiler/src/GLTables.cpp 2006/09/08 14:42:48 1.9 @@ -58,6 +58,7 @@ VALIDATION = 0; } + void GL_RUN::Clear() { ID = 0; ID_RUN_FRAG = 0; @@ -122,6 +123,8 @@ OBT2 = 0; PKT1 = 0; PKT2 = 0; + BOOT_NUMBER = 0; + VALIDATION = 0; } GL_CALO_CALIB::GL_CALO_CALIB(){ @@ -327,6 +330,42 @@ CAL_DSP_MASK = 0; }; +void GL_RUN::Set_GL_RUN(TSQLRow *Row){ + for( Int_t t = 0; t < 30; t++){ + if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); + if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); + if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); + if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); + if (t==11) EV_FROM = (UInt_t)atoll(Row->GetField(t)); + if (t==12) EV_TO = (UInt_t)atoll(Row->GetField(t)); + if (t==13) NEVENTS = (UInt_t)atoll(Row->GetField(t)); + if (t==14) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); + if (t==17) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==18) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); + if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); + if (t==21) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==22) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); + if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); + if (t==25) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); + if (t==26) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); + if (t==27) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==28) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); + }; + +} + /** * Function to fill the GL_RUN table of the DB. @@ -547,37 +586,38 @@ for( r=0; r < 1000; r++){ Row = pResult->Next(); if( Row == NULL ) break; +// Set_GL_RUN(Row); for( t = 0; t < pResult->GetFieldCount(); t++){ - if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); - if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); - if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); - if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); - if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); - if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); - if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); - if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); - if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); - if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); - if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); - if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); - if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); - if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); - if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); - if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); - if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); - if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); - if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); - if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); - if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); - if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); - if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); - if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); - if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); - if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); - if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); - if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); + if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); + if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); + if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); + if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); + if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); + if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); + if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); + if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); + if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); + if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); + if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); + if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); + if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); + if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); + if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); }; }; // delete pResult; @@ -721,6 +761,7 @@ * Function to query the GL_TRK_CALIB table of the DB. * * \param run starting time + * \param dbc DB server * \return struct of type GL_TRK_CALIB_data, which stores the query result */ Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ @@ -732,7 +773,7 @@ stringstream myquery; // ---------------- myquery.str(""); - myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2 from GL_TRK_CALIB where FROM_TIME <= "<< time; + myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time; myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; // myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; pResult = dbc->Query(myquery.str().c_str()); @@ -744,22 +785,25 @@ stringstream row; row.str(""); row << "0" << Row->GetField(t); // add leading 0 since we have two fields that could be "null" and we want to avoid crashes due to atoll - if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); - if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); + if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); - if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); // - if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); - if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); - if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); - if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); - }; + if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); + if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); + if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); + if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); + if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); + if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); + }; }; - delete pResult; + delete pResult; + // +// if ( TO_TIME < time ) return(51); // - if(TO_TIME < time)return(51); if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! // return 0; @@ -772,12 +816,13 @@ * \param run starting time * \return struct of type GL_CALO_CALIB_data, which stores the query result */ -Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t section, TSQLServer *dbc){ +Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; TSQLRow *Row; int t; stringstream myquery; + uptime = 0; // // select the correct calibration // @@ -785,14 +830,21 @@ myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; myquery << " and FROM_TIME <= " << time; myquery << " and TO_TIME > " << time; - myquery << " and VALIDATION=1;"; + myquery << " ;"; + //myquery << " and VALIDATION=1;"; // pResult = dbc->Query(myquery.str().c_str()); + // printf(" mysquery is %s\n",myquery.str().c_str()); + // + if( !pResult->GetRowCount() ) return(-54); + Row = pResult->Next(); + if( Row == NULL ) return (-54); + // + uptime = (UInt_t)atoll(Row->GetField(2)); // // if it is corrupted validation is 0 and we have no results from the query... // - if( !pResult->GetRowCount() ){ - // pResult->Delete(); + if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 // // in this case take relax the conditions and take the valid calibration that preceed the correct one // @@ -801,15 +853,18 @@ myquery << " and FROM_TIME <= " << time; myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; pResult = dbc->Query(myquery.str().c_str()); + // printf(" mysquery is %s\n",myquery.str().c_str()); // // if no results yet quit with error // if( !pResult->GetRowCount() ) return (-54); + // + Row = pResult->Next(); + // }; // // store infos and exit // - Row = pResult->Next(); if( Row == NULL ) return (-54); for( t = 0; t < pResult->GetFieldCount(); t++){ if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));