| 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){ | 
| 60 | // | // | 
| 61 | // | // | 
| 62 | SetConnection(host,user,password); | SetConnection(host,user,password); | 
| 79 | INSERT_ROOT = !filerootname.IsNull(); | INSERT_ROOT = !filerootname.IsNull(); | 
| 80 | if( INSERT_ROOT ){ | if( INSERT_ROOT ){ | 
| 81 | this->SetRootName(filerootname); | this->SetRootName(filerootname); | 
| 82 | this->SetOrbitNo(); | this->SetOrbitNo(dwinput); | 
| 83 | file = TFile::Open(this->GetRootName().Data()); | file = TFile::Open(this->GetRootName().Data()); | 
| 84 | } else { | } else { | 
| 85 | this->SetRootName(""); | this->SetRootName(""); | 
| 215 | /** | /** | 
| 216 | * Store the downlink orbit number from filename. | * Store the downlink orbit number from filename. | 
| 217 | */ | */ | 
| 218 | void PamelaDBOperations::SetOrbitNo(){ | void PamelaDBOperations::SetOrbitNo(UInt_t dwinput){ | 
| 219 | dworbit = 0; | dworbit = 0; | 
| 220 |  | // | 
| 221 |  | if ( dwinput ){ | 
| 222 |  | dworbit = dwinput; | 
| 223 |  | if ( IsDebug() ) printf(" Downlink orbit given by hand: %i  \n",dworbit); | 
| 224 |  | return; | 
| 225 |  | }; | 
| 226 |  | // | 
| 227 | TString name = this->GetRootFile(); | TString name = this->GetRootFile(); | 
| 228 | Int_t nlength = name.Length(); | Int_t nlength = name.Length(); | 
| 229 | if ( nlength < 5 ) return; | if ( nlength < 5 ) return; | 
| 280 | oss << "SELECT ID FROM GL_RAW WHERE " | oss << "SELECT ID FROM GL_RAW WHERE " | 
| 281 | << " PATH = '" << this->GetRawPath().Data() << "' AND " | << " PATH = '" << this->GetRawPath().Data() << "' AND " | 
| 282 | << " NAME = '" << this->GetRawFile().Data() << "' "; | << " NAME = '" << this->GetRawFile().Data() << "' "; | 
| 283 |  |  | 
| 284 | result = conn->Query(oss.str().c_str()); | result = conn->Query(oss.str().c_str()); | 
| 285 | if ( result == NULL ) throw -4; | if ( result == NULL ) throw -4; | 
| 286 | row = result->Next(); | row = result->Next(); | 
| 323 | Long64_t deltapkt = 5000LL; | Long64_t deltapkt = 5000LL; | 
| 324 | Long64_t deltaobt = 50000LL; | Long64_t deltaobt = 50000LL; | 
| 325 | // | // | 
| 326 | //   pcksList packetsNames; | pcksList packetsNames; | 
| 327 | //   pcksList::iterator Iter; | pcksList::iterator Iter; | 
| 328 | //   getPacketsNames(packetsNames); | getPacketsNames(packetsNames); | 
| 329 | // | // | 
| 330 | pktfirst = 0; | pktfirst = 0; | 
| 331 | obtfirst = 0; | obtfirst = 0; | 
| 332 |  | ppktfirst = 0; | 
| 333 |  | pobtfirst = 0; | 
| 334 | // | // | 
| 335 | TTree *T = 0; | TTree *T = 0; | 
| 336 | T = (TTree*)file->Get("Physics"); | T = (TTree*)file->Get("Physics"); | 
| 344 | ph = eh->GetPscuHeader(); | ph = eh->GetPscuHeader(); | 
| 345 | pktfirst = ph->GetCounter(); | pktfirst = ph->GetCounter(); | 
| 346 | obtfirst = ph->GetOrbitalTime(); | obtfirst = ph->GetOrbitalTime(); | 
| 347 |  | ppktfirst = pktfirst; | 
| 348 |  | pobtfirst = obtfirst; | 
| 349 | // | // | 
| 350 | //   code = eh->GetCounter(); | code = eh->GetCounter(); | 
| 351 | //   UInt_t en = 0; | UInt_t en = 0; | 
| 352 | //   for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ | for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ | 
| 353 | //     en = code->Get(GetPacketType(*Iter)); | en = code->Get(GetPacketType(*Iter)); | 
| 354 | //     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) ){ | 
| 355 | //}; | if ( IsDebug() ) printf(" We have a calibration before the first physic packet: packet type is %s, entries: %i \n",*Iter,en); | 
| 356 |  | // | 
| 357 |  | TTree *TC = 0; | 
| 358 |  | TC = (TTree*)file->Get("CalibCalPed"); | 
| 359 |  | if ( !TC || TC->IsZombie() ) throw -16; | 
| 360 |  | EventHeader *ehc = 0; | 
| 361 |  | PscuHeader *phc = 0; | 
| 362 |  | TC->SetBranchAddress("Header", &ehc); | 
| 363 |  | TC->GetEntry(0); | 
| 364 |  | phc = ehc->GetPscuHeader(); | 
| 365 |  | pktfirst = phc->GetCounter(); | 
| 366 |  | obtfirst = phc->GetOrbitalTime(); | 
| 367 |  | // | 
| 368 |  | }; | 
| 369 |  | }; | 
| 370 | // | // | 
| 371 | T->GetEntry(nevent-1); | T->GetEntry(nevent-1); | 
| 372 | ph = eh->GetPscuHeader(); | ph = eh->GetPscuHeader(); | 
| 386 | if ( !nevent ) return(2); | if ( !nevent ) return(2); | 
| 387 | // | // | 
| 388 | if ( nevent < 2 ) return(4); | if ( nevent < 2 ) return(4); | 
| 389 |  | if ( nevent < jump ) jump = 1; | 
| 390 |  | //  if ( nevent < jump ) jump = int(nevent/10); | 
| 391 |  | //  if ( !jump ) jump = 1; | 
| 392 | // | // | 
| 393 | 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 ){ | 
| 394 | // | // | 
| 395 |  | if ( IsDebug() ) printf(" starting jump %i \n",jump); | 
| 396 | // go back | // go back | 
| 397 | zomp = nevent - 2; | zomp = nevent - 2; | 
| 398 | // | // | 
| 468 | Long64_t pkth = 0LL; | Long64_t pkth = 0LL; | 
| 469 | Long64_t obth = 0LL; | Long64_t obth = 0LL; | 
| 470 | // | // | 
| 471 | T->GetEntry(upperentry); | if ( rhev || rtev ){ | 
| 472 | code = eh->GetCounter(); |  | 
| 473 | Int_t lasttrail = code->Get(pctp->RunTrailer); | T->GetEntry(upperentry); | 
| 474 | Int_t lasthead = code->Get(pctp->RunHeader); | code = eh->GetCounter(); | 
| 475 | if ( lasttrail < rtev ){ | Int_t lasttrail = code->Get(pctp->RunTrailer); | 
| 476 | rt->GetEntry(lasttrail); | Int_t lasthead = code->Get(pctp->RunHeader); | 
| 477 | pht = eht->GetPscuHeader(); | if ( lasttrail < rtev ){ | 
| 478 | pktt = PKT(pht->GetCounter()); | rt->GetEntry(lasttrail); | 
| 479 | obtt = OBT(pht->GetOrbitalTime()); | pht = eht->GetPscuHeader(); | 
| 480 | }; | pktt = PKT(pht->GetCounter()); | 
| 481 | // | obtt = OBT(pht->GetOrbitalTime()); | 
| 482 | if ( lasthead < rhev ){ | }; | 
| 483 | rh->GetEntry(lasthead); | // | 
| 484 | phh = ehh->GetPscuHeader(); | if ( lasthead < rhev ){ | 
| 485 | pkth = PKT(phh->GetCounter()); | rh->GetEntry(lasthead); | 
| 486 | obth = OBT(phh->GetOrbitalTime()); | phh = ehh->GetPscuHeader(); | 
| 487 | }; | pkth = PKT(phh->GetCounter()); | 
| 488 | // | obth = OBT(phh->GetOrbitalTime()); | 
| 489 | if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); | }; | 
| 490 | if ( pkth > upperpkt && obth > upperobt ){ | // | 
| 491 | 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); | 
| 492 | upperpkt = pkth; | if ( pkth > upperpkt && obth > upperobt ){ | 
| 493 | 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); | 
| 494 | rhev = lasthead+1; | upperpkt = pkth; | 
| 495 | } else { | upperobt = obth; | 
| 496 | rhev = lasthead; | rhev = lasthead+1; | 
| 497 | }; | } else { | 
| 498 | if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); | rhev = lasthead; | 
| 499 | // | }; | 
| 500 | 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); | 
| 501 | if ( pktt > upperpkt && obtt > upperobt ){ | // | 
| 502 | 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); | 
| 503 | upperpkt = pktt; | if ( pktt > upperpkt && obtt > upperobt ){ | 
| 504 | 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); | 
| 505 | rtev = lasttrail+1; | upperpkt = pktt; | 
| 506 | } else { | upperobt = obtt; | 
| 507 | rtev = lasttrail; | rtev = lasttrail+1; | 
| 508 | }; | } else { | 
| 509 | if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); | rtev = lasttrail; | 
| 510 | //  goto kikko; | }; | 
| 511 | // | if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); | 
| 512 | // | //  goto kikko; | 
| 513 | // Check if runtrailer/runheader are within lower limits | // | 
| 514 | // | // | 
| 515 | // | // Check if runtrailer/runheader are within lower limits | 
| 516 | pkth = 0LL; | // | 
| 517 | obth = 0LL; | // | 
| 518 | spkth = 0LL; | pkth = 0LL; | 
| 519 | sobth = 0LL; | obth = 0LL; | 
| 520 | for (Int_t k=0; k<rhev; k++){ | spkth = 0LL; | 
| 521 | if ( k > 0 ){ | sobth = 0LL; | 
| 522 | spkth = pkth; | for (Int_t k=0; k<rhev; k++){ | 
| 523 | sobth = obth; | if ( k > 0 ){ | 
| 524 | }; | spkth = pkth; | 
| 525 | rh->GetEntry(k); | sobth = obth; | 
| 526 | phh = ehh->GetPscuHeader(); | }; | 
| 527 | pkth = PKT(phh->GetCounter()); | rh->GetEntry(k); | 
| 528 | obth = OBT(phh->GetOrbitalTime()); | phh = ehh->GetPscuHeader(); | 
| 529 | // | pkth = PKT(phh->GetCounter()); | 
| 530 | //    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()); | 
| 531 | // | // | 
| 532 | 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); | 
| 533 | if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i  \n",rhev); | // | 
| 534 | // | if ( pkth < spkth && obth < sobth ){ | 
| 535 | rhev = k-1; | if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i  \n",rhev); | 
| 536 | rh->GetEntry(rhev); | // | 
| 537 | pkth = spkth; | rhev = k-1; | 
| 538 | obth = sobth; | rh->GetEntry(rhev); | 
| 539 | // | pkth = spkth; | 
| 540 | UInt_t evbefh = 0; | obth = sobth; | 
| 541 | code = ehh->GetCounter(); | // | 
| 542 | evbefh = code->Get(pctp->Physics); | UInt_t evbefh = 0; | 
| 543 | if ( evbefh >= 0 ){ | code = ehh->GetCounter(); | 
| 544 | T->GetEntry(evbefh); | evbefh = code->Get(pctp->Physics); | 
| 545 | ph = eh->GetPscuHeader(); | if ( evbefh >= 0 ){ | 
| 546 | 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); |  | 
| 547 | ph = eh->GetPscuHeader(); | ph = eh->GetPscuHeader(); | 
| 548 | upperpkt = PKT(ph->GetCounter()); | t_pktlast = PKT(ph->GetCounter()); | 
| 549 | upperobt = OBT(ph->GetOrbitalTime()); | t_obtlast = OBT(ph->GetOrbitalTime()); | 
| 550 | upperentry = evbefh-1; | if ( t_pktlast <= spkth && t_obtlast <= sobth ){ // jump | 
| 551 | }; | upperpkt = pkth; | 
| 552 |  | upperobt = obth; | 
| 553 |  | upperentry = evbefh-1; | 
| 554 |  | } else { | 
| 555 |  | while ( t_pktlast > spkth && t_obtlast > sobth && evbefh < nevent ){ | 
| 556 |  | evbefh++; | 
| 557 |  | T->GetEntry(evbefh); | 
| 558 |  | ph = eh->GetPscuHeader(); | 
| 559 |  | t_pktlast = PKT(ph->GetCounter()); | 
| 560 |  | t_obtlast = OBT(ph->GetOrbitalTime()); | 
| 561 |  | }; | 
| 562 |  | T->GetEntry(evbefh-1); | 
| 563 |  | ph = eh->GetPscuHeader(); | 
| 564 |  | upperpkt = PKT(ph->GetCounter()); | 
| 565 |  | upperobt = OBT(ph->GetOrbitalTime()); | 
| 566 |  | upperentry = evbefh-1; | 
| 567 |  | }; | 
| 568 |  | }; | 
| 569 |  | if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); | 
| 570 |  | goto kikko0; | 
| 571 | }; | }; | 
|  | if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |  | 
|  | goto 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; |  | 
| 572 | }; | }; | 
| 573 | rt->GetEntry(k); | kikko0: | 
|  | pht = eht->GetPscuHeader(); |  | 
|  | pktt = PKT(pht->GetCounter()); |  | 
|  | obtt = OBT(pht->GetOrbitalTime()); |  | 
| 574 | // | // | 
|  | //    if ( IsDebug() ) printf(" k %i rtev beforev %i  pt %i upperp %i ot %llu uppero %llu \n",k,rtev,pktt,spktt,obtt,sobtt); |  | 
| 575 | // | // | 
| 576 | if ( pktt < spktt && obtt < sobtt ){ | // | 
| 577 | if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); | pktt = 0LL; | 
| 578 |  | obtt = 0LL; | 
| 579 |  | spktt = 0LL; | 
| 580 |  | sobtt = 0LL; | 
| 581 |  | for (Int_t k=0; k<rtev; k++){ | 
| 582 |  | if ( k > 0 ){ | 
| 583 |  | spktt = pktt; | 
| 584 |  | sobtt = obtt; | 
| 585 |  | }; | 
| 586 |  | rt->GetEntry(k); | 
| 587 |  | pht = eht->GetPscuHeader(); | 
| 588 |  | pktt = PKT(pht->GetCounter()); | 
| 589 |  | obtt = OBT(pht->GetOrbitalTime()); | 
| 590 | // | // | 
| 591 | 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); |  | 
| 592 | // | // | 
| 593 | UInt_t evbeft = 0; | if ( pktt < spktt && obtt < sobtt ){ | 
| 594 | code = eht->GetCounter(); | if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); | 
| 595 | evbeft = code->Get(pctp->Physics); | // | 
| 596 | if ( evbeft >= 0 ){ | rtev = k-1; | 
| 597 | T->GetEntry(evbeft); | rt->GetEntry(rtev); | 
| 598 | ph = eh->GetPscuHeader(); | pktt = spktt; | 
| 599 | t_pktlast = PKT(ph->GetCounter()); | obtt = sobtt; | 
| 600 | t_obtlast = OBT(ph->GetOrbitalTime()); | if ( IsDebug() ) printf(" lasttrail %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); | 
| 601 | if ( t_pktlast <= spktt && t_obtlast <= sobtt ){ // jump | // | 
| 602 | upperpkt = pktt; | UInt_t evbeft = 0; | 
| 603 | upperobt = obtt; | code = eht->GetCounter(); | 
| 604 | upperentry = evbeft-1; | evbeft = code->Get(pctp->Physics); | 
| 605 | } else { | if ( evbeft >= 0 ){ | 
| 606 | while ( t_pktlast > spktt && t_obtlast > sobtt && evbeft < nevent ){ | T->GetEntry(evbeft); | 
| 607 | evbeft++; | ph = eh->GetPscuHeader(); | 
| 608 | T->GetEntry(evbeft); | t_pktlast = PKT(ph->GetCounter()); | 
| 609 |  | t_obtlast = OBT(ph->GetOrbitalTime()); | 
| 610 |  | if ( t_pktlast <= spktt && t_obtlast <= sobtt ){ // jump | 
| 611 |  | upperpkt = pktt; | 
| 612 |  | upperobt = obtt; | 
| 613 |  | upperentry = evbeft-1; | 
| 614 |  | } else { | 
| 615 |  | while ( t_pktlast > spktt && t_obtlast > sobtt && evbeft < nevent ){ | 
| 616 |  | evbeft++; | 
| 617 |  | T->GetEntry(evbeft); | 
| 618 |  | ph = eh->GetPscuHeader(); | 
| 619 |  | t_pktlast = PKT(ph->GetCounter()); | 
| 620 |  | t_obtlast = OBT(ph->GetOrbitalTime()); | 
| 621 |  | }; | 
| 622 |  | T->GetEntry(evbeft-1); | 
| 623 | ph = eh->GetPscuHeader(); | ph = eh->GetPscuHeader(); | 
| 624 | t_pktlast = PKT(ph->GetCounter()); | upperpkt = PKT(ph->GetCounter()); | 
| 625 | t_obtlast = OBT(ph->GetOrbitalTime()); | upperobt = OBT(ph->GetOrbitalTime()); | 
| 626 |  | upperentry = evbeft-1; | 
| 627 | }; | }; | 
|  | T->GetEntry(evbeft-1); |  | 
|  | ph = eh->GetPscuHeader(); |  | 
|  | upperpkt = PKT(ph->GetCounter()); |  | 
|  | upperobt = OBT(ph->GetOrbitalTime()); |  | 
|  | upperentry = evbeft-1; |  | 
| 628 | }; | }; | 
| 629 |  | if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); | 
| 630 |  | goto kikko; | 
| 631 |  | //      break; | 
| 632 |  | // | 
| 633 | }; | }; | 
| 634 | if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); | // | 
|  | goto kikko; |  | 
|  | //      break; |  | 
|  | // |  | 
| 635 | }; | }; | 
| 636 | // | // | 
| 637 | }; | kikko: | 
| 638 | // | // | 
| 639 | kikko: | T->GetEntry(upperentry); | 
| 640 | // | code = eh->GetCounter(); | 
| 641 | T->GetEntry(upperentry); | lasttrail = code->Get(pctp->RunTrailer); | 
| 642 | code = eh->GetCounter(); | lasthead = code->Get(pctp->RunHeader); | 
| 643 | lasttrail = code->Get(pctp->RunTrailer); | if ( lasttrail < rtev ){ | 
| 644 | lasthead = code->Get(pctp->RunHeader); | rt->GetEntry(lasttrail); | 
| 645 | if ( lasttrail < rtev ){ | pht = eht->GetPscuHeader(); | 
| 646 | rt->GetEntry(lasttrail); | pktt = PKT(pht->GetCounter()); | 
| 647 | pht = eht->GetPscuHeader(); | obtt = OBT(pht->GetOrbitalTime()); | 
| 648 | pktt = PKT(pht->GetCounter()); | }; | 
| 649 | obtt = OBT(pht->GetOrbitalTime()); | // | 
| 650 | }; | if ( lasthead < rhev ){ | 
| 651 | // | rh->GetEntry(lasthead); | 
| 652 | if ( lasthead < rhev ){ | phh = ehh->GetPscuHeader(); | 
| 653 | rh->GetEntry(lasthead); | pkth = PKT(phh->GetCounter()); | 
| 654 | phh = ehh->GetPscuHeader(); | obth = OBT(phh->GetOrbitalTime()); | 
| 655 | pkth = PKT(phh->GetCounter()); | }; | 
| 656 | obth = OBT(phh->GetOrbitalTime()); | // | 
| 657 | }; | if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); | 
| 658 | // | if ( pkth > upperpkt && obth > upperobt ){ | 
| 659 | 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); | 
| 660 | if ( pkth > upperpkt && obth > upperobt ){ | upperpkt = pkth; | 
| 661 | 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; | 
| 662 | upperpkt = pkth; | rhev = lasthead+1; | 
| 663 | upperobt = obth; | } else { | 
| 664 | rhev = lasthead+1; | rhev = lasthead; | 
| 665 | } else { | }; | 
| 666 | rhev = lasthead; | if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); | 
| 667 | }; | // | 
| 668 | 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); | 
| 669 | // | if ( pktt > upperpkt && obtt > upperobt ){ | 
| 670 | 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); | 
| 671 | if ( pktt > upperpkt && obtt > upperobt ){ | upperpkt = pktt; | 
| 672 | 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; | 
| 673 | upperpkt = pktt; | rtev = lasttrail+1; | 
| 674 | upperobt = obtt; | } else { | 
| 675 | rtev = lasttrail+1; | rtev = lasttrail; | 
| 676 | } else { | }; | 
| 677 | rtev = lasttrail; | if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); | 
| 678 |  | // | 
| 679 | }; | }; | 
|  | if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt); |  | 
| 680 | // | // | 
| 681 | 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); | 
| 682 | // | // | 
| 812 | if( !conn ) throw -1; | if( !conn ) throw -1; | 
| 813 | bool connect = conn->IsConnected(); | bool connect = conn->IsConnected(); | 
| 814 | if( !connect ) throw -1; | if( !connect ) throw -1; | 
| 815 |  | // | 
| 816 |  | 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()); | 
| 817 |  | // | 
| 818 | if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; | if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; | 
| 819 | // | // | 
| 820 | // set DB timezone to UTC | // set DB timezone to UTC | 
| 826 | TSQLResult *result = 0; | TSQLResult *result = 0; | 
| 827 | result = conn->Query(oss.str().c_str()); | result = conn->Query(oss.str().c_str()); | 
| 828 | if ( !result ) throw -10; | if ( !result ) throw -10; | 
| 829 |  | oss.str(""); | 
| 830 |  | oss << "SET wait_timeout=173000;"; | 
| 831 |  | conn->Query(oss.str().c_str()); | 
| 832 | // | // | 
| 833 | }; | }; | 
| 834 |  |  | 
| 837 | */ | */ | 
| 838 | Long64_t PamelaDBOperations::PKT(UInt_t pkt_num){ | Long64_t PamelaDBOperations::PKT(UInt_t pkt_num){ | 
| 839 | // | // | 
| 840 | 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)); | 
| 841 | // | // | 
| 842 | if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2)  ){ | if ( pkt_num < (ppktfirst/2) && ppktfirst > (16777214/2)  ){ | 
| 843 | 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); | 
| 844 | return((Long64_t)pkt_num+16777215LL); | return((Long64_t)pkt_num+16777215LL); | 
| 845 | }; | }; | 
| 846 | // | // | 
| 847 | if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ | if ( pkt_num > ppktfirst*2 && pkt_num > (16777214/2) ){ | 
| 848 | 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); | 
| 849 | return((Long64_t)pkt_num-16777215LL); | return((Long64_t)pkt_num-16777215LL); | 
| 850 | }; | }; | 
| 859 | */ | */ | 
| 860 | Long64_t PamelaDBOperations::OBT(UInt_t obt){ | Long64_t PamelaDBOperations::OBT(UInt_t obt){ | 
| 861 | // | // | 
| 862 | if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); | if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); | 
| 863 | // | // | 
| 864 | if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ | if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ | 
| 865 | return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); | return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); | 
| 866 | }; | }; | 
| 867 | // | // | 
| 1413 | // | // | 
| 1414 | Int_t sgn = 0; | Int_t sgn = 0; | 
| 1415 | // | // | 
| 1416 | if ( !found ){ | if ( !found && !BOOTNO ){ | 
| 1417 | throw -29; | throw -29; | 
| 1418 | } else { | } else { | 
| 1419 | if ( afound ){ | if ( afound ){ | 
| 1747 | delete result; | delete result; | 
| 1748 | // | // | 
| 1749 | if ( signal && IsDebug() ) printf(" The run has already been inserted \n"); | if ( signal && IsDebug() ) printf(" The run has already been inserted \n"); | 
| 1750 |  | if ( !signal && IsDebug() ) printf(" The run existed and was deleted, fill the DB \n"); | 
| 1751 | return(signal); | return(signal); | 
| 1752 | }; | }; | 
| 1753 |  |  | 
| 1861 | // | // | 
| 1862 | } else { | } else { | 
| 1863 | if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); | if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); | 
| 1864 |  | return; | 
| 1865 | }; | }; | 
| 1866 | // | // | 
| 1867 | // | // | 
| 2923 | // | // | 
| 2924 | } else { | } else { | 
| 2925 | // | // | 
| 2926 | 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); | 
| 2927 | // | // | 
| 2928 | }; | }; | 
| 2929 | // | // | 
| 3134 | pkt1 = ph1->GetCounter(); | pkt1 = ph1->GetCounter(); | 
| 3135 | fromtime = this->GetAbsTime(ph1->GetOrbitalTime()); | fromtime = this->GetAbsTime(ph1->GetOrbitalTime()); | 
| 3136 | // | // | 
| 3137 | valid = 1; | //     valid = 1; | 
| 3138 | // | //     // | 
| 3139 | if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1 | //     if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1 | 
| 3140 | // | // | 
| 3141 | // | // | 
| 3142 | 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) ){ | 
| 3143 | // | // | 
| 3144 | if ( IsDebug() ) printf(" Trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1); | if ( IsDebug() ) printf(" Trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1); | 
| 3145 |  | // | 
| 3146 |  | valid = ValidateTrkCalib( caltrk1, eh1 ); | 
| 3147 |  | if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; | 
| 3148 | // | // | 
| 3149 | // Do we have the second calibration packet? | // Do we have the second calibration packet? | 
| 3150 | // | // | 
| 3161 | obt2 = ph2->GetOrbitalTime(); | obt2 = ph2->GetOrbitalTime(); | 
| 3162 | pkt2 = ph2->GetCounter(); | pkt2 = ph2->GetCounter(); | 
| 3163 | // | // | 
| 3164 | if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 | //        if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 | 
| 3165 | // | // | 
| 3166 | } else { | } else { | 
| 3167 | // | // | 
| 3192 | // | // | 
| 3193 | 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 %i pkt %i t2 is %i is good \n",obt2,pkt2,t2); | 
| 3194 | // | // | 
| 3195 |  | UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); | 
| 3196 |  | if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; | 
| 3197 |  | valid = valid & valid2; | 
| 3198 |  | // | 
| 3199 | // Handle good calib | // Handle good calib | 
| 3200 | // | // | 
| 3201 | this->HandleTRK_CALIB(true,true); | this->HandleTRK_CALIB(true,true); | 
| 4464 | // | // | 
| 4465 | }; | }; | 
| 4466 | }; | }; | 
| 4467 |  |  | 
| 4468 |  | /** | 
| 4469 |  | * | 
| 4470 |  | * Rearrange calibration tables | 
| 4471 |  | * | 
| 4472 |  | **/ | 
| 4473 |  | UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ | 
| 4474 |  |  | 
| 4475 |  | Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; | 
| 4476 |  | UInt_t timeaftercalib=120000; //2000; | 
| 4477 |  | //  ---------- | 
| 4478 |  | //  Check CRCs | 
| 4479 |  | //  ---------- | 
| 4480 |  | for(Int_t ipkt=0; ipkt<6; ipkt++){ | 
| 4481 |  | if( caltrk->crc_hcal[ipkt] )return 0; // :-( | 
| 4482 |  | for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-( | 
| 4483 |  | } | 
| 4484 |  | //  ----------------------- | 
| 4485 |  | //  Check missing packets: | 
| 4486 |  | //  ----------------------- | 
| 4487 |  | //    Readout order: | 
| 4488 |  | //    ------------------ | 
| 4489 |  | //    DSP   packet board | 
| 4490 |  | //    ------------------ | 
| 4491 |  | //    12    0      1 | 
| 4492 |  | //    10    1      1 | 
| 4493 |  | //     8    2      1 | 
| 4494 |  | //     4    3      1 | 
| 4495 |  | //     6    4      1 | 
| 4496 |  | //     2    5      1 | 
| 4497 |  | //    ------------------ | 
| 4498 |  | //    11    0      2 | 
| 4499 |  | //     9    1      2 | 
| 4500 |  | //     7    2      2 | 
| 4501 |  | //     3    3      2 | 
| 4502 |  | //     5    4      2 | 
| 4503 |  | //     1    5      2 | 
| 4504 |  | //    ------------------ | 
| 4505 |  | //  ------------------------------------------------- | 
| 4506 |  | //  Check if it is first or second calibration packet | 
| 4507 |  | //  ------------------------------------------------- | 
| 4508 |  | UInt_t build=0; | 
| 4509 |  | TString classname = caltrk->GetName(); | 
| 4510 |  | UInt_t base=0; | 
| 4511 |  | UInt_t mask=0; | 
| 4512 |  | if(classname.Contains("CalibTrk1Event")){ | 
| 4513 |  | base=12; | 
| 4514 |  | mask=0x03F000; | 
| 4515 |  | } | 
| 4516 |  | if(classname.Contains("CalibTrk2Event")){ | 
| 4517 |  | base=18; | 
| 4518 |  | mask=0xFC0000; | 
| 4519 |  | } | 
| 4520 |  | //  ------------------------------------------------- | 
| 4521 |  | //  Count number of packets and set build variable | 
| 4522 |  | //  ------------------------------------------------- | 
| 4523 |  | Int_t  npkts=0; | 
| 4524 |  | for(Int_t ipkt=0; ipkt<6; ipkt++){ | 
| 4525 |  | if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ | 
| 4526 |  | npkts++; | 
| 4527 |  | build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); | 
| 4528 |  | } | 
| 4529 |  | } | 
| 4530 |  | //    if( npkts==6 )return 1; // :-) | 
| 4531 |  |  | 
| 4532 |  | //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; | 
| 4533 |  |  | 
| 4534 |  | //  ----------------------------------------------- | 
| 4535 |  | //  If missing packets: check the acq configuration | 
| 4536 |  | //  (some DSPs might be excluded from acquisition) | 
| 4537 |  | //  ----------------------------------------------- | 
| 4538 |  |  | 
| 4539 |  | //  ----------------------------------------------- | 
| 4540 |  | //  retrieve the first run header after calib | 
| 4541 |  | //  ----------------------------------------------- | 
| 4542 |  | PacketType *pctp; | 
| 4543 |  | EventCounter *cod; | 
| 4544 |  | cod = eh->GetCounter(); | 
| 4545 |  | Int_t irun = cod->Get(pctp->RunHeader); | 
| 4546 |  | TTree *rh=(TTree*)file->Get("RunHeader"); | 
| 4547 |  | if ( !rh || rh->IsZombie() ) throw -17; | 
| 4548 |  | if( rh->GetEntries() == irun ){ | 
| 4549 |  | if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1)  -- cannot validate :-( "<<endl; | 
| 4550 |  | return 0; // :-( | 
| 4551 |  | } | 
| 4552 |  |  | 
| 4553 |  | RunHeaderEvent *run  = 0; | 
| 4554 |  | EventHeader    *hrun = 0; | 
| 4555 |  | rh->SetBranchAddress("RunHeader", &run); | 
| 4556 |  | rh->SetBranchAddress("Header", &hrun); | 
| 4557 |  | rh->GetEntry(irun); | 
| 4558 |  | //     cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; | 
| 4559 |  |  | 
| 4560 |  | if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ | 
| 4561 |  | if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; | 
| 4562 |  | return 0; // :-( | 
| 4563 |  | } | 
| 4564 |  |  | 
| 4565 |  | if( !run->RM_ACQ_AFTER_CALIB ){ | 
| 4566 |  | if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0    -- cannot validate :-( "<<endl; | 
| 4567 |  | return 0; // :-( | 
| 4568 |  | } | 
| 4569 |  |  | 
| 4570 |  | UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); | 
| 4571 |  | if( dtime > timeaftercalib ){ | 
| 4572 |  | if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; | 
| 4573 |  | return 0; // :-( | 
| 4574 |  | } | 
| 4575 |  |  | 
| 4576 |  |  | 
| 4577 |  |  | 
| 4578 |  | if( (run->ACQ_BUILD_INFO & mask) != build ){ | 
| 4579 |  | if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; | 
| 4580 |  | return 0; // :-( | 
| 4581 |  | } | 
| 4582 |  | return 1; // :-) | 
| 4583 |  |  | 
| 4584 |  | } | 
| 4585 |  |  | 
| 4586 |  | /** | 
| 4587 |  | * | 
| 4588 |  | * Check the DB (only for overlapping runs at the moment) | 
| 4589 |  | * | 
| 4590 |  | **/ | 
| 4591 |  | UInt_t PamelaDBOperations::Check(){ | 
| 4592 |  | // | 
| 4593 |  | UInt_t test = 0; | 
| 4594 |  | // | 
| 4595 |  | UInt_t thisrht = 0; | 
| 4596 |  | UInt_t thisrtt = 0; | 
| 4597 |  | UInt_t thisid = 0; | 
| 4598 |  | UInt_t prevrht = 0; | 
| 4599 |  | UInt_t prevrtt = 0; | 
| 4600 |  | UInt_t previd = 0; | 
| 4601 |  | // | 
| 4602 |  | UInt_t prevl0id = 0; | 
| 4603 |  | UInt_t thisl0id = 0; | 
| 4604 |  | // | 
| 4605 |  | stringstream oss; | 
| 4606 |  | TSQLResult *result = 0; | 
| 4607 |  | TSQLRow    *row    = 0; | 
| 4608 |  | TSQLResult *result2 = 0; | 
| 4609 |  | TSQLRow    *row2    = 0; | 
| 4610 |  | oss.str(""); | 
| 4611 |  | oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN order by RUNHEADER_TIME asc;"; | 
| 4612 |  | //  oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;"; | 
| 4613 |  | result = conn->Query(oss.str().c_str()); | 
| 4614 |  | // | 
| 4615 |  | if ( !result ) throw -4;; | 
| 4616 |  | // | 
| 4617 |  | row = result->Next(); | 
| 4618 |  | // | 
| 4619 |  | while ( row ){ | 
| 4620 |  | thisid = (UInt_t)atoll(row->GetField(0)); | 
| 4621 |  | thisl0id = (UInt_t)atoll(row->GetField(1)); | 
| 4622 |  | thisrht = (UInt_t)atoll(row->GetField(2)); | 
| 4623 |  | thisrtt = (UInt_t)atoll(row->GetField(3)); | 
| 4624 |  | // | 
| 4625 |  | //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){ | 
| 4626 |  | //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){ | 
| 4627 |  | if ( (thisrht < prevrtt) && (thisrht != prevrht) ){ | 
| 4628 |  | if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); | 
| 4629 |  | printf(" CHECK n.1 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid); | 
| 4630 |  | TString prevf = ""; | 
| 4631 |  | TString thisf = ""; | 
| 4632 |  | oss.str(""); | 
| 4633 |  | oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; | 
| 4634 |  | result2 = conn->Query(oss.str().c_str()); | 
| 4635 |  | if ( !result2 ) throw -4;; | 
| 4636 |  | row2 = result2->Next(); | 
| 4637 |  | prevf = (TString)row2->GetField(0); | 
| 4638 |  | oss.str(""); | 
| 4639 |  | oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; | 
| 4640 |  | result2 = conn->Query(oss.str().c_str()); | 
| 4641 |  | if ( !result2 ) throw -4;; | 
| 4642 |  | row2 = result2->Next(); | 
| 4643 |  | thisf = (TString)row2->GetField(0); | 
| 4644 |  | if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); | 
| 4645 |  | test = 1; | 
| 4646 |  | }; | 
| 4647 |  | // | 
| 4648 |  | if ( (thisrtt < prevrht) && (thisrht != prevrht) ){ | 
| 4649 |  | if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); | 
| 4650 |  | printf(" CHECK n.2 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid); | 
| 4651 |  | TString prevf = ""; | 
| 4652 |  | TString thisf = ""; | 
| 4653 |  | oss.str(""); | 
| 4654 |  | oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; | 
| 4655 |  | result2 = conn->Query(oss.str().c_str()); | 
| 4656 |  | if ( !result2 ) throw -4;; | 
| 4657 |  | row2 = result2->Next(); | 
| 4658 |  | prevf = (TString)row2->GetField(0); | 
| 4659 |  | oss.str(""); | 
| 4660 |  | oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; | 
| 4661 |  | result2 = conn->Query(oss.str().c_str()); | 
| 4662 |  | if ( !result2 ) throw -4;; | 
| 4663 |  | row2 = result2->Next(); | 
| 4664 |  | thisf = (TString)row2->GetField(0); | 
| 4665 |  | if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); | 
| 4666 |  | test = 1; | 
| 4667 |  | }; | 
| 4668 |  | // | 
| 4669 |  | if ( (thisrht > thisrtt) && (thisrht != prevrht) ){ | 
| 4670 |  | if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt); | 
| 4671 |  | printf(" CHECK n.3 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid); | 
| 4672 |  | TString prevf = ""; | 
| 4673 |  | TString thisf = ""; | 
| 4674 |  | oss.str(""); | 
| 4675 |  | oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; | 
| 4676 |  | result2 = conn->Query(oss.str().c_str()); | 
| 4677 |  | if ( !result2 ) throw -4;; | 
| 4678 |  | row2 = result2->Next(); | 
| 4679 |  | prevf = (TString)row2->GetField(0); | 
| 4680 |  | oss.str(""); | 
| 4681 |  | oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";"; | 
| 4682 |  | result2 = conn->Query(oss.str().c_str()); | 
| 4683 |  | if ( !result2 ) throw -4;; | 
| 4684 |  | row2 = result2->Next(); | 
| 4685 |  | thisf = (TString)row2->GetField(0); | 
| 4686 |  | if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); | 
| 4687 |  | test = 1; | 
| 4688 |  | }; | 
| 4689 |  |  | 
| 4690 |  | // | 
| 4691 |  | prevrht = thisrht; | 
| 4692 |  | prevrtt = thisrtt; | 
| 4693 |  | previd = thisid; | 
| 4694 |  | prevl0id = thisl0id; | 
| 4695 |  | row = result->Next(); | 
| 4696 |  | }; | 
| 4697 |  | // | 
| 4698 |  | return(test); | 
| 4699 |  | // | 
| 4700 |  | }; |