| 1352 |
// |
// |
| 1353 |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
| 1354 |
// |
// |
| 1355 |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
| 1356 |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
| 1357 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
| 1358 |
}; |
}; |
| 2317 |
// |
// |
| 2318 |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
| 2319 |
// |
// |
| 2320 |
|
// what about pth=ptht-1 |
| 2321 |
}; |
}; |
| 2322 |
}; |
}; |
| 2323 |
// |
// |
| 2380 |
// if ( ptt+1 == rtev){ |
// if ( ptt+1 == rtev){ |
| 2381 |
if ( conptt+1 == nrtev ){ |
if ( conptt+1 == nrtev ){ |
| 2382 |
// if ( conptt+1 == (nrtev+nrtbef )){ |
// if ( conptt+1 == (nrtev+nrtbef )){ |
| 2383 |
|
if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt); |
| 2384 |
ptht++; |
ptht++; |
| 2385 |
if ( ptht < rhev ){ |
if ( ptht < rhev ){ |
| 2386 |
rh->GetEntry(ptht); |
rh->GetEntry(ptht); |
| 2387 |
|
//pth++; |
| 2388 |
|
//if ( pth < rhev ){ |
| 2389 |
|
//rh->GetEntry(pth); |
| 2390 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
| 2391 |
pkth = phh->GetCounter(); |
pkth = phh->GetCounter(); |
| 2392 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 2411 |
if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1); |
if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1); |
| 2412 |
// |
// |
| 2413 |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
| 2414 |
rt->GetEntry(ptt-1); |
// rt->GetEntry(ptt-1); |
| 2415 |
|
rt->GetEntry(rtev-1); |
| 2416 |
cod = eht->GetCounter(); |
cod = eht->GetCounter(); |
| 2417 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics)+1; |
| 2418 |
evbefh = TMath::Max(chminentry,tcod); |
evbefh = TMath::Max(chminentry,tcod); |
| 2419 |
// evbefh = cod->Get(pctp->Physics); |
// evbefh = cod->Get(pctp->Physics); |
| 2420 |
rt->GetEntry(ptt); |
rt->GetEntry(ptt); |
| 3248 |
// |
// |
| 3249 |
} else { |
} else { |
| 3250 |
// |
// |
| 3251 |
if ( IsDebug() ) printf(" There are no-phyics packets inside the run!\n"); |
if ( IsDebug() ) printf(" There are no-physics packets inside the run!\n"); |
| 3252 |
// |
// |
| 3253 |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
| 3254 |
// |
// |
| 3258 |
UInt_t check = 0; |
UInt_t check = 0; |
| 3259 |
UInt_t lastevtemp = lastev; |
UInt_t lastevtemp = lastev; |
| 3260 |
UInt_t firstevno = firstev; |
UInt_t firstevno = firstev; |
| 3261 |
|
UInt_t rhchko=0; |
| 3262 |
|
UInt_t rhchk=0; |
| 3263 |
// |
// |
| 3264 |
for (UInt_t i=firstev; i<=lastev; i++){ |
for (UInt_t i=firstev; i<=lastev; i++){ |
| 3265 |
// |
// |
| 3268 |
// |
// |
| 3269 |
check = 0; |
check = 0; |
| 3270 |
// |
// |
| 3271 |
|
|
| 3272 |
|
// if we have a runheader set lastev then exit |
| 3273 |
|
// |
| 3274 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 3275 |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
| 3276 |
}; |
}; |
| 3277 |
|
// check here if we have a runheader |
| 3278 |
|
rhchko = rhchk; |
| 3279 |
|
rhchk = code->Get(GetPacketType("RunHeader")); |
| 3280 |
// |
// |
| 3281 |
if ( checkfirst < check || i == lastev ){ |
if ( checkfirst < check || i == lastev ){ |
| 3282 |
// |
// |
| 3693 |
// |
// |
| 3694 |
}; |
}; |
| 3695 |
// |
// |
| 3696 |
|
if ( i > firstev ){ |
| 3697 |
|
if ( rhchko != rhchk ){ |
| 3698 |
|
if ( IsDebug() ) printf("oh oh... we have a runheader! stop here and handle later the remaining piece\n"); |
| 3699 |
|
lastev = i; |
| 3700 |
|
return(false); |
| 3701 |
|
}; |
| 3702 |
|
}; |
| 3703 |
|
// |
| 3704 |
if ( check == checklast && i != lastev ){ |
if ( check == checklast && i != lastev ){ |
| 3705 |
lastevtemp = i - 1; |
lastevtemp = i - 1; |
| 3706 |
i = lastev - 1; |
i = lastev - 1; |
| 6082 |
// 2) get the OBT of the last validated run |
// 2) get the OBT of the last validated run |
| 6083 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
| 6084 |
oss.str(""); |
oss.str(""); |
| 6085 |
oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
// oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
| 6086 |
|
oss << " SELECT * FROM GL_RUN WHERE VALIDATION>0 AND RUNHEADER_TIME<="<< t_start |
| 6087 |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
| 6088 |
if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
| 6089 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 6226 |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
| 6227 |
|
|
| 6228 |
if( !CHECK && this_run->VALIDATION ){ |
if( !CHECK && this_run->VALIDATION ){ |
| 6229 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
// for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
| 6230 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],this_run->VALIDATION); |
| 6231 |
nseq=0; |
nseq=0; |
| 6232 |
} |
} |
| 6233 |
|
|
| 6248 |
if( CHECK ){ |
if( CHECK ){ |
| 6249 |
// check if calibration exists |
// check if calibration exists |
| 6250 |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
| 6251 |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
// Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
| 6252 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
UInt_t MISSING = MissingTRK_CALIB(t1,t2); |
| 6253 |
|
UInt_t val = 0; |
| 6254 |
|
if ( MISSING == 1 ) val = 0; |
| 6255 |
|
if ( MISSING == 0 ) val = 1; |
| 6256 |
|
if ( MISSING == 2 ) val = 2; |
| 6257 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],val); |
| 6258 |
nseq=0; |
nseq=0; |
| 6259 |
}; |
}; |
| 6260 |
//-------------- |
//-------------- |
| 6284 |
* @param t2 To absolute time |
* @param t2 To absolute time |
| 6285 |
* @return true if there might be a missing calibration |
* @return true if there might be a missing calibration |
| 6286 |
*/ |
*/ |
| 6287 |
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
//Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 6288 |
|
UInt_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 6289 |
|
|
| 6290 |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
| 6291 |
|
|
| 6292 |
// get the closest calibration before the run start (t2) |
// get the closest calibration before the run start (t2) |
| 6293 |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
// if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
| 6294 |
|
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(1); //>>> missing |
| 6295 |
|
|
| 6296 |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
// if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
| 6297 |
|
if ( trkcalib->TO_TIME < t2 ) return(1); //>>> missing |
| 6298 |
|
|
| 6299 |
//============================================================== |
//============================================================== |
| 6300 |
// Check is done first on the basis of time between calibration, |
// Check is done first on the basis of time between calibration, |
| 6311 |
//============================================================== |
//============================================================== |
| 6312 |
Bool_t DOWNLOAD = false; |
Bool_t DOWNLOAD = false; |
| 6313 |
// check if the calib was skipped becouse of download .... DA FARE!! |
// check if the calib was skipped becouse of download .... DA FARE!! |
| 6314 |
if(DOWNLOAD)return(false); |
// if(DOWNLOAD)return(false); |
| 6315 |
|
if(DOWNLOAD)return(0); |
| 6316 |
|
|
| 6317 |
return(true); //>>> missing |
// return(true); //>>> missing |
| 6318 |
|
return(1); //>>> missing |
| 6319 |
|
|
| 6320 |
}; |
}; |
| 6321 |
|
|
| 6325 |
//============================================================== |
//============================================================== |
| 6326 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
| 6327 |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
| 6328 |
return(false); |
if ( trkcalib->VALIDATION ) return(0); |
| 6329 |
|
if ( IsDebug() )printf("Calibration is not validated... :-/ ==> OK but with VALIDATION=2! \n"); |
| 6330 |
|
return(2); |
| 6331 |
|
|
| 6332 |
}; |
}; |
| 6333 |
/** |
/** |
| 6336 |
* @param validation true/false |
* @param validation true/false |
| 6337 |
*/ |
*/ |
| 6338 |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
| 6339 |
|
return(this->assignVALIDATION(idrun,(UInt_t)validation)); |
| 6340 |
|
} |
| 6341 |
|
|
| 6342 |
|
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, UInt_t validation){ |
| 6343 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 6344 |
stringstream oss; |
stringstream oss; |
| 6345 |
oss.str(""); |
oss.str(""); |
| 6536 |
stringstream myquery; |
stringstream myquery; |
| 6537 |
// |
// |
| 6538 |
myquery.str(""); |
myquery.str(""); |
| 6539 |
myquery << " SELECT ID, ID_RAW FROM GL_ROOT where NAME='"<<remfile.Data() <<"';"; |
myquery << " SELECT ID,ID_RAW,ID_TIMESYNC FROM GL_ROOT where NAME='"<<remfile.Data() <<"';"; |
| 6540 |
// |
// |
| 6541 |
pResult = conn->Query(myquery.str().c_str()); |
pResult = conn->Query(myquery.str().c_str()); |
| 6542 |
// |
// |
| 6552 |
// |
// |
| 6553 |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
| 6554 |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
| 6555 |
|
UInt_t idtsy=(UInt_t)atoll(Row->GetField(2)); |
| 6556 |
// |
// |
| 6557 |
this->ValidationOFF(); |
this->ValidationOFF(); |
| 6558 |
// |
// |
| 6560 |
// |
// |
| 6561 |
this->RemoveRUNS(); |
this->RemoveRUNS(); |
| 6562 |
// |
// |
| 6563 |
this->RemoveFILES(); |
this->RemoveFILES(idtsy); |
| 6564 |
// |
// |
| 6565 |
this->SetID_ROOT(0); |
this->SetID_ROOT(0); |
| 6566 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
| 6780 |
* Rearrange calibration tables |
* Rearrange calibration tables |
| 6781 |
* |
* |
| 6782 |
**/ |
**/ |
| 6783 |
void PamelaDBOperations::RemoveFILES(){ |
void PamelaDBOperations::RemoveFILES(UInt_t idtsy){ |
| 6784 |
stringstream myquery; |
stringstream myquery; |
| 6785 |
// |
// |
| 6786 |
myquery.str(""); |
myquery.str(""); |
| 6790 |
// |
// |
| 6791 |
conn->Query(myquery.str().c_str()); |
conn->Query(myquery.str().c_str()); |
| 6792 |
// |
// |
| 6793 |
|
myquery.str(""); |
| 6794 |
|
myquery << " DELETE FROM GL_ROOT WHERE ID=" <<this->GetID_ROOT() <<";"; |
| 6795 |
|
// |
| 6796 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
| 6797 |
|
// |
| 6798 |
|
conn->Query(myquery.str().c_str()); // |
| 6799 |
|
// |
| 6800 |
|
if ( !chewbacca ){ |
| 6801 |
|
myquery.str(""); |
| 6802 |
|
myquery << " DELETE FROM GL_TIMESYNC WHERE ID=" << idtsy <<";"; |
| 6803 |
|
// |
| 6804 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
| 6805 |
|
// |
| 6806 |
|
conn->Query(myquery.str().c_str()); |
| 6807 |
|
}; |
| 6808 |
|
// |
| 6809 |
}; |
}; |
| 6810 |
|
|
| 6811 |
/** |
/** |