| 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, UInt_t dwinput){ |
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 |
// |
// |
| 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(); |
| 493 |
// |
// |
| 494 |
if ( rhev || rtev ){ |
if ( rhev || rtev ){ |
| 495 |
|
|
| 496 |
|
T->GetEntry(upperentry); |
| 497 |
T->GetEntry(upperentry); |
code = eh->GetCounter(); |
| 498 |
code = eh->GetCounter(); |
Int_t lasttrail = code->Get(pctp->RunTrailer); |
| 499 |
Int_t lasttrail = code->Get(pctp->RunTrailer); |
Int_t lasthead = code->Get(pctp->RunHeader); |
| 500 |
Int_t lasthead = code->Get(pctp->RunHeader); |
if ( lasttrail < rtev ){ |
| 501 |
if ( lasttrail < rtev ){ |
rt->GetEntry(lasttrail); |
| 502 |
rt->GetEntry(lasttrail); |
pht = eht->GetPscuHeader(); |
| 503 |
pht = eht->GetPscuHeader(); |
pktt = PKT(pht->GetCounter()); |
| 504 |
pktt = PKT(pht->GetCounter()); |
obtt = OBT(pht->GetOrbitalTime()); |
| 505 |
obtt = OBT(pht->GetOrbitalTime()); |
}; |
| 506 |
}; |
// |
| 507 |
// |
if ( lasthead < rhev ){ |
| 508 |
if ( lasthead < rhev ){ |
rh->GetEntry(lasthead); |
| 509 |
rh->GetEntry(lasthead); |
phh = ehh->GetPscuHeader(); |
| 510 |
phh = ehh->GetPscuHeader(); |
pkth = PKT(phh->GetCounter()); |
| 511 |
pkth = PKT(phh->GetCounter()); |
obth = OBT(phh->GetOrbitalTime()); |
| 512 |
obth = OBT(phh->GetOrbitalTime()); |
}; |
| 513 |
}; |
// |
| 514 |
// |
if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 515 |
if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
if ( pkth > upperpkt && obth > upperobt ){ |
| 516 |
if ( 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); |
| 517 |
if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %lld upperp %lld oh %lld uppero %lld \n",pkth,upperpkt,obth,upperobt); |
upperpkt = pkth; |
| 518 |
upperpkt = pkth; |
upperobt = obth; |
| 519 |
upperobt = obth; |
rhev = lasthead+1; |
| 520 |
rhev = lasthead+1; |
} else { |
| 521 |
} else { |
rhev = lasthead; |
| 522 |
rhev = lasthead; |
}; |
| 523 |
}; |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 524 |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
// |
| 525 |
// |
if ( IsDebug() ) printf(" rtev beforev %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 526 |
if ( IsDebug() ) printf(" rtev beforev %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
if ( pktt > upperpkt && obtt > upperobt ){ |
| 527 |
if ( 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); |
| 528 |
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %lld upperp %lld ot %lld uppero %lld \n",pktt,upperpkt,obtt,upperobt); |
upperpkt = pktt; |
| 529 |
upperpkt = pktt; |
upperobt = obtt; |
| 530 |
upperobt = obtt; |
rtev = lasttrail+1; |
| 531 |
rtev = lasttrail+1; |
} else { |
| 532 |
} else { |
rtev = lasttrail; |
| 533 |
rtev = lasttrail; |
}; |
| 534 |
}; |
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 535 |
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
// goto kikko; |
| 536 |
// goto kikko; |
// |
| 537 |
// |
// |
| 538 |
// |
// Check if runtrailer/runheader are within lower limits |
| 539 |
// Check if runtrailer/runheader are within lower limits |
// |
| 540 |
// |
// |
| 541 |
// |
pkth = 0LL; |
| 542 |
pkth = 0LL; |
obth = 0LL; |
| 543 |
obth = 0LL; |
spkth = 0LL; |
| 544 |
spkth = 0LL; |
sobth = 0LL; |
| 545 |
sobth = 0LL; |
for (Int_t k=0; k<rhev; k++){ |
| 546 |
for (Int_t k=0; k<rhev; k++){ |
if ( k > 0 ){ |
| 547 |
if ( k > 0 ){ |
spkth = pkth; |
| 548 |
spkth = pkth; |
sobth = obth; |
| 549 |
sobth = obth; |
}; |
| 550 |
}; |
rh->GetEntry(k); |
| 551 |
rh->GetEntry(k); |
phh = ehh->GetPscuHeader(); |
| 552 |
phh = ehh->GetPscuHeader(); |
pkth = PKT(phh->GetCounter()); |
| 553 |
pkth = PKT(phh->GetCounter()); |
obth = OBT(phh->GetOrbitalTime()); |
| 554 |
obth = OBT(phh->GetOrbitalTime()); |
// |
| 555 |
// |
// 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(" k %i rhev before %i ph %u upperp %u oh %u uppero %u \n",k,rhev,pkth,spkth,obth,sobth); |
// |
| 557 |
// |
if ( pkth < spkth && obth < sobth ){ |
| 558 |
if ( pkth < spkth && obth < sobth ){ |
if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i \n",rhev); |
| 559 |
if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i \n",rhev); |
// |
| 560 |
// |
rhev = k-1; |
| 561 |
rhev = k-1; |
rh->GetEntry(rhev); |
| 562 |
rh->GetEntry(rhev); |
pkth = spkth; |
| 563 |
pkth = spkth; |
obth = sobth; |
| 564 |
obth = sobth; |
// |
| 565 |
// |
UInt_t evbefh = 0; |
| 566 |
UInt_t evbefh = 0; |
code = ehh->GetCounter(); |
| 567 |
code = ehh->GetCounter(); |
evbefh = code->Get(pctp->Physics); |
| 568 |
evbefh = code->Get(pctp->Physics); |
if ( evbefh >= 0 ){ |
| 569 |
if ( evbefh >= 0 ){ |
T->GetEntry(evbefh); |
|
T->GetEntry(evbefh); |
|
|
ph = eh->GetPscuHeader(); |
|
|
t_pktlast = PKT(ph->GetCounter()); |
|
|
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: |
| 597 |
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()); |
|
| 598 |
// |
// |
|
// if ( IsDebug() ) printf(" k %i rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",k,rtev,pktt,spktt,obtt,sobtt); |
|
| 599 |
// |
// |
| 600 |
if ( pktt < spktt && obtt < sobtt ){ |
pktt = 0LL; |
| 601 |
if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); |
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 |
}; |
// |
|
if ( IsDebug() ) printf(" rtev after %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |
|
|
// |
|
|
|
|
|
|
|
| 702 |
}; |
}; |
| 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); |
| 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 > 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: ob 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) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
| 888 |
|
// |
| 889 |
|
if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
| 890 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
| 891 |
}; |
}; |
| 892 |
// |
// |
| 1005 |
if ( idr ) return(1); |
if ( idr ) return(1); |
| 1006 |
// |
// |
| 1007 |
oss.str(""); |
oss.str(""); |
| 1008 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1009 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
| 1010 |
|
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
| 1011 |
|
} else { |
| 1012 |
|
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
| 1013 |
|
}; |
| 1014 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
| 1015 |
// |
// |
| 1016 |
idr = this->SetID_RAW(); |
idr = this->SetID_RAW(); |
| 1291 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
| 1292 |
// |
// |
| 1293 |
oss.str(""); |
oss.str(""); |
| 1294 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
if ( STATIC ){ |
| 1295 |
<< " LEFT JOIN GL_ROOT " |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1296 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
<< " LEFT JOIN GL_ROOT " |
| 1297 |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1298 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1299 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1300 |
|
} else { |
| 1301 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1302 |
|
<< " LEFT JOIN GL_ROOT " |
| 1303 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1304 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
| 1305 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1306 |
|
}; |
| 1307 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1308 |
// |
// |
| 1309 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
| 1330 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
| 1331 |
// |
// |
| 1332 |
oss.str(""); |
oss.str(""); |
| 1333 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1334 |
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1335 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
| 1336 |
|
} else { |
| 1337 |
|
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1338 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
| 1339 |
|
}; |
| 1340 |
// |
// |
| 1341 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
| 1342 |
// |
// |
| 1363 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 1364 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 1365 |
oss.str(""); |
oss.str(""); |
| 1366 |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
if ( STATIC ){ |
| 1367 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1368 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1369 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1370 |
|
} else { |
| 1371 |
|
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1372 |
|
<< " PATH = '$PAM_RAW' AND " |
| 1373 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1374 |
|
}; |
| 1375 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1376 |
// |
// |
| 1377 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
| 2971 |
// |
// |
| 2972 |
} else { |
} else { |
| 2973 |
// |
// |
| 2974 |
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 %i obt %i pkt %i \n",section,fromtime,obt,pkt); |
| 2975 |
// |
// |
| 2976 |
}; |
}; |
| 2977 |
// |
// |