172 |
} |
} |
173 |
|
|
174 |
|
|
175 |
void GL_RUN::Clear() { |
void GL_RUN::Clear(Option_t *t) { |
176 |
ID = 0; |
ID = 0; |
177 |
ID_RUN_FRAG = 0; |
ID_RUN_FRAG = 0; |
178 |
ID_ROOT_L0 = 0; |
ID_ROOT_L0 = 0; |
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 && myfromtime > 0 ){ |
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(); |
1705 |
*/ |
*/ |
1706 |
UInt_t GL_TIMESYNC::ResursTime(UInt_t OBT){ |
UInt_t GL_TIMESYNC::ResursTime(UInt_t OBT){ |
1707 |
// |
// |
1708 |
return(((UInt_t)((Int_t)(this->DBobt(OBT)-this->DBobt(OBT0))/1000)+TIMESYNC)); |
return(((UInt_t)((Int_t)(this->DBobt(OBT)-this->DBobt(OBT0)/1000))+TIMESYNC)); |
1709 |
// |
// |
1710 |
}; |
}; |
1711 |
|
|
1732 |
*/ |
*/ |
1733 |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
1734 |
// |
// |
1735 |
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
1736 |
|
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
1737 |
|
}; |
1738 |
// |
// |
1739 |
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
1740 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |