| 1280 |
// |
// |
| 1281 |
uptime = (UInt_t)atoll(Row->GetField(2)); |
uptime = (UInt_t)atoll(Row->GetField(2)); |
| 1282 |
// |
// |
| 1283 |
|
UInt_t myfromtime = (UInt_t)atoll(Row->GetField(1)); |
| 1284 |
|
UInt_t mytotime = (UInt_t)atoll(Row->GetField(2)); |
| 1285 |
|
// |
| 1286 |
// if it is corrupted validation is 0 and we have no results from the query... |
// if it is corrupted validation is 0 and we have no results from the query... |
| 1287 |
// |
// |
| 1288 |
if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 |
if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 |
| 1304 |
// |
// |
| 1305 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 1306 |
// |
// |
| 1307 |
|
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
| 1308 |
|
// |
| 1309 |
|
}; |
| 1310 |
|
// |
| 1311 |
|
// if the selected calibration is too old (more than 5 orbits old) try to take the closest not corrupted one |
| 1312 |
|
// |
| 1313 |
|
if ( (time-myfromtime)>28500 ){ |
| 1314 |
|
// |
| 1315 |
|
myquery.str(""); |
| 1316 |
|
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALO_CALIB where SECTION=" << section; |
| 1317 |
|
myquery << " and VALIDATION=1 ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; |
| 1318 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
| 1319 |
|
this->GetGLTABLES()->AddQ(); |
| 1320 |
|
pResult = dbc->Query(myquery.str().c_str()); |
| 1321 |
|
// printf(" mysquery is %s\n",myquery.str().c_str()); |
| 1322 |
|
// |
| 1323 |
|
// if no results yet quit with error |
| 1324 |
|
// |
| 1325 |
|
if( !pResult->GetRowCount() ) return (-54); |
| 1326 |
|
// |
| 1327 |
|
Row = pResult->Next(); |
| 1328 |
|
// |
| 1329 |
}; |
}; |
| 1330 |
// |
// |
| 1331 |
// store infos and exit |
// store infos and exit |
| 1333 |
if( Row == NULL ) return (-54); |
if( Row == NULL ) return (-54); |
| 1334 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 1335 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 1336 |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==1) FROM_TIME = myfromtime; |
| 1337 |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) TO_TIME = mytotime; |
| 1338 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
| 1339 |
}; |
}; |
| 1340 |
pResult->Delete(); |
pResult->Delete(); |