--- YodaProfiler/src/GLTables.cpp 2007/10/19 07:47:52 1.32 +++ YodaProfiler/src/GLTables.cpp 2007/10/25 13:23:36 1.34 @@ -24,6 +24,7 @@ ClassImp(GL_PARAM); ClassImp(GL_S4_CALIB); ClassImp(GL_CALO_CALIB); +ClassImp(GL_CALOPULSE_CALIB); ClassImp(GL_TIMESYNC); ClassImp(GL_TLE); // @@ -63,8 +64,6 @@ return true; }; // - // - // // printf(" host is %s \n",fHost->Data()); // stringstream myquery; @@ -85,7 +84,7 @@ }; }; }; - // printf("porca di quella \n"); + // if ( true ) { // printf(" WARNING: Lost connection to DB! try to recover... \n"); @@ -100,8 +99,6 @@ myquery << "show databases;"; dbc->Query(myquery.str().c_str()); fNquery++; - // printf(" e riporca di quella \n"); - // // if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ if ( !(dbc->GetErrorCode()) ){ // @@ -249,6 +246,25 @@ FROM_TIME = 0; TO_TIME = 0; SECTION = 0; + OBT = 0; + PKT = 0; + BOOT_NUMBER = 0; + VALIDATION = 0; +} + +GL_CALOPULSE_CALIB::GL_CALOPULSE_CALIB(){ + ID = 0; + ID_ROOT_L0 = 0; + EV_ROOT = 0; + FROM_TIME = 0; + TO_TIME = 0; + SECTION = 0; + PULSED_STRIP = 0; + PULSE_AMPLITUDE = 0; + OBT = 0; + PKT = 0; + BOOT_NUMBER = 0; + VALIDATION = 0; } GL_S4_CALIB::GL_S4_CALIB(){ @@ -257,8 +273,9 @@ EV_ROOT = 0; FROM_TIME = 0; TO_TIME = 0; - PARAM_FIT0 = 0.; - PARAM_FIT1 = 0.; + OBT = 0; + PKT = 0; + BOOT_NUMBER = 0; } GL_TIMESYNC::GL_TIMESYNC(){ @@ -1297,6 +1314,54 @@ pResult->Delete(); return 0; }; + + +// **************************************************** +/** + * Function to query the GL_CALOPULSE_CALIB table of the DB. + * + * \param run starting time + * \return struct of type GL_CALOPULSE_CALIB_data, which stores the query result + */ +Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){ + // MySQL variables + TSQLResult *pResult; + TSQLRow *Row; + int t; + stringstream myquery; + // + // select the correct calibration i.e. the closest to our time + // + myquery.str(""); + myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALOPULSE_CALIB where SECTION=" << section; + myquery << " and PULSE_AMPLITUDE=" << pampli; + myquery << " and VALIDATION=1 and (PULSED_STRIP IS NULL OR PULSED_STRIP<100) ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; + // printf(" myq is %s \n",myquery.str().c_str()); + // + if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; + this->GetGLTABLES()->AddQ(); + pResult = dbc->Query(myquery.str().c_str()); + // + if( !pResult ) return(-54); + // + Row = pResult->Next(); + // + if( !Row ) return (-54); + // + // store infos and exit + // + for( t = 0; t < pResult->GetFieldCount(); t++){ + // printf(" field %i is %s \n",t,Row->GetField(t)); + if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); + }; + pResult->Delete(); + return 0; +}; + + // **************************************************** /** * Function to query the GL_S4_CALIB table of the DB. @@ -1313,7 +1378,7 @@ stringstream myquery; // ---------------- myquery.str(""); - myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time; + myquery << "select ID,ID_ROOT_L0,EV_ROOT,FROM_TIME,TO_TIME from GL_S4_CALIB where FROM_TIME <= "<< time; myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; // myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; @@ -1325,12 +1390,10 @@ if( Row == NULL ) break; for( t = 0; t < pResult->GetFieldCount(); 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 = (UInt_t)atoll(Row->GetField(t)); - if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t==5) PARAM_FIT0 = atof(Row->GetField(t)); - if (t==6) PARAM_FIT1 = atof(Row->GetField(t)); + if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t==2) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); + if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); }; }; delete pResult; @@ -1525,7 +1588,7 @@ if ( pResult ){ Row = pResult->Next(); if ( Row ){ - printf(" GREAT! the DB structure is the new one! \n"); + // printf(" GREAT! the DB structure is the new one! \n"); fndit = true; dworbit = 1; };