--- YodaProfiler/src/GLTables.cpp 2007/11/26 07:58:00 1.36 +++ YodaProfiler/src/GLTables.cpp 2008/03/07 10:35:15 1.38 @@ -1280,6 +1280,9 @@ // uptime = (UInt_t)atoll(Row->GetField(2)); // + UInt_t myfromtime = (UInt_t)atoll(Row->GetField(1)); + UInt_t mytotime = (UInt_t)atoll(Row->GetField(2)); + // // if it is corrupted validation is 0 and we have no results from the query... // if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 @@ -1301,6 +1304,28 @@ // Row = pResult->Next(); // + myfromtime = (UInt_t)atoll(Row->GetField(1)); + // + }; + // + // if the selected calibration is too old (more than 5 orbits old) try to take the closest not corrupted one + // + if ( (time-myfromtime)>28500 ){ + // + myquery.str(""); + myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALO_CALIB where SECTION=" << section; + myquery << " and VALIDATION=1 ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; + if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; + this->GetGLTABLES()->AddQ(); + 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 @@ -1308,8 +1333,8 @@ if( Row == NULL ) return (-54); for( t = 0; t < pResult->GetFieldCount(); 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==1) FROM_TIME = myfromtime; + if (t==2) TO_TIME = mytotime; if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); }; pResult->Delete(); @@ -1707,7 +1732,9 @@ */ Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ // - if ( obt < (obtfirst/2) && obtfirst > (numeric_limits::max()/2) ) return((Long64_t)(obt+numeric_limits::max())); + if ( obt < (obtfirst/2) && obtfirst > (numeric_limits::max()/2) ){ + return((Long64_t)obt+(Long64_t)numeric_limits::max()); + }; // if ( obt > (obtfirst*2) && obt > (numeric_limits::max()/2) ){ return((Long64_t)obt-(Long64_t)numeric_limits::max());