/[PAMELA software]/YodaProfiler/src/PamelaDBOperations.cpp
ViewVC logotype

Diff of /YodaProfiler/src/PamelaDBOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by mocchiut, Mon Dec 4 11:32:07 2006 UTC revision 1.28 by mocchiut, Wed Feb 14 10:55:00 2007 UTC
# Line 56  string getTleDatetime(cTle*); Line 56  string getTleDatetime(cTle*);
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);
# Line 79  PamelaDBOperations::PamelaDBOperations(T Line 79  PamelaDBOperations::PamelaDBOperations(T
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("");
# Line 215  void PamelaDBOperations::SetRootName(TSt Line 215  void PamelaDBOperations::SetRootName(TSt
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;
# Line 273  Bool_t PamelaDBOperations::SetID_RAW(){ Line 280  Bool_t PamelaDBOperations::SetID_RAW(){
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();
# Line 315  Int_t PamelaDBOperations::SetUpperLimits Line 323  Int_t PamelaDBOperations::SetUpperLimits
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");
# Line 334  Int_t PamelaDBOperations::SetUpperLimits Line 344  Int_t PamelaDBOperations::SetUpperLimits
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();
# Line 360  Int_t PamelaDBOperations::SetUpperLimits Line 386  Int_t PamelaDBOperations::SetUpperLimits
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      //      //
# Line 438  Int_t PamelaDBOperations::SetUpperLimits Line 468  Int_t PamelaDBOperations::SetUpperLimits
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;  
572      };      };
573    };    kikko0:
574   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());  
575      //      //
 //    if ( IsDebug() ) printf(" k %i rtev beforev %i  pt %i upperp %i ot %llu uppero %llu \n",k,rtev,pktt,spktt,obtt,sobtt);  
576      //      //
577      if ( pktt < spktt && obtt < sobtt ){      pktt = 0LL;
578        if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev);      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    //    //
# Line 778  void PamelaDBOperations::CheckConnection Line 812  void PamelaDBOperations::CheckConnection
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
# Line 789  void PamelaDBOperations::CheckConnection Line 826  void PamelaDBOperations::CheckConnection
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    
# Line 797  void PamelaDBOperations::CheckConnection Line 837  void PamelaDBOperations::CheckConnection
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    };    };
# Line 819  Long64_t PamelaDBOperations::PKT(UInt_t Line 859  Long64_t PamelaDBOperations::PKT(UInt_t
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    //    //
# Line 1373  Int_t PamelaDBOperations::assignBOOT_NUM Line 1413  Int_t PamelaDBOperations::assignBOOT_NUM
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 ){
# Line 2883  Int_t PamelaDBOperations::insertCALO_CAL Line 2923  Int_t PamelaDBOperations::insertCALO_CAL
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          //                //      

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.23