| 56 |
* @param debug debug flag. |
* @param debug debug flag. |
| 57 |
* @param tlefilename ascii file with TLE 3 line elements. |
* @param tlefilename ascii file with TLE 3 line elements. |
| 58 |
*/ |
*/ |
| 59 |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename){ |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp){ |
| 60 |
// |
// |
| 61 |
|
STATIC=false; |
| 62 |
|
if ( staticp ) STATIC=true; |
| 63 |
// |
// |
| 64 |
SetConnection(host,user,password); |
SetConnection(host,user,password); |
| 65 |
// |
// |
| 81 |
INSERT_ROOT = !filerootname.IsNull(); |
INSERT_ROOT = !filerootname.IsNull(); |
| 82 |
if( INSERT_ROOT ){ |
if( INSERT_ROOT ){ |
| 83 |
this->SetRootName(filerootname); |
this->SetRootName(filerootname); |
| 84 |
this->SetOrbitNo(); |
this->SetOrbitNo(dwinput); |
| 85 |
file = TFile::Open(this->GetRootName().Data()); |
file = TFile::Open(this->GetRootName().Data()); |
| 86 |
} else { |
} else { |
| 87 |
this->SetRootName(""); |
this->SetRootName(""); |
| 217 |
/** |
/** |
| 218 |
* Store the downlink orbit number from filename. |
* Store the downlink orbit number from filename. |
| 219 |
*/ |
*/ |
| 220 |
void PamelaDBOperations::SetOrbitNo(){ |
void PamelaDBOperations::SetOrbitNo(UInt_t dwinput){ |
| 221 |
dworbit = 0; |
dworbit = 0; |
| 222 |
|
// |
| 223 |
|
if ( dwinput ){ |
| 224 |
|
dworbit = dwinput; |
| 225 |
|
if ( IsDebug() ) printf(" Downlink orbit given by hand: %i \n",dworbit); |
| 226 |
|
return; |
| 227 |
|
}; |
| 228 |
|
// |
| 229 |
TString name = this->GetRootFile(); |
TString name = this->GetRootFile(); |
| 230 |
Int_t nlength = name.Length(); |
Int_t nlength = name.Length(); |
| 231 |
if ( nlength < 5 ) return; |
if ( nlength < 5 ) return; |
| 263 |
tlefilename = str; |
tlefilename = str; |
| 264 |
}; |
}; |
| 265 |
|
|
| 266 |
|
TString PamelaDBOperations::GetRawPath(){ |
| 267 |
|
if ( STATIC ){ |
| 268 |
|
return((TString)gSystem->DirName(filerawname.Data())+'/'); |
| 269 |
|
} else { |
| 270 |
|
return((TString)gSystem->ExpandPathName("$PAM_RAW")+'/'); |
| 271 |
|
}; |
| 272 |
|
}; |
| 273 |
|
|
| 274 |
|
TString PamelaDBOperations::GetRootPath(){ |
| 275 |
|
if ( STATIC ){ |
| 276 |
|
return((TString)gSystem->DirName(filerootname.Data())+'/'); |
| 277 |
|
} else { |
| 278 |
|
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
| 279 |
|
}; |
| 280 |
|
}; |
| 281 |
|
|
| 282 |
/** |
/** |
| 283 |
* Store the olderthan variable |
* Store the olderthan variable |
| 284 |
* @param olderthan |
* @param olderthan |
| 295 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 296 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 297 |
oss.str(""); |
oss.str(""); |
| 298 |
oss << "SELECT ID FROM GL_RAW WHERE " |
if ( STATIC ){ |
| 299 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID FROM GL_RAW WHERE " |
| 300 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
| 301 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 302 |
|
} else { |
| 303 |
|
oss << "SELECT ID FROM GL_RAW WHERE " |
| 304 |
|
<< " PATH = '$PAM_RAW' AND " |
| 305 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 306 |
|
} |
| 307 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 308 |
if ( result == NULL ) throw -4; |
if ( result == NULL ) throw -4; |
| 309 |
row = result->Next(); |
row = result->Next(); |
| 346 |
Long64_t deltapkt = 5000LL; |
Long64_t deltapkt = 5000LL; |
| 347 |
Long64_t deltaobt = 50000LL; |
Long64_t deltaobt = 50000LL; |
| 348 |
// |
// |
| 349 |
// pcksList packetsNames; |
pcksList packetsNames; |
| 350 |
// pcksList::iterator Iter; |
pcksList::iterator Iter; |
| 351 |
// getPacketsNames(packetsNames); |
getPacketsNames(packetsNames); |
| 352 |
// |
// |
| 353 |
pktfirst = 0; |
pktfirst = 0; |
| 354 |
obtfirst = 0; |
obtfirst = 0; |
| 355 |
|
ppktfirst = 0; |
| 356 |
|
pobtfirst = 0; |
| 357 |
// |
// |
| 358 |
TTree *T = 0; |
TTree *T = 0; |
| 359 |
T = (TTree*)file->Get("Physics"); |
T = (TTree*)file->Get("Physics"); |
| 367 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 368 |
pktfirst = ph->GetCounter(); |
pktfirst = ph->GetCounter(); |
| 369 |
obtfirst = ph->GetOrbitalTime(); |
obtfirst = ph->GetOrbitalTime(); |
| 370 |
|
ppktfirst = pktfirst; |
| 371 |
|
pobtfirst = obtfirst; |
| 372 |
// |
// |
| 373 |
// code = eh->GetCounter(); |
code = eh->GetCounter(); |
| 374 |
// UInt_t en = 0; |
UInt_t en = 0; |
| 375 |
// for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 376 |
// en = code->Get(GetPacketType(*Iter)); |
en = code->Get(GetPacketType(*Iter)); |
| 377 |
// if ( en ) printf(" Packet type is %s, entries: %i \n",*Iter,en); |
if ( !strcmp("CalibCalPed",*Iter) || !strcmp("CalibTrk1",*Iter) || !strcmp("CalibTrk2",*Iter) || !strcmp("CalibS4",*Iter) ){ |
| 378 |
//}; |
if ( IsDebug() ) printf(" We have a calibration before the first physic packet: packet type is %s, entries: %i \n",*Iter,en); |
| 379 |
|
// |
| 380 |
|
TTree *TC = 0; |
| 381 |
|
TC = (TTree*)file->Get("CalibCalPed"); |
| 382 |
|
if ( !TC || TC->IsZombie() ) throw -16; |
| 383 |
|
EventHeader *ehc = 0; |
| 384 |
|
PscuHeader *phc = 0; |
| 385 |
|
TC->SetBranchAddress("Header", &ehc); |
| 386 |
|
TC->GetEntry(0); |
| 387 |
|
phc = ehc->GetPscuHeader(); |
| 388 |
|
pktfirst = phc->GetCounter(); |
| 389 |
|
obtfirst = phc->GetOrbitalTime(); |
| 390 |
|
// |
| 391 |
|
}; |
| 392 |
|
}; |
| 393 |
// |
// |
| 394 |
T->GetEntry(nevent-1); |
T->GetEntry(nevent-1); |
| 395 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 400 |
upperobt = OBT(obtlast); |
upperobt = OBT(obtlast); |
| 401 |
upperentry = nevent-1; |
upperentry = nevent-1; |
| 402 |
// |
// |
| 403 |
if ( IsDebug() ) printf(" First entries are: OBT %i pkt_num %i \n",obtfirst,pktfirst); |
if ( IsDebug() ) printf(" First entries are: OBT %u pkt_num %u \n",obtfirst,pktfirst); |
| 404 |
// |
// |
| 405 |
if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry); |
if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry); |
| 406 |
// |
// |
| 407 |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ) return(1); |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ) return(32); |
| 408 |
// |
// |
| 409 |
if ( !nevent ) return(2); |
if ( !nevent ) return(64); |
| 410 |
// |
// |
| 411 |
if ( nevent < 2 ) return(4); |
if ( nevent < 2 ) return(128); |
| 412 |
|
if ( nevent < jump ) jump = 1; |
| 413 |
|
// if ( nevent < jump ) jump = int(nevent/10); |
| 414 |
|
// if ( !jump ) jump = 1; |
| 415 |
// |
// |
| 416 |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) ){ |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) && nevent > deltapkt ){ |
| 417 |
// |
// |
| 418 |
|
if ( IsDebug() ) printf(" starting jump %i \n",jump); |
| 419 |
// go back |
// go back |
| 420 |
zomp = nevent - 2; |
zomp = nevent - 2; |
| 421 |
// |
// |
| 447 |
if ( t_pktlast < upperpkt && t_obtlast < upperobt && t_pktlast < upperpkt2 && t_obtlast < upperobt2 ){ |
if ( t_pktlast < upperpkt && t_obtlast < upperobt && t_pktlast < upperpkt2 && t_obtlast < upperobt2 ){ |
| 448 |
zomp = i + jump + 1; |
zomp = i + jump + 1; |
| 449 |
if ( zomp > nevent-2 ) zomp = nevent - 2; |
if ( zomp > nevent-2 ) zomp = nevent - 2; |
| 450 |
if ( IsDebug() ) printf(" .-. jump %i zomp %i upperpkt %lld pktlast %i upperobt %lld obtlast %u last entry is %i \n",jump,zomp,upperpkt,pktlast,upperobt,obtlast,i); |
if ( IsDebug() ) printf(" .-. jump %i zomp %i upperpkt %lld pktlast %u upperobt %lld obtlast %u last entry is %i \n",jump,zomp,upperpkt,pktlast,upperobt,obtlast,i); |
| 451 |
break; |
break; |
| 452 |
}; |
}; |
| 453 |
// |
// |
| 491 |
Long64_t pkth = 0LL; |
Long64_t pkth = 0LL; |
| 492 |
Long64_t obth = 0LL; |
Long64_t obth = 0LL; |
| 493 |
// |
// |
| 494 |
T->GetEntry(upperentry); |
if ( rhev || rtev ){ |
| 495 |
code = eh->GetCounter(); |
|
| 496 |
Int_t lasttrail = code->Get(pctp->RunTrailer); |
T->GetEntry(upperentry); |
| 497 |
Int_t lasthead = code->Get(pctp->RunHeader); |
code = eh->GetCounter(); |
| 498 |
if ( lasttrail < rtev ){ |
Int_t lasttrail = code->Get(pctp->RunTrailer); |
| 499 |
rt->GetEntry(lasttrail); |
Int_t lasthead = code->Get(pctp->RunHeader); |
| 500 |
pht = eht->GetPscuHeader(); |
if ( lasttrail < rtev ){ |
| 501 |
pktt = PKT(pht->GetCounter()); |
rt->GetEntry(lasttrail); |
| 502 |
obtt = OBT(pht->GetOrbitalTime()); |
pht = eht->GetPscuHeader(); |
| 503 |
}; |
pktt = PKT(pht->GetCounter()); |
| 504 |
// |
obtt = OBT(pht->GetOrbitalTime()); |
| 505 |
if ( lasthead < rhev ){ |
}; |
| 506 |
rh->GetEntry(lasthead); |
// |
| 507 |
phh = ehh->GetPscuHeader(); |
if ( lasthead < rhev ){ |
| 508 |
pkth = PKT(phh->GetCounter()); |
rh->GetEntry(lasthead); |
| 509 |
obth = OBT(phh->GetOrbitalTime()); |
phh = ehh->GetPscuHeader(); |
| 510 |
}; |
pkth = PKT(phh->GetCounter()); |
| 511 |
// |
obth = OBT(phh->GetOrbitalTime()); |
| 512 |
if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
}; |
| 513 |
if ( pkth > upperpkt && obth > upperobt ){ |
// |
| 514 |
if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %lld upperp %lld oh %lld uppero %lld \n",pkth,upperpkt,obth,upperobt); |
if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 515 |
upperpkt = pkth; |
if ( pkth > upperpkt && obth > upperobt ){ |
| 516 |
upperobt = obth; |
if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %lld upperp %lld oh %lld uppero %lld \n",pkth,upperpkt,obth,upperobt); |
| 517 |
rhev = lasthead+1; |
upperpkt = pkth; |
| 518 |
} else { |
upperobt = obth; |
| 519 |
rhev = lasthead; |
rhev = lasthead+1; |
| 520 |
}; |
} else { |
| 521 |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
rhev = lasthead; |
| 522 |
// |
}; |
| 523 |
if ( IsDebug() ) printf(" rtev beforev %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 524 |
if ( pktt > upperpkt && obtt > upperobt ){ |
// |
| 525 |
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %lld upperp %lld ot %lld uppero %lld \n",pktt,upperpkt,obtt,upperobt); |
if ( IsDebug() ) printf(" rtev beforev %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 526 |
upperpkt = pktt; |
if ( pktt > upperpkt && obtt > upperobt ){ |
| 527 |
upperobt = obtt; |
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %lld upperp %lld ot %lld uppero %lld \n",pktt,upperpkt,obtt,upperobt); |
| 528 |
rtev = lasttrail+1; |
upperpkt = pktt; |
| 529 |
} else { |
upperobt = obtt; |
| 530 |
rtev = lasttrail; |
rtev = lasttrail+1; |
| 531 |
}; |
} else { |
| 532 |
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
rtev = lasttrail; |
| 533 |
// goto kikko; |
}; |
| 534 |
// |
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 535 |
// |
// goto kikko; |
| 536 |
// Check if runtrailer/runheader are within lower limits |
// |
| 537 |
// |
// |
| 538 |
// |
// Check if runtrailer/runheader are within lower limits |
| 539 |
pkth = 0LL; |
// |
| 540 |
obth = 0LL; |
// |
| 541 |
spkth = 0LL; |
pkth = 0LL; |
| 542 |
sobth = 0LL; |
obth = 0LL; |
| 543 |
for (Int_t k=0; k<rhev; k++){ |
spkth = 0LL; |
| 544 |
if ( k > 0 ){ |
sobth = 0LL; |
| 545 |
spkth = pkth; |
for (Int_t k=0; k<rhev; k++){ |
| 546 |
sobth = obth; |
if ( k > 0 ){ |
| 547 |
}; |
spkth = pkth; |
| 548 |
rh->GetEntry(k); |
sobth = obth; |
| 549 |
phh = ehh->GetPscuHeader(); |
}; |
| 550 |
pkth = PKT(phh->GetCounter()); |
rh->GetEntry(k); |
| 551 |
obth = OBT(phh->GetOrbitalTime()); |
phh = ehh->GetPscuHeader(); |
| 552 |
// |
pkth = PKT(phh->GetCounter()); |
| 553 |
// if ( IsDebug() ) printf(" k %i rhev before %i ph %u upperp %u oh %u uppero %u \n",k,rhev,pkth,spkth,obth,sobth); |
obth = OBT(phh->GetOrbitalTime()); |
| 554 |
// |
// |
| 555 |
if ( pkth < spkth && obth < sobth ){ |
// if ( IsDebug() ) printf(" k %i rhev before %i ph %u upperp %u oh %u uppero %u \n",k,rhev,pkth,spkth,obth,sobth); |
| 556 |
if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i \n",rhev); |
// |
| 557 |
// |
if ( pkth < spkth && obth < sobth ){ |
| 558 |
rhev = k-1; |
if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i \n",rhev); |
| 559 |
rh->GetEntry(rhev); |
// |
| 560 |
pkth = spkth; |
rhev = k-1; |
| 561 |
obth = sobth; |
rh->GetEntry(rhev); |
| 562 |
// |
pkth = spkth; |
| 563 |
UInt_t evbefh = 0; |
obth = sobth; |
| 564 |
code = ehh->GetCounter(); |
// |
| 565 |
evbefh = code->Get(pctp->Physics); |
UInt_t evbefh = 0; |
| 566 |
if ( evbefh >= 0 ){ |
code = ehh->GetCounter(); |
| 567 |
T->GetEntry(evbefh); |
evbefh = code->Get(pctp->Physics); |
| 568 |
ph = eh->GetPscuHeader(); |
if ( evbefh >= 0 ){ |
| 569 |
t_pktlast = PKT(ph->GetCounter()); |
T->GetEntry(evbefh); |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
|
|
if ( t_pktlast <= spkth && t_obtlast <= sobth ){ // jump |
|
|
upperpkt = pkth; |
|
|
upperobt = obth; |
|
|
upperentry = evbefh-1; |
|
|
} else { |
|
|
while ( t_pktlast > spkth && t_obtlast > sobth && evbefh < nevent ){ |
|
|
evbefh++; |
|
|
T->GetEntry(evbefh); |
|
|
ph = eh->GetPscuHeader(); |
|
|
t_pktlast = PKT(ph->GetCounter()); |
|
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
|
|
}; |
|
|
T->GetEntry(evbefh-1); |
|
| 570 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 571 |
upperpkt = PKT(ph->GetCounter()); |
t_pktlast = PKT(ph->GetCounter()); |
| 572 |
upperobt = OBT(ph->GetOrbitalTime()); |
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 573 |
upperentry = evbefh-1; |
if ( t_pktlast <= spkth && t_obtlast <= sobth ){ // jump |
| 574 |
}; |
upperpkt = pkth; |
| 575 |
|
upperobt = obth; |
| 576 |
|
upperentry = evbefh-1; |
| 577 |
|
} else { |
| 578 |
|
while ( t_pktlast > spkth && t_obtlast > sobth && evbefh < nevent ){ |
| 579 |
|
evbefh++; |
| 580 |
|
T->GetEntry(evbefh); |
| 581 |
|
ph = eh->GetPscuHeader(); |
| 582 |
|
t_pktlast = PKT(ph->GetCounter()); |
| 583 |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 584 |
|
}; |
| 585 |
|
T->GetEntry(evbefh-1); |
| 586 |
|
ph = eh->GetPscuHeader(); |
| 587 |
|
upperpkt = PKT(ph->GetCounter()); |
| 588 |
|
upperobt = OBT(ph->GetOrbitalTime()); |
| 589 |
|
upperentry = evbefh-1; |
| 590 |
|
}; |
| 591 |
|
}; |
| 592 |
|
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 593 |
|
goto kikko0; |
| 594 |
}; |
}; |
|
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
|
|
goto kikko0; |
|
| 595 |
}; |
}; |
| 596 |
}; |
kikko0: |
|
kikko0: |
|
|
// |
|
|
// |
|
|
// |
|
|
pktt = 0LL; |
|
|
obtt = 0LL; |
|
|
spktt = 0LL; |
|
|
sobtt = 0LL; |
|
|
for (Int_t k=0; k<rtev; k++){ |
|
|
if ( k > 0 ){ |
|
|
spktt = pktt; |
|
|
sobtt = obtt; |
|
|
}; |
|
|
rt->GetEntry(k); |
|
|
pht = eht->GetPscuHeader(); |
|
|
pktt = PKT(pht->GetCounter()); |
|
|
obtt = OBT(pht->GetOrbitalTime()); |
|
| 597 |
// |
// |
|
// if ( IsDebug() ) printf(" k %i rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",k,rtev,pktt,spktt,obtt,sobtt); |
|
| 598 |
// |
// |
| 599 |
if ( pktt < spktt && obtt < sobtt ){ |
// |
| 600 |
if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); |
pktt = 0LL; |
| 601 |
|
obtt = 0LL; |
| 602 |
|
spktt = 0LL; |
| 603 |
|
sobtt = 0LL; |
| 604 |
|
for (Int_t k=0; k<rtev; k++){ |
| 605 |
|
if ( k > 0 ){ |
| 606 |
|
spktt = pktt; |
| 607 |
|
sobtt = obtt; |
| 608 |
|
}; |
| 609 |
|
rt->GetEntry(k); |
| 610 |
|
pht = eht->GetPscuHeader(); |
| 611 |
|
pktt = PKT(pht->GetCounter()); |
| 612 |
|
obtt = OBT(pht->GetOrbitalTime()); |
| 613 |
// |
// |
| 614 |
rtev = k-1; |
// if ( IsDebug() ) printf(" k %i rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",k,rtev,pktt,spktt,obtt,sobtt); |
|
rt->GetEntry(rtev); |
|
|
pktt = spktt; |
|
|
obtt = sobtt; |
|
|
if ( IsDebug() ) printf(" lasttrail %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
|
| 615 |
// |
// |
| 616 |
UInt_t evbeft = 0; |
if ( pktt < spktt && obtt < sobtt ){ |
| 617 |
code = eht->GetCounter(); |
if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); |
| 618 |
evbeft = code->Get(pctp->Physics); |
// |
| 619 |
if ( evbeft >= 0 ){ |
rtev = k-1; |
| 620 |
T->GetEntry(evbeft); |
rt->GetEntry(rtev); |
| 621 |
ph = eh->GetPscuHeader(); |
pktt = spktt; |
| 622 |
t_pktlast = PKT(ph->GetCounter()); |
obtt = sobtt; |
| 623 |
t_obtlast = OBT(ph->GetOrbitalTime()); |
if ( IsDebug() ) printf(" lasttrail %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 624 |
if ( t_pktlast <= spktt && t_obtlast <= sobtt ){ // jump |
// |
| 625 |
upperpkt = pktt; |
UInt_t evbeft = 0; |
| 626 |
upperobt = obtt; |
code = eht->GetCounter(); |
| 627 |
upperentry = evbeft-1; |
evbeft = code->Get(pctp->Physics); |
| 628 |
} else { |
if ( evbeft >= 0 ){ |
| 629 |
while ( t_pktlast > spktt && t_obtlast > sobtt && evbeft < nevent ){ |
T->GetEntry(evbeft); |
| 630 |
evbeft++; |
ph = eh->GetPscuHeader(); |
| 631 |
T->GetEntry(evbeft); |
t_pktlast = PKT(ph->GetCounter()); |
| 632 |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 633 |
|
if ( t_pktlast <= spktt && t_obtlast <= sobtt ){ // jump |
| 634 |
|
upperpkt = pktt; |
| 635 |
|
upperobt = obtt; |
| 636 |
|
upperentry = evbeft-1; |
| 637 |
|
} else { |
| 638 |
|
while ( t_pktlast > spktt && t_obtlast > sobtt && evbeft < nevent ){ |
| 639 |
|
evbeft++; |
| 640 |
|
T->GetEntry(evbeft); |
| 641 |
|
ph = eh->GetPscuHeader(); |
| 642 |
|
t_pktlast = PKT(ph->GetCounter()); |
| 643 |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 644 |
|
}; |
| 645 |
|
T->GetEntry(evbeft-1); |
| 646 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 647 |
t_pktlast = PKT(ph->GetCounter()); |
upperpkt = PKT(ph->GetCounter()); |
| 648 |
t_obtlast = OBT(ph->GetOrbitalTime()); |
upperobt = OBT(ph->GetOrbitalTime()); |
| 649 |
|
upperentry = evbeft-1; |
| 650 |
}; |
}; |
|
T->GetEntry(evbeft-1); |
|
|
ph = eh->GetPscuHeader(); |
|
|
upperpkt = PKT(ph->GetCounter()); |
|
|
upperobt = OBT(ph->GetOrbitalTime()); |
|
|
upperentry = evbeft-1; |
|
| 651 |
}; |
}; |
| 652 |
|
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 653 |
|
goto kikko; |
| 654 |
|
// break; |
| 655 |
|
// |
| 656 |
}; |
}; |
| 657 |
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
// |
|
goto kikko; |
|
|
// break; |
|
|
// |
|
| 658 |
}; |
}; |
| 659 |
// |
// |
| 660 |
}; |
kikko: |
| 661 |
// |
// |
| 662 |
kikko: |
T->GetEntry(upperentry); |
| 663 |
// |
code = eh->GetCounter(); |
| 664 |
T->GetEntry(upperentry); |
lasttrail = code->Get(pctp->RunTrailer); |
| 665 |
code = eh->GetCounter(); |
lasthead = code->Get(pctp->RunHeader); |
| 666 |
lasttrail = code->Get(pctp->RunTrailer); |
if ( lasttrail < rtev ){ |
| 667 |
lasthead = code->Get(pctp->RunHeader); |
rt->GetEntry(lasttrail); |
| 668 |
if ( lasttrail < rtev ){ |
pht = eht->GetPscuHeader(); |
| 669 |
rt->GetEntry(lasttrail); |
pktt = PKT(pht->GetCounter()); |
| 670 |
pht = eht->GetPscuHeader(); |
obtt = OBT(pht->GetOrbitalTime()); |
| 671 |
pktt = PKT(pht->GetCounter()); |
}; |
| 672 |
obtt = OBT(pht->GetOrbitalTime()); |
// |
| 673 |
}; |
if ( lasthead < rhev ){ |
| 674 |
// |
rh->GetEntry(lasthead); |
| 675 |
if ( lasthead < rhev ){ |
phh = ehh->GetPscuHeader(); |
| 676 |
rh->GetEntry(lasthead); |
pkth = PKT(phh->GetCounter()); |
| 677 |
phh = ehh->GetPscuHeader(); |
obth = OBT(phh->GetOrbitalTime()); |
| 678 |
pkth = PKT(phh->GetCounter()); |
}; |
| 679 |
obth = OBT(phh->GetOrbitalTime()); |
// |
| 680 |
}; |
if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 681 |
// |
if ( pkth > upperpkt && obth > upperobt ){ |
| 682 |
if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %lld upperp %lld oh %lld uppero %lld \n",pkth,upperpkt,obth,upperobt); |
| 683 |
if ( pkth > upperpkt && obth > upperobt ){ |
upperpkt = pkth; |
| 684 |
if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %lld upperp %lld oh %lld uppero %lld \n",pkth,upperpkt,obth,upperobt); |
upperobt = obth; |
| 685 |
upperpkt = pkth; |
rhev = lasthead+1; |
| 686 |
upperobt = obth; |
} else { |
| 687 |
rhev = lasthead+1; |
rhev = lasthead; |
| 688 |
} else { |
}; |
| 689 |
rhev = lasthead; |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 690 |
}; |
// |
| 691 |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
if ( IsDebug() ) printf(" rtev beforev %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 692 |
// |
if ( pktt > upperpkt && obtt > upperobt ){ |
| 693 |
if ( IsDebug() ) printf(" rtev beforev %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %lld upperp %lld ot %lld uppero %lld \n",pktt,upperpkt,obtt,upperobt); |
| 694 |
if ( pktt > upperpkt && obtt > upperobt ){ |
upperpkt = pktt; |
| 695 |
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %lld upperp %lld ot %lld uppero %lld \n",pktt,upperpkt,obtt,upperobt); |
upperobt = obtt; |
| 696 |
upperpkt = pktt; |
rtev = lasttrail+1; |
| 697 |
upperobt = obtt; |
} else { |
| 698 |
rtev = lasttrail+1; |
rtev = lasttrail; |
| 699 |
} else { |
}; |
| 700 |
rtev = lasttrail; |
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 701 |
|
// |
| 702 |
}; |
}; |
|
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
|
| 703 |
// |
// |
| 704 |
if ( IsDebug() ) printf(" Upper limits are: OBT %lld pkt_num %lld upper entry %i \n",upperobt,upperpkt,upperentry); |
if ( IsDebug() ) printf(" Upper limits are: OBT %lld pkt_num %lld upper entry %i \n",upperobt,upperpkt,upperentry); |
| 705 |
// |
// |
| 835 |
if( !conn ) throw -1; |
if( !conn ) throw -1; |
| 836 |
bool connect = conn->IsConnected(); |
bool connect = conn->IsConnected(); |
| 837 |
if( !connect ) throw -1; |
if( !connect ) throw -1; |
| 838 |
|
// |
| 839 |
|
if ( IsDebug() ) printf("\n DB INFORMATIONS:\n SQL: %s Version: %s Host %s Port %i \n\n",conn->GetDBMS(),conn->ServerInfo(),conn->GetHost(),conn->GetPort()); |
| 840 |
|
// |
| 841 |
if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; |
if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; |
| 842 |
// |
// |
| 843 |
// set DB timezone to UTC |
// set DB timezone to UTC |
| 849 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 850 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 851 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
| 852 |
|
oss.str(""); |
| 853 |
|
oss << "SET wait_timeout=173000;"; |
| 854 |
|
conn->Query(oss.str().c_str()); |
| 855 |
// |
// |
| 856 |
}; |
}; |
| 857 |
|
|
| 860 |
*/ |
*/ |
| 861 |
Long64_t PamelaDBOperations::PKT(UInt_t pkt_num){ |
Long64_t PamelaDBOperations::PKT(UInt_t pkt_num){ |
| 862 |
// |
// |
| 863 |
if ( IsDebug() ) printf(" pkt conversion: pkt_num is %u pktfirst is %u (UInt_t)(16777214/2)) is %u \n",pkt_num,pktfirst,(UInt_t)(16777214/2)); |
if ( IsDebug() ) printf(" pkt conversion: pkt_num is %u pktfirst is %u (UInt_t)(16777214/2)) is %u \n",pkt_num,ppktfirst,(UInt_t)(16777214/2)); |
| 864 |
// |
// |
| 865 |
if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ){ |
if ( pkt_num < (ppktfirst/2) && ppktfirst > (16777214/2) ){ |
| 866 |
if ( IsDebug() ) printf(" rise up pktnum %lld \n",(Long64_t)pkt_num+16777215LL); |
if ( IsDebug() ) printf(" rise up pktnum %lld \n",(Long64_t)pkt_num+16777215LL); |
| 867 |
return((Long64_t)pkt_num+16777215LL); |
return((Long64_t)pkt_num+16777215LL); |
| 868 |
}; |
}; |
| 869 |
// |
// |
| 870 |
if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ |
if ( pkt_num > ((Long64_t)ppktfirst*2) && pkt_num > (16777214/2) ){ |
| 871 |
if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL); |
if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL); |
| 872 |
return((Long64_t)pkt_num-16777215LL); |
return((Long64_t)pkt_num-16777215LL); |
| 873 |
}; |
}; |
| 882 |
*/ |
*/ |
| 883 |
Long64_t PamelaDBOperations::OBT(UInt_t obt){ |
Long64_t PamelaDBOperations::OBT(UInt_t obt){ |
| 884 |
// |
// |
| 885 |
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
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)); |
| 886 |
// |
// |
| 887 |
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
| 888 |
|
if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)(obt+numeric_limits<UInt_t>::max())); |
| 889 |
|
return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
| 890 |
|
}; |
| 891 |
|
// |
| 892 |
|
if ( obt > ((Long64_t)pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
| 893 |
|
if ( IsDebug() ) printf(" pobtfirst*2 %lld \n",((Long64_t)pobtfirst*2)); |
| 894 |
|
if ( IsDebug() ) printf(" rise down pktnum %lld \n", (Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
| 895 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
| 896 |
}; |
}; |
| 897 |
// |
// |
| 898 |
|
if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)obt); |
| 899 |
return((Long64_t)obt); |
return((Long64_t)obt); |
| 900 |
}; |
}; |
| 901 |
|
|
| 1011 |
if ( idr ) return(1); |
if ( idr ) return(1); |
| 1012 |
// |
// |
| 1013 |
oss.str(""); |
oss.str(""); |
| 1014 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1015 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
| 1016 |
|
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
| 1017 |
|
} else { |
| 1018 |
|
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
| 1019 |
|
}; |
| 1020 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
| 1021 |
// |
// |
| 1022 |
idr = this->SetID_RAW(); |
idr = this->SetID_RAW(); |
| 1035 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 1036 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 1037 |
UInt_t t0 = 0; |
UInt_t t0 = 0; |
| 1038 |
|
Int_t signal = 0; |
| 1039 |
|
// |
| 1040 |
|
signal = this->SetUpperLimits(); |
| 1041 |
// |
// |
| 1042 |
stringstream oss; |
stringstream oss; |
| 1043 |
// |
// |
| 1090 |
}; |
}; |
| 1091 |
// |
// |
| 1092 |
TTree *T = 0; |
TTree *T = 0; |
|
Int_t signal = 0; |
|
| 1093 |
// |
// |
| 1094 |
UInt_t nevent = 0; |
UInt_t nevent = 0; |
| 1095 |
UInt_t recEntries = 0; |
UInt_t recEntries = 0; |
| 1299 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
| 1300 |
// |
// |
| 1301 |
oss.str(""); |
oss.str(""); |
| 1302 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
if ( STATIC ){ |
| 1303 |
<< " LEFT JOIN GL_ROOT " |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1304 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
<< " LEFT JOIN GL_ROOT " |
| 1305 |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1306 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1307 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1308 |
|
} else { |
| 1309 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1310 |
|
<< " LEFT JOIN GL_ROOT " |
| 1311 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1312 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
| 1313 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1314 |
|
}; |
| 1315 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1316 |
// |
// |
| 1317 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
| 1338 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
| 1339 |
// |
// |
| 1340 |
oss.str(""); |
oss.str(""); |
| 1341 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1342 |
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1343 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
| 1344 |
|
} else { |
| 1345 |
|
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1346 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
| 1347 |
|
}; |
| 1348 |
// |
// |
| 1349 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
| 1350 |
// |
// |
| 1371 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 1372 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 1373 |
oss.str(""); |
oss.str(""); |
| 1374 |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
if ( STATIC ){ |
| 1375 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1376 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1377 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1378 |
|
} else { |
| 1379 |
|
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1380 |
|
<< " PATH = '$PAM_RAW' AND " |
| 1381 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1382 |
|
}; |
| 1383 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1384 |
// |
// |
| 1385 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
| 1469 |
// |
// |
| 1470 |
Int_t sgn = 0; |
Int_t sgn = 0; |
| 1471 |
// |
// |
| 1472 |
if ( !found ){ |
if ( !found && !BOOTNO ){ |
| 1473 |
throw -29; |
throw -29; |
| 1474 |
} else { |
} else { |
| 1475 |
if ( afound ){ |
if ( afound ){ |
| 1498 |
stringstream oss; |
stringstream oss; |
| 1499 |
oss.str(""); |
oss.str(""); |
| 1500 |
// |
// |
| 1501 |
signal = this->SetUpperLimits(); |
// signal = this->SetUpperLimits(); |
| 1502 |
// |
// |
| 1503 |
// loop on runheader and runtrailer events |
// loop on runheader and runtrailer events |
| 1504 |
// |
// |
| 1549 |
// |
// |
| 1550 |
if ( !ptt && !(ptht+1) ){ |
if ( !ptt && !(ptht+1) ){ |
| 1551 |
// |
// |
| 1552 |
if ( IsDebug() ) printf(" Piece of run at the beginning of the file %i %i %i \n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" Piece of run at the beginning of the file %u %u %u \n",ptht,pth,ptt); |
| 1553 |
// |
// |
| 1554 |
this->HandleRunFragments(true,false,0,(evbeft-1)); |
this->HandleRunFragments(true,false,0,(evbeft-1)); |
| 1555 |
// |
// |
| 1556 |
// |
// |
| 1557 |
} else if ( pth == ptht ){ |
} else if ( pth == ptht ){ |
| 1558 |
// |
// |
| 1559 |
if ( IsDebug() ) printf(" Missing header %i %i %i\n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" Missing header %u %u %u\n",ptht,pth,ptt); |
| 1560 |
// |
// |
| 1561 |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
| 1562 |
rt->GetEntry(ptt-1); |
rt->GetEntry(ptt-1); |
| 1565 |
rt->GetEntry(ptt); |
rt->GetEntry(ptt); |
| 1566 |
pht = eht->GetPscuHeader(); |
pht = eht->GetPscuHeader(); |
| 1567 |
// |
// |
| 1568 |
if ( IsDebug() ) printf(" Try to find the beginning of a run which has only the runtrailer %i %i %i \n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" Try to find the beginning of a run which has only the runtrailer %u %u %u \n",ptht,pth,ptt); |
| 1569 |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt); |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt); |
| 1570 |
// |
// |
| 1571 |
this->HandleMissingHoT(true,false,evbefh,evbeft-1); |
this->HandleMissingHoT(true,false,evbefh,evbeft-1); |
| 1572 |
// |
// |
| 1573 |
} else { |
} else { |
| 1574 |
// |
// |
| 1575 |
if ( IsDebug() ) printf(" Could be a good run, we have a runheader followed by a runtrailer %i %i %i\n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" Could be a good run, we have a runheader followed by a runtrailer %u %u %u\n",ptht,pth,ptt); |
| 1576 |
// |
// |
| 1577 |
rh->GetEntry(ptht); |
rh->GetEntry(ptht); |
| 1578 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
| 1580 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 1581 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
| 1582 |
evbefh = cod->Get(pctp->Physics); |
evbefh = cod->Get(pctp->Physics); |
| 1583 |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt); |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt); |
| 1584 |
// |
// |
| 1585 |
// handle this run |
// handle this run |
| 1586 |
// |
// |
| 1590 |
// |
// |
| 1591 |
if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){ |
if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){ |
| 1592 |
// |
// |
| 1593 |
if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER \n"); |
if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER evbefh = %u \n",evbefh); |
|
// |
|
|
this->HandleRunFragments(true,true,0,(evbefh-1)); |
|
| 1594 |
// |
// |
| 1595 |
|
if ( evbefh == 0 ) { |
| 1596 |
|
// |
| 1597 |
|
signal = 8; |
| 1598 |
|
if ( IsDebug() ) printf(" Not supported yet: run with no events, no runtrailer, no runheader \n"); |
| 1599 |
|
// |
| 1600 |
|
} else { |
| 1601 |
|
// |
| 1602 |
|
this->HandleRunFragments(true,true,0,(evbefh-1)); |
| 1603 |
|
// |
| 1604 |
|
}; |
| 1605 |
}; |
}; |
| 1606 |
// |
// |
| 1607 |
// |
// |
| 1608 |
if ( (ptht - pth) > 1 ){ |
if ( (ptht - pth) > 1 ){ |
| 1609 |
// |
// |
| 1610 |
if ( IsDebug() ) printf(" Missing runtrailers! \n"); |
if ( IsDebug() ) printf(" Missing runtrailers! \n"); |
| 1611 |
if ( IsDebug() ) printf(" Attention there is a jump in the runheader counter %i %i %i \n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" Attention there is a jump in the runheader counter %u %u %u \n",ptht,pth,ptt); |
| 1612 |
// is not the consecutive header |
// is not the consecutive header |
| 1613 |
while ( pth != ptht ){ |
while ( pth != ptht ){ |
| 1614 |
// |
// |
| 1629 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 1630 |
evbefh = cod->Get(pctp->Physics); |
evbefh = cod->Get(pctp->Physics); |
| 1631 |
// |
// |
| 1632 |
if ( IsDebug() ) printf(" Try to find the end of a run which has only the runheader %i %i %i \n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" Try to find the end of a run which has only the runheader %u %u %u \n",ptht,pth,ptt); |
| 1633 |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt); |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt); |
| 1634 |
// |
// |
| 1635 |
this->HandleMissingHoT(false,true,evbefh,evbeft-1); |
this->HandleMissingHoT(false,true,evbefh,evbeft-1); |
| 1636 |
// |
// |
| 1639 |
} else if ( !(ptht - pth) ){ |
} else if ( !(ptht - pth) ){ |
| 1640 |
// |
// |
| 1641 |
if ( IsDebug() ) printf(" Missing runheader! \n"); |
if ( IsDebug() ) printf(" Missing runheader! \n"); |
| 1642 |
if ( IsDebug() ) printf(" Attention! the runheader counter did not changed %i %i %i \n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" Attention! the runheader counter did not changed %u %u %u \n",ptht,pth,ptt); |
| 1643 |
if ( IsDebug() ) printf(" The run should have already been handled by HandleRun() \n"); |
if ( IsDebug() ) printf(" The run should have already been handled by HandleRun() \n"); |
| 1644 |
// |
// |
| 1645 |
} else { |
} else { |
| 1660 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 1661 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
| 1662 |
evbefh = cod->Get(pctp->Physics); |
evbefh = cod->Get(pctp->Physics); |
| 1663 |
if ( IsDebug() ) printf(" Piece of run at the end of file %i %i %i \n",pkth,obth,obtt); |
if ( IsDebug() ) printf(" Piece of run at the end of file %u %u %u \n",pkth,obth,obtt); |
| 1664 |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i %i %i \n",ptht,pth,ptt); |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u %u %u \n",ptht,pth,ptt); |
| 1665 |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i \n",rhev); |
if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u \n",rhev); |
| 1666 |
// |
// |
| 1667 |
this->HandleRunFragments(false,true,evbefh,upperentry); |
this->HandleRunFragments(false,true,evbefh,upperentry); |
| 1668 |
} else { |
} else { |
| 2062 |
ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT()); |
ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT()); |
| 2063 |
UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT()); |
UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT()); |
| 2064 |
ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT()); |
ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT()); |
| 2065 |
if ( IsDebug() ) printf(" Check overlapping events: %i %i %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
| 2066 |
TTree *T= 0; |
TTree *T= 0; |
| 2067 |
T = (TTree*)file->Get("Physics"); |
T = (TTree*)file->Get("Physics"); |
| 2068 |
if ( !T || T->IsZombie() ) throw -16; |
if ( !T || T->IsZombie() ) throw -16; |
| 2076 |
bobt = OBT(ph->GetOrbitalTime()); |
bobt = OBT(ph->GetOrbitalTime()); |
| 2077 |
firstev++; |
firstev++; |
| 2078 |
}; |
}; |
| 2079 |
if ( IsDebug() ) printf(" Check overlapping events done: %i %i %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
| 2080 |
// |
// |
| 2081 |
glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER()); |
glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER()); |
| 2082 |
glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER()); |
glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER()); |
| 2259 |
ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT()); |
ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT()); |
| 2260 |
UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT()); |
UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT()); |
| 2261 |
ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT()); |
ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT()); |
| 2262 |
if ( IsDebug() ) printf(" Check overlapping events: %i %i %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
| 2263 |
TTree *T= 0; |
TTree *T= 0; |
| 2264 |
T = (TTree*)file->Get("Physics"); |
T = (TTree*)file->Get("Physics"); |
| 2265 |
if ( !T || T->IsZombie() ) throw -16; |
if ( !T || T->IsZombie() ) throw -16; |
| 2273 |
aobt = OBT(ph->GetOrbitalTime()); |
aobt = OBT(ph->GetOrbitalTime()); |
| 2274 |
lastev--; |
lastev--; |
| 2275 |
}; |
}; |
| 2276 |
if ( IsDebug() ) printf(" Check overlapping events done: %i %i %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
| 2277 |
// |
// |
| 2278 |
glrun->SetEV_TO(lastev); |
glrun->SetEV_TO(lastev); |
| 2279 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
| 2880 |
fromtime = this->GetAbsTime(ph->GetOrbitalTime()); |
fromtime = this->GetAbsTime(ph->GetOrbitalTime()); |
| 2881 |
if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){ |
if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){ |
| 2882 |
// |
// |
| 2883 |
if ( IsDebug() ) printf(" Calo calibration for section %i at time %i obt %i pkt %i \n",section,fromtime,obt,pkt); |
if ( IsDebug() ) printf(" Calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt); |
| 2884 |
// |
// |
| 2885 |
// check if the calibration has already been inserted |
// check if the calibration has already been inserted |
| 2886 |
// |
// |
| 2925 |
// |
// |
| 2926 |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section); |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section); |
| 2927 |
if ( fromtime < 1150871000 ){ //1150866904 |
if ( fromtime < 1150871000 ){ //1150866904 |
| 2928 |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime); |
| 2929 |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
| 2930 |
}; |
}; |
| 2931 |
// |
// |
| 2987 |
// |
// |
| 2988 |
} else { |
} else { |
| 2989 |
// |
// |
| 2990 |
if ( IsDebug() ) printf(" Repetead calo calibration for section %i at time %i obt %i pkt %i \n",section,fromtime,obt,pkt); |
if ( IsDebug() ) printf(" Repeated calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt); |
| 2991 |
// |
// |
| 2992 |
}; |
}; |
| 2993 |
// |
// |
| 3205 |
// |
// |
| 3206 |
if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
| 3207 |
// |
// |
| 3208 |
if ( IsDebug() ) printf(" Trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1); |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1); |
| 3209 |
// |
// |
| 3210 |
valid = ValidateTrkCalib( caltrk1, eh1 ); |
valid = ValidateTrkCalib( caltrk1, eh1 ); |
| 3211 |
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
| 3248 |
// |
// |
| 3249 |
}; |
}; |
| 3250 |
// |
// |
| 3251 |
if ( IsDebug() ) printf(" Found trk calibration2 at obt %i pkt %i t2 is %i \n",obt2,pkt2,t2); |
if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2); |
| 3252 |
// |
// |
| 3253 |
// The calibration is good |
// The calibration is good |
| 3254 |
// |
// |
| 3255 |
if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){ |
if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){ |
| 3256 |
// |
// |
| 3257 |
if ( IsDebug() ) printf(" The trk calibration2 at obt %i pkt %i t2 is %i is good \n",obt2,pkt2,t2); |
if ( IsDebug() ) printf(" The trk calibration2 at obt %u pkt %u t2 is %u is good \n",obt2,pkt2,t2); |
| 3258 |
// |
// |
| 3259 |
UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); |
UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); |
| 3260 |
if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; |
if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; |
| 3268 |
// |
// |
| 3269 |
if ( t2 != pret2+1 ){ |
if ( t2 != pret2+1 ){ |
| 3270 |
// |
// |
| 3271 |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %i pkt %i t2 is %i pret2 is %i \n",obt2,pkt2,t2,pret2); |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u pret2 is %u \n",obt2,pkt2,t2,pret2); |
| 3272 |
// |
// |
| 3273 |
while ( t2 > pret2+1 ){ |
while ( t2 > pret2+1 ){ |
| 3274 |
// |
// |
| 3297 |
// |
// |
| 3298 |
// Check for missing calibtrk2 |
// Check for missing calibtrk2 |
| 3299 |
// |
// |
| 3300 |
if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %i pkt %i t2 is %i\n",obt2,pkt2,t2); |
if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
| 3301 |
t2 = pret2; |
t2 = pret2; |
| 3302 |
// |
// |
| 3303 |
// handle missing calib2 |
// handle missing calib2 |
| 3311 |
// |
// |
| 3312 |
} else { |
} else { |
| 3313 |
// |
// |
| 3314 |
if ( IsDebug() ) printf(" Repetead trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1); |
if ( IsDebug() ) printf(" Repetead trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1); |
| 3315 |
// |
// |
| 3316 |
}; |
}; |
| 3317 |
// |
// |
| 3336 |
valid = 0; |
valid = 0; |
| 3337 |
if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
| 3338 |
// |
// |
| 3339 |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %i pkt %i t2 is %i\n",obt2,pkt2,t2); |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
| 3340 |
// |
// |
| 3341 |
this->HandleTRK_CALIB(false,true); |
this->HandleTRK_CALIB(false,true); |
| 3342 |
// |
// |
| 3390 |
fromtime = this->GetAbsTime(ph->GetOrbitalTime()); |
fromtime = this->GetAbsTime(ph->GetOrbitalTime()); |
| 3391 |
if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){ |
if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){ |
| 3392 |
// |
// |
| 3393 |
if ( IsDebug() ) printf(" S4 calibration at time %i obt %i pkt %i \n",fromtime,obt,pkt); |
if ( IsDebug() ) printf(" S4 calibration at time %u obt %u pkt %u \n",fromtime,obt,pkt); |
| 3394 |
// |
// |
| 3395 |
// check if the calibration has already been inserted |
// check if the calibration has already been inserted |
| 3396 |
// |
// |
| 3433 |
// |
// |
| 3434 |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n"); |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n"); |
| 3435 |
if ( fromtime < 1150871000 ){ |
if ( fromtime < 1150871000 ){ |
| 3436 |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime); |
| 3437 |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
| 3438 |
}; |
}; |
| 3439 |
// |
// |
| 3492 |
// |
// |
| 3493 |
} else { |
} else { |
| 3494 |
// |
// |
| 3495 |
if ( IsDebug() ) printf(" Repetead S4 calibration at time %i obt %i pkt %i \n",fromtime,obt,pkt); |
if ( IsDebug() ) printf(" Repeated S4 calibration at time %u obt %u pkt %u \n",fromtime,obt,pkt); |
| 3496 |
// |
// |
| 3497 |
}; |
}; |
| 3498 |
// |
// |
| 3703 |
row = result->Next(); |
row = result->Next(); |
| 3704 |
t_stop = (UInt_t)atoll(row->GetField(4)); |
t_stop = (UInt_t)atoll(row->GetField(4)); |
| 3705 |
}; |
}; |
| 3706 |
if ( IsDebug() ) printf("Validation interval: from time %i - to time %i \n\n",t_stop,t_start); |
if ( IsDebug() ) printf("Validation interval: from time %u - to time %u \n\n",t_stop,t_start); |
| 3707 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
| 3708 |
// now retrieves runs to be validated |
// now retrieves runs to be validated |
| 3709 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
| 3874 |
}else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max); |
}else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max); |
| 3875 |
}; |
}; |
| 3876 |
|
|
| 3877 |
if ( IsDebug() ) printf("%i Run %i \n",nrow,this_run->ID); |
if ( IsDebug() ) printf("%i Run %u \n",nrow,this_run->ID); |
| 3878 |
nrow++; |
nrow++; |
| 3879 |
|
|
| 3880 |
}; |
}; |
| 3903 |
// which should be equal to the time between ascending-nodes. |
// which should be equal to the time between ascending-nodes. |
| 3904 |
//============================================================== |
//============================================================== |
| 3905 |
if ( t2 - trkcalib->FROM_TIME > 5700) { |
if ( t2 - trkcalib->FROM_TIME > 5700) { |
| 3906 |
if ( IsDebug() )printf("Long time between calib and run start %i :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Long time between calib and run start %u :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME); |
| 3907 |
//============================================================== |
//============================================================== |
| 3908 |
// there might be a missing calibration, due to: |
// there might be a missing calibration, due to: |
| 3909 |
// - MM full |
// - MM full |
| 3924 |
// it is enough to say that there are no missing calibrations |
// it is enough to say that there are no missing calibrations |
| 3925 |
//============================================================== |
//============================================================== |
| 3926 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
| 3927 |
if ( IsDebug() )printf("Short time between calib and run start %i :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
| 3928 |
return(false); |
return(false); |
| 3929 |
|
|
| 3930 |
}; |
}; |
| 4240 |
}; |
}; |
| 4241 |
}; |
}; |
| 4242 |
}; |
}; |
| 4243 |
if ( IsDebug() ) printf(" %i runs have been unvalidated \n",unv); |
if ( IsDebug() ) printf(" %u runs have been unvalidated \n",unv); |
| 4244 |
}; |
}; |
| 4245 |
|
|
| 4246 |
/** |
/** |
| 4271 |
if ( IsDebug() ) printf(" Deleting run from GL_RUN table \n"); |
if ( IsDebug() ) printf(" Deleting run from GL_RUN table \n"); |
| 4272 |
while ( Row ){ |
while ( Row ){ |
| 4273 |
delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN"); |
delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN"); |
| 4274 |
if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0))); |
if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0))); |
| 4275 |
drun++; |
drun++; |
| 4276 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 4277 |
}; |
}; |
| 4292 |
} else { |
} else { |
| 4293 |
if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN table \n"); |
if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN table \n"); |
| 4294 |
while ( Row ){ |
while ( Row ){ |
| 4295 |
if ( IsDebug() ) printf(" restore run %i \n",(UInt_t)atoll(Row->GetField(1))); |
if ( IsDebug() ) printf(" restore run %u \n",(UInt_t)atoll(Row->GetField(1))); |
| 4296 |
delrun->RestoreRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN_FRAGMENTS"); |
delrun->RestoreRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN_FRAGMENTS"); |
| 4297 |
if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(1))); |
if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(1))); |
| 4298 |
delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN"); |
delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN"); |
| 4299 |
if ( (UInt_t)atoll(Row->GetField(1)) != (UInt_t)atoll(Row->GetField(0)) ){ |
if ( (UInt_t)atoll(Row->GetField(1)) != (UInt_t)atoll(Row->GetField(0)) ){ |
| 4300 |
if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0))); |
if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0))); |
| 4301 |
delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN"); |
delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN"); |
| 4302 |
}; |
}; |
| 4303 |
drun++; |
drun++; |
| 4323 |
} else { |
} else { |
| 4324 |
if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_TRASH table \n"); |
if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_TRASH table \n"); |
| 4325 |
while ( Row ){ |
while ( Row ){ |
| 4326 |
if ( IsDebug() ) printf(" del run idtrash %i \n",(UInt_t)atoll(Row->GetField(0))); |
if ( IsDebug() ) printf(" del run idtrash %u \n",(UInt_t)atoll(Row->GetField(0))); |
| 4327 |
myquery.str(""); |
myquery.str(""); |
| 4328 |
myquery << " DELETE FROM GL_RUN_TRASH where ID_TRASH=" << Row->GetField(0) <<";"; |
myquery << " DELETE FROM GL_RUN_TRASH where ID_TRASH=" << Row->GetField(0) <<";"; |
| 4329 |
conn->Query(myquery.str().c_str()); |
conn->Query(myquery.str().c_str()); |
| 4332 |
}; |
}; |
| 4333 |
}; |
}; |
| 4334 |
// |
// |
| 4335 |
if ( IsDebug() ) printf(" Deleted %i run(s) from GL_RUN_TRASH table \n",drun); |
if ( IsDebug() ) printf(" Deleted %u run(s) from GL_RUN_TRASH table \n",drun); |
| 4336 |
// |
// |
| 4337 |
// |
// |
| 4338 |
// |
// |
| 4350 |
} else { |
} else { |
| 4351 |
if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_FRAGMENTS table \n"); |
if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_FRAGMENTS table \n"); |
| 4352 |
while ( Row ){ |
while ( Row ){ |
| 4353 |
if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0))); |
if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0))); |
| 4354 |
myquery.str(""); |
myquery.str(""); |
| 4355 |
myquery << " DELETE FROM GL_RUN_FRAGMENTS where ID=" << Row->GetField(0) <<";"; |
myquery << " DELETE FROM GL_RUN_FRAGMENTS where ID=" << Row->GetField(0) <<";"; |
| 4356 |
conn->Query(myquery.str().c_str()); |
conn->Query(myquery.str().c_str()); |
| 4359 |
}; |
}; |
| 4360 |
}; |
}; |
| 4361 |
// |
// |
| 4362 |
if ( IsDebug() ) printf(" Deleted %i run(s) from GL_RUN_FRAGMENTS table \n",drun); |
if ( IsDebug() ) printf(" Deleted %u run(s) from GL_RUN_FRAGMENTS table \n",drun); |
| 4363 |
// |
// |
| 4364 |
// |
// |
| 4365 |
// |
// |
| 4528 |
// |
// |
| 4529 |
}; |
}; |
| 4530 |
}; |
}; |
| 4531 |
|
|
| 4532 |
/** |
/** |
| 4533 |
* |
* |
| 4534 |
* Rearrange calibration tables |
* Rearrange calibration tables |
| 4646 |
return 1; // :-) |
return 1; // :-) |
| 4647 |
|
|
| 4648 |
} |
} |
| 4649 |
|
|
| 4650 |
|
/** |
| 4651 |
|
* |
| 4652 |
|
* Check the DB (only for overlapping runs at the moment) |
| 4653 |
|
* |
| 4654 |
|
**/ |
| 4655 |
|
UInt_t PamelaDBOperations::Check(){ |
| 4656 |
|
// |
| 4657 |
|
UInt_t test = 0; |
| 4658 |
|
// |
| 4659 |
|
UInt_t thisrht = 0; |
| 4660 |
|
UInt_t thisrtt = 0; |
| 4661 |
|
UInt_t thisid = 0; |
| 4662 |
|
UInt_t prevrht = 0; |
| 4663 |
|
UInt_t prevrtt = 0; |
| 4664 |
|
UInt_t previd = 0; |
| 4665 |
|
// |
| 4666 |
|
UInt_t prevl0id = 0; |
| 4667 |
|
UInt_t thisl0id = 0; |
| 4668 |
|
// |
| 4669 |
|
stringstream oss; |
| 4670 |
|
TSQLResult *result = 0; |
| 4671 |
|
TSQLRow *row = 0; |
| 4672 |
|
TSQLResult *result2 = 0; |
| 4673 |
|
TSQLRow *row2 = 0; |
| 4674 |
|
oss.str(""); |
| 4675 |
|
oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN order by RUNHEADER_TIME asc;"; |
| 4676 |
|
// oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;"; |
| 4677 |
|
result = conn->Query(oss.str().c_str()); |
| 4678 |
|
// |
| 4679 |
|
if ( !result ) throw -4;; |
| 4680 |
|
// |
| 4681 |
|
row = result->Next(); |
| 4682 |
|
// |
| 4683 |
|
while ( row ){ |
| 4684 |
|
thisid = (UInt_t)atoll(row->GetField(0)); |
| 4685 |
|
thisl0id = (UInt_t)atoll(row->GetField(1)); |
| 4686 |
|
thisrht = (UInt_t)atoll(row->GetField(2)); |
| 4687 |
|
thisrtt = (UInt_t)atoll(row->GetField(3)); |
| 4688 |
|
// |
| 4689 |
|
// if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){ |
| 4690 |
|
// if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){ |
| 4691 |
|
if ( (thisrht < prevrtt) && (thisrht != prevrht) ){ |
| 4692 |
|
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
| 4693 |
|
printf(" CHECK n.1 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid); |
| 4694 |
|
TString prevf = ""; |
| 4695 |
|
TString thisf = ""; |
| 4696 |
|
oss.str(""); |
| 4697 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
| 4698 |
|
result2 = conn->Query(oss.str().c_str()); |
| 4699 |
|
if ( !result2 ) throw -4;; |
| 4700 |
|
row2 = result2->Next(); |
| 4701 |
|
prevf = (TString)row2->GetField(0); |
| 4702 |
|
oss.str(""); |
| 4703 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; |
| 4704 |
|
result2 = conn->Query(oss.str().c_str()); |
| 4705 |
|
if ( !result2 ) throw -4;; |
| 4706 |
|
row2 = result2->Next(); |
| 4707 |
|
thisf = (TString)row2->GetField(0); |
| 4708 |
|
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
| 4709 |
|
test = 1; |
| 4710 |
|
}; |
| 4711 |
|
// |
| 4712 |
|
if ( (thisrtt < prevrht) && (thisrht != prevrht) ){ |
| 4713 |
|
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
| 4714 |
|
printf(" CHECK n.2 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid); |
| 4715 |
|
TString prevf = ""; |
| 4716 |
|
TString thisf = ""; |
| 4717 |
|
oss.str(""); |
| 4718 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
| 4719 |
|
result2 = conn->Query(oss.str().c_str()); |
| 4720 |
|
if ( !result2 ) throw -4;; |
| 4721 |
|
row2 = result2->Next(); |
| 4722 |
|
prevf = (TString)row2->GetField(0); |
| 4723 |
|
oss.str(""); |
| 4724 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; |
| 4725 |
|
result2 = conn->Query(oss.str().c_str()); |
| 4726 |
|
if ( !result2 ) throw -4;; |
| 4727 |
|
row2 = result2->Next(); |
| 4728 |
|
thisf = (TString)row2->GetField(0); |
| 4729 |
|
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
| 4730 |
|
test = 1; |
| 4731 |
|
}; |
| 4732 |
|
// |
| 4733 |
|
if ( (thisrht > thisrtt) && (thisrht != prevrht) ){ |
| 4734 |
|
if ( IsDebug() ) printf(" IDprev %u ID %u prevrht %u prevrtt %u thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); |
| 4735 |
|
printf(" CHECK n.3 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid); |
| 4736 |
|
TString prevf = ""; |
| 4737 |
|
TString thisf = ""; |
| 4738 |
|
oss.str(""); |
| 4739 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; |
| 4740 |
|
result2 = conn->Query(oss.str().c_str()); |
| 4741 |
|
if ( !result2 ) throw -4;; |
| 4742 |
|
row2 = result2->Next(); |
| 4743 |
|
prevf = (TString)row2->GetField(0); |
| 4744 |
|
oss.str(""); |
| 4745 |
|
oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; |
| 4746 |
|
result2 = conn->Query(oss.str().c_str()); |
| 4747 |
|
if ( !result2 ) throw -4;; |
| 4748 |
|
row2 = result2->Next(); |
| 4749 |
|
thisf = (TString)row2->GetField(0); |
| 4750 |
|
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
| 4751 |
|
test = 1; |
| 4752 |
|
}; |
| 4753 |
|
|
| 4754 |
|
// |
| 4755 |
|
prevrht = thisrht; |
| 4756 |
|
prevrtt = thisrtt; |
| 4757 |
|
previd = thisid; |
| 4758 |
|
prevl0id = thisl0id; |
| 4759 |
|
row = result->Next(); |
| 4760 |
|
}; |
| 4761 |
|
// |
| 4762 |
|
return(test); |
| 4763 |
|
// |
| 4764 |
|
}; |