/[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.16 by mocchiut, Tue Oct 31 15:36:04 2006 UTC revision 1.26 by mocchiut, Wed Jan 31 16:15:03 2007 UTC
# Line 14  Line 14 
14  #include <TSQLRow.h>  #include <TSQLRow.h>
15  #include <TTree.h>  #include <TTree.h>
16  #include <TGraph.h>  #include <TGraph.h>
17  #include <TDatime.h>  #include <TTimeStamp.h>
18  #include <TF1.h>  #include <TF1.h>
19  //  //
20  #include <EventHeader.h>  #include <EventHeader.h>
# Line 112  void PamelaDBOperations::Close(){ Line 112  void PamelaDBOperations::Close(){
112  //  //
113  void PamelaDBOperations::CheckValidate(Long64_t olderthan){  void PamelaDBOperations::CheckValidate(Long64_t olderthan){
114    clean_time = new TDatime();    clean_time = new TDatime();
115      //
116    if(olderthan >= 0){    if(olderthan >= 0){
117      VALIDATE = true;      VALIDATE = true;
118      UInt_t timelim = 0;      UInt_t timelim = 0;
119      timelim =  (UInt_t)clean_time->Convert() - olderthan;      timelim =  (UInt_t)clean_time->Convert(true) - olderthan;
120      clean_time->Set(timelim,false);      clean_time->Set(timelim,false);
121    };    };
122  };  };
# Line 156  void PamelaDBOperations::SetDebugFlag(Bo Line 157  void PamelaDBOperations::SetDebugFlag(Bo
157  };  };
158    
159  /**  /**
160     * Set the autoboot flag
161     *
162     */
163    void PamelaDBOperations::SetAutoBoot(Bool_t dbg){
164      AUTOBOOT = dbg;
165    };
166    
167    /**
168   * Set the nofrag flag   * Set the nofrag flag
169   *   *
170   */   */
# Line 264  Bool_t PamelaDBOperations::SetID_RAW(){ Line 273  Bool_t PamelaDBOperations::SetID_RAW(){
273    oss << "SELECT ID FROM GL_RAW WHERE "    oss << "SELECT ID FROM GL_RAW WHERE "
274        << " PATH = '" << this->GetRawPath().Data() << "' AND "        << " PATH = '" << this->GetRawPath().Data() << "' AND "
275        << " NAME = '" << this->GetRawFile().Data() << "' ";        << " NAME = '" << this->GetRawFile().Data() << "' ";
276    
277    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
278    if ( result == NULL ) throw -4;    if ( result == NULL ) throw -4;
279    row = result->Next();    row = result->Next();
# Line 294  Int_t PamelaDBOperations::SetUpperLimits Line 304  Int_t PamelaDBOperations::SetUpperLimits
304    UInt_t nevent = 0;    UInt_t nevent = 0;
305    UInt_t pktlast = 0;    UInt_t pktlast = 0;
306    UInt_t obtlast = 0;    UInt_t obtlast = 0;
307    UInt_t t_pktlast = 0;    Long64_t t_pktlast = 0LL;
308    UInt_t t_obtlast = 0;    //  UInt_t t_obtlast = 0;
309    UInt_t upperpkt2 = 0;    Long64_t t_obtlast = 0LL;
310    ULong64_t upperobt2 = 0;    Long64_t upperpkt2 = 0LL;
311      Long64_t upperobt2 = 0LL;
312    UInt_t zomp = 0;    UInt_t zomp = 0;
313    UInt_t jump = 50000; // was 5000    UInt_t jump = 50000; // was 5000
314    EventCounter *code=0;    EventCounter *code=0;
315    //    //
316    UInt_t deltapkt = 5000;    Long64_t deltapkt = 5000LL;
317    ULong64_t deltaobt = 50000;    Long64_t deltaobt = 50000LL;
318    //    //
319    //   pcksList packetsNames;    //   pcksList packetsNames;
320    //   pcksList::iterator Iter;    //   pcksList::iterator Iter;
# Line 341  Int_t PamelaDBOperations::SetUpperLimits Line 352  Int_t PamelaDBOperations::SetUpperLimits
352    upperobt = OBT(obtlast);    upperobt = OBT(obtlast);
353    upperentry = nevent-1;    upperentry = nevent-1;
354    //    //
355    if ( IsDebug() ) printf(" First entries are: OBT %llu pkt_num %i \n",obtfirst,pktfirst);    if ( IsDebug() ) printf(" First entries are: OBT %i pkt_num %i \n",obtfirst,pktfirst);
356    //    //
357    if ( IsDebug() ) printf(" Last entries are: OBT %llu pkt_num %i entry %i\n",upperobt,upperpkt,upperentry);    if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry);
358    //    //
359    if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ) return(1);    if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ) return(1);
360    //    //
# Line 374  Int_t PamelaDBOperations::SetUpperLimits Line 385  Int_t PamelaDBOperations::SetUpperLimits
385          upperpkt2 = PKT(ph->GetCounter());          upperpkt2 = PKT(ph->GetCounter());
386          upperobt2 = OBT(ph->GetOrbitalTime());          upperobt2 = OBT(ph->GetOrbitalTime());
387          //          //
388          if ( (t_pktlast < upperpkt && t_obtlast > upperobt) || (t_pktlast < upperpkt2 && t_obtlast > upperobt2) ) throw -13;              if ( (t_pktlast < upperpkt && t_obtlast > upperobt) || (t_pktlast < upperpkt2 && t_obtlast > upperobt2) ){
389              if ( IsDebug() ) printf(" .-. upperpkt2 %lld upperobt2 %lld \n",upperpkt2,upperobt2);  
390              if ( IsDebug() ) printf(" .-. upperpkt %lld t_pktlast %lld upperobt %lld t_obtlast %lld \n",upperpkt,t_pktlast,upperobt,t_obtlast);    
391              if ( IsDebug() ) printf(" .-. jump %i zomp %i upperpkt %lld pktlast %u upperobt %lld obtlast %u last entry is %i \n",jump,zomp,upperpkt,pktlast,upperobt,obtlast,i);    
392              throw -13;    
393            };
394          //          //
395          if ( t_pktlast < upperpkt && t_obtlast < upperobt && t_pktlast < upperpkt2 && t_obtlast < upperobt2 ){          if ( t_pktlast < upperpkt && t_obtlast < upperobt && t_pktlast < upperpkt2 && t_obtlast < upperobt2 ){
396            zomp = i + jump + 1;            zomp = i + jump + 1;
397            if ( zomp > nevent-2 ) zomp = nevent - 2;            if ( zomp > nevent-2 ) zomp = nevent - 2;
398            if ( IsDebug() ) printf(" .-. jump %i zomp %i upperpkt %i pktlast %i upperobt %llu obtlast %u last entry is %i \n",jump,zomp,upperpkt,pktlast,upperobt,obtlast,i);            if ( IsDebug() ) printf(" .-. jump %i zomp %i upperpkt %lld pktlast %i upperobt %lld obtlast %u last entry is %i \n",jump,zomp,upperpkt,pktlast,upperobt,obtlast,i);
399            break;            break;
400          };          };
401          //          //
# Line 414  Int_t PamelaDBOperations::SetUpperLimits Line 430  Int_t PamelaDBOperations::SetUpperLimits
430    //    //
431    rhev = rh->GetEntries();    rhev = rh->GetEntries();
432    rtev = rt->GetEntries();    rtev = rt->GetEntries();
433    UInt_t sobtt = 0;    Long64_t sobtt = 0LL;
434    UInt_t sobth = 0;    Long64_t sobth = 0LL;
435    UInt_t spktt = 0;    Long64_t spktt = 0LL;
436    UInt_t spkth = 0;    Long64_t spkth = 0LL;
437    UInt_t pktt = 0;    Long64_t pktt = 0LL;
438    ULong64_t obtt = 0;    Long64_t obtt = 0LL;
439    UInt_t pkth = 0;    Long64_t pkth = 0LL;
440    ULong64_t obth = 0;    Long64_t obth = 0LL;
441    //    //
442    T->GetEntry(upperentry);    T->GetEntry(upperentry);
443    code = eh->GetCounter();    code = eh->GetCounter();
# Line 441  Int_t PamelaDBOperations::SetUpperLimits Line 457  Int_t PamelaDBOperations::SetUpperLimits
457      obth = OBT(phh->GetOrbitalTime());      obth = OBT(phh->GetOrbitalTime());
458    };    };
459    //    //
460    if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);    if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt);
461    if ( pkth > upperpkt && obth > upperobt ){    if ( pkth > upperpkt && obth > upperobt ){
462      if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %i upperp %i oh %llu uppero %llu \n",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);
463      upperpkt = pkth;      upperpkt = pkth;
464      upperobt = obth;      upperobt = obth;
465      rhev = lasthead+1;      rhev = lasthead+1;
466    } else {    } else {
467      rhev = lasthead;      rhev = lasthead;
468    };    };
469    if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);    if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt);
470    //    //
471    if ( IsDebug() ) printf(" rtev beforev %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);    if ( IsDebug() ) printf(" rtev beforev %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt);
472    if ( pktt > upperpkt && obtt > upperobt ){    if ( pktt > upperpkt && obtt > upperobt ){
473      if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %i upperp %i ot %llu uppero %llu \n",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);
474      upperpkt = pktt;      upperpkt = pktt;
475      upperobt = obtt;      upperobt = obtt;
476      rtev = lasttrail+1;      rtev = lasttrail+1;
477    } else {    } else {
478      rtev = lasttrail;      rtev = lasttrail;
479    };    };
480    if ( IsDebug() ) printf(" rtev after %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);    if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt);
481    //  goto kikko;    //  goto kikko;
482    //    //
483    //    //
484    // Check if runtrailer/runheader are within lower limits    // Check if runtrailer/runheader are within lower limits
485    //    //
486    //    //
487    pkth = 0;    pkth = 0LL;
488    obth = 0;    obth = 0LL;
489    spkth = 0;    spkth = 0LL;
490    sobth = 0;    sobth = 0LL;
491    for (Int_t k=0; k<rhev; k++){    for (Int_t k=0; k<rhev; k++){
492      if ( k > 0 ){      if ( k > 0 ){
493        spkth = pkth;        spkth = pkth;
# Line 519  Int_t PamelaDBOperations::SetUpperLimits Line 535  Int_t PamelaDBOperations::SetUpperLimits
535            upperentry = evbefh-1;            upperentry = evbefh-1;
536          };              };    
537        };        };
538        if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);        if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt);
539        goto kikko0;        goto kikko0;
540      };      };
541    };    };
# Line 527  Int_t PamelaDBOperations::SetUpperLimits Line 543  Int_t PamelaDBOperations::SetUpperLimits
543    //    //
544    //    //
545    //    //
546    pktt = 0;    pktt = 0LL;
547    obtt = 0;    obtt = 0LL;
548    spktt = 0;    spktt = 0LL;
549    sobtt = 0;    sobtt = 0LL;
550    for (Int_t k=0; k<rtev; k++){    for (Int_t k=0; k<rtev; k++){
551      if ( k > 0 ){      if ( k > 0 ){
552        spktt = pktt;        spktt = pktt;
# Line 550  Int_t PamelaDBOperations::SetUpperLimits Line 566  Int_t PamelaDBOperations::SetUpperLimits
566        rt->GetEntry(rtev);        rt->GetEntry(rtev);
567        pktt = spktt;        pktt = spktt;
568        obtt = sobtt;        obtt = sobtt;
569        if ( IsDebug() ) printf(" lasttrail %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);        if ( IsDebug() ) printf(" lasttrail %i pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt);
570        //        //
571        UInt_t evbeft = 0;        UInt_t evbeft = 0;
572        code = eht->GetCounter();        code = eht->GetCounter();
# Line 579  Int_t PamelaDBOperations::SetUpperLimits Line 595  Int_t PamelaDBOperations::SetUpperLimits
595            upperentry = evbeft-1;            upperentry = evbeft-1;
596          };          };
597        };        };
598        if ( IsDebug() ) printf(" rtev after %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);        if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt);
599        goto kikko;        goto kikko;
600        //      break;        //      break;
601        //        //
# Line 607  Int_t PamelaDBOperations::SetUpperLimits Line 623  Int_t PamelaDBOperations::SetUpperLimits
623      obth = OBT(phh->GetOrbitalTime());      obth = OBT(phh->GetOrbitalTime());
624    };    };
625    //    //
626    if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);    if ( IsDebug() ) printf(" rhev before %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt);
627    if ( pkth > upperpkt && obth > upperobt ){    if ( pkth > upperpkt && obth > upperobt ){
628      if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %i upperp %i oh %llu uppero %llu \n",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);
629      upperpkt = pkth;      upperpkt = pkth;
630      upperobt = obth;      upperobt = obth;
631      rhev = lasthead+1;      rhev = lasthead+1;
632    } else {    } else {
633      rhev = lasthead;      rhev = lasthead;
634    };    };
635    if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);    if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt);
636    //    //
637    if ( IsDebug() ) printf(" rtev beforev %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);    if ( IsDebug() ) printf(" rtev beforev %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt);
638    if ( pktt > upperpkt && obtt > upperobt ){    if ( pktt > upperpkt && obtt > upperobt ){
639      if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %i upperp %i ot %llu uppero %llu \n",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);
640      upperpkt = pktt;      upperpkt = pktt;
641      upperobt = obtt;      upperobt = obtt;
642      rtev = lasttrail+1;      rtev = lasttrail+1;
643    } else {    } else {
644      rtev = lasttrail;      rtev = lasttrail;
645    };    };
646    if ( IsDebug() ) printf(" rtev after %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);    if ( IsDebug() ) printf(" rtev after %i  pt %lld upperp %lld ot %lld uppero %lld \n",rtev,pktt,upperpkt,obtt,upperobt);
647    //    //
648    if ( IsDebug() ) printf(" Upper limits are: OBT %llu pkt_num %i 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);
649    //    //
650    return(0);    return(0);
651  }  }
# Line 763  void PamelaDBOperations::CheckConnection Line 779  void PamelaDBOperations::CheckConnection
779    if( !conn ) throw -1;    if( !conn ) throw -1;
780    bool connect = conn->IsConnected();    bool connect = conn->IsConnected();
781    if( !connect ) throw -1;    if( !connect ) throw -1;
782      //
783      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());
784      //
785    if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27;    if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27;
786      //
787      // set DB timezone to UTC
788      //
789      stringstream oss;
790      //  
791      oss.str("");
792      oss << "SET time_zone='+0:00';";
793      TSQLResult *result = 0;
794      result = conn->Query(oss.str().c_str());
795      if ( !result ) throw -10;
796      oss.str("");
797      oss << "SET wait_timeout=173000;";
798      conn->Query(oss.str().c_str());
799      //
800  };  };
801    
802  /**  /**
803   * Return the correct packet number if we went back to zero   * Return the correct packet number if we went back to zero
804   */   */
805  UInt_t PamelaDBOperations::PKT(UInt_t pkt_num){    Long64_t PamelaDBOperations::PKT(UInt_t pkt_num){  
806    //    //
807    //  if ( IsDebug() ) printf(" pkt conversion: pkt_num is %u pktfirst is %u (pktfirst - (UInt_t)(16777212/2)) is %u  \n",pkt_num,pktfirst,(pktfirst - (UInt_t)(16777212/2)));    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));
808    //    //
809    if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2)  ) return((pkt_num+16777215));    if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2)  ){
810        if ( IsDebug() ) printf(" rise up pktnum %lld \n",(Long64_t)pkt_num+16777215LL);
811        return((Long64_t)pkt_num+16777215LL);
812      };
813    //    //
814    if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){    if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){
815      if ( (pkt_num-16777215) < 0 ){      if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL);
816        return((16777215-pkt_num));      return((Long64_t)pkt_num-16777215LL);
     } else {  
       return((pkt_num-16777215));  
     };  
817    };    };
818    //    //
819    return(pkt_num);    if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)pkt_num);
820      return((Long64_t)pkt_num);
821    //    //
822  };  };
823    
824  /**  /**
825   * Return the correct On Board Time if we went back to zero   * Return the correct On Board Time if we went back to zero
826   */   */
827  ULong64_t PamelaDBOperations::OBT(UInt_t obt){    Long64_t PamelaDBOperations::OBT(UInt_t obt){  
828    //    //
829    if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((ULong64_t)(obt+numeric_limits<UInt_t>::max()));    if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max()));
830    //    //
831    if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){    if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){
832      if ( (obt-numeric_limits<UInt_t>::max()) < 0  ){      return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max());
       return((ULong64_t)(numeric_limits<UInt_t>::max()-obt));  
     } else {  
       return((ULong64_t)(obt-numeric_limits<UInt_t>::max()));  
     };  
833    };    };
834    //    //
835    return((ULong64_t)obt);    return((Long64_t)obt);
836  };  };
837    
838  /**  /**
# Line 943  Int_t PamelaDBOperations::insertPamelaGL Line 973  Int_t PamelaDBOperations::insertPamelaGL
973    if ( this->GetID_RAW() == 0 )  throw -11;    if ( this->GetID_RAW() == 0 )  throw -11;
974    //    //
975    oss.str("");    oss.str("");
976    oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='"    oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='"
977        << this->GetRawFile().Data() << "';";        << this->GetRawFile().Data() << "';";
978    if ( IsDebug() ) printf(" %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
979    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
# Line 952  Int_t PamelaDBOperations::insertPamelaGL Line 982  Int_t PamelaDBOperations::insertPamelaGL
982    //    //
983    if ( !row ){    if ( !row ){
984      oss.str("");      oss.str("");
985      oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "      oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "
986          << dworbit << " order by FROM_ORBIT desc limit 1;";          << dworbit << " order by FROM_ORBIT desc limit 1;";
987      if ( IsDebug() ) printf(" %s \n",oss.str().c_str());      if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
988      result = conn->Query(oss.str().c_str());      result = conn->Query(oss.str().c_str());
# Line 961  Int_t PamelaDBOperations::insertPamelaGL Line 991  Int_t PamelaDBOperations::insertPamelaGL
991      if ( !row ) throw -10;      if ( !row ) throw -10;
992    };    };
993    //    //
994    t0 = (UInt_t)TDatime(row->GetField(0)).Convert();    TTimeStamp tu = TTimeStamp((UInt_t)atoi(row->GetField(0)),(UInt_t)atoi(row->GetField(1)),(UInt_t)atoi(row->GetField(2)),(UInt_t)atoi(row->GetField(3)),(UInt_t)atoi(row->GetField(4)),(UInt_t)atoi(row->GetField(5)),0,true,0);
995      t0 = (UInt_t)tu.GetSec();
996      if ( IsDebug() ) printf(" t0 is %u ti is %s %s %s %s %s %s\n",t0,row->GetField(0),row->GetField(1),row->GetField(2),row->GetField(3),row->GetField(4),row->GetField(5));
997      //
998    /*    /*
999     * Verify that the TIMESYNC have been not already processed     * Verify that the TIMESYNC have been not already processed
1000     */     */
# Line 976  Int_t PamelaDBOperations::insertPamelaGL Line 1009  Int_t PamelaDBOperations::insertPamelaGL
1009    if (result == NULL) throw -10;    if (result == NULL) throw -10;
1010    row = result->Next();    row = result->Next();
1011    if ((row != NULL) && ((UInt_t)atoll(row->GetField(0)) > 0)){    if ((row != NULL) && ((UInt_t)atoll(row->GetField(0)) > 0)){
1012        if ( IsDebug() ) printf(" found a timesync t0 is %u \n",t0);
1013      toffset = (UInt_t)atoll(row->GetField(2)) - (UInt_t)(this->OBT((UInt_t)atoll(row->GetField(1)))/1000) + t0;      toffset = (UInt_t)atoll(row->GetField(2)) - (UInt_t)(this->OBT((UInt_t)atoll(row->GetField(1)))/1000) + t0;
1014        //
1015        tsync = (UInt_t)atoll(row->GetField(2));
1016        obt0 = (UInt_t)atoll(row->GetField(1));
1017        //
1018      return(1);      return(1);
1019    };    };
1020    //    //
# Line 1170  Int_t PamelaDBOperations::insertPamelaGL Line 1208  Int_t PamelaDBOperations::insertPamelaGL
1208    conn->Query(oss.str().c_str());    conn->Query(oss.str().c_str());
1209    if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to fill it:\n %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to fill it:\n %s \n",oss.str().c_str());
1210    //    //
1211      if ( IsDebug() ) printf(" found a timesync t0 is %u \n",t0);
1212    toffset = (UInt_t)TSYNC - (UInt_t)(this->OBT(OBT)/1000) + t0;    toffset = (UInt_t)TSYNC - (UInt_t)(this->OBT(OBT)/1000) + t0;
1213    //    //
1214      tsync = TSYNC;
1215      obt0 = OBT;
1216      //
1217    delete result;    delete result;
1218    return(signal);    return(signal);
1219  }  }
# Line 1271  Int_t PamelaDBOperations::assignBOOT_NUM Line 1313  Int_t PamelaDBOperations::assignBOOT_NUM
1313    VarDumpEvent  *vde = 0;    VarDumpEvent  *vde = 0;
1314    VarDumpRecord *vdr = 0;    VarDumpRecord *vdr = 0;
1315    //    //
1316      Bool_t found = false;
1317    trDumpEv->SetBranchAddress("VarDump", &vde);    trDumpEv->SetBranchAddress("VarDump", &vde);
1318    if ( trDumpEv->GetEntries() > 0 ){    if ( trDumpEv->GetEntries() > 0 ){
1319      Bool_t found = false;      found = false;
1320      for ( Int_t i = 0; i < trDumpEv->GetEntries(); i++){      for ( Int_t i = 0; i < trDumpEv->GetEntries(); i++){
1321        trDumpEv->GetEntry(i);        trDumpEv->GetEntry(i);
1322        vde->Records->GetEntries();        //      vde->Records->GetEntries();
1323        if ( vde->Records->GetEntries()>0 ){        if ( vde->Records->GetEntries()>5 ){
1324          found = true;          found = true;
1325          goto fill;          goto fill;
1326        };        };
# Line 1290  Int_t PamelaDBOperations::assignBOOT_NUM Line 1333  Int_t PamelaDBOperations::assignBOOT_NUM
1333        this->SetBOOTnumber((Int_t)vdr->VAR_VALUE);        this->SetBOOTnumber((Int_t)vdr->VAR_VALUE);
1334        //        //
1335      } else {      } else {
1336        if ( !this->GetBOOTnumber() ) return(4);        if ( !this->GetBOOTnumber() && !this->AutoBoot()) return(4);
1337        };
1338      } else {
1339        if ( !this->GetBOOTnumber() && !this->AutoBoot()) return(2);
1340      };
1341      //
1342      UInt_t bn = 0;
1343      Bool_t afound = false;
1344      if ( !found && this->AutoBoot()){
1345        afound = true;
1346        //
1347        // Search for other files with similar timesync
1348        //
1349        if ( IsDebug() ) printf(" tsync %u obt0 %u \n",tsync,obt0);
1350        UInt_t upperts = tsync-(obt0/1000)+5;
1351        UInt_t lowerts = tsync-(obt0/1000)-5;
1352        oss.str("");
1353        oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where TIMESYNC-(OBT0/1000)<"
1354            << upperts
1355            << " AND TIMESYNC-(OBT0/1000)>"
1356            << lowerts
1357            << " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;";
1358        result = conn->Query(oss.str().c_str());
1359        if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to find boot number:\n %s \n",oss.str().c_str());
1360        //
1361        if ( !result ) throw -4;;
1362        found = true;
1363        if ( result->GetRowCount()<3 ){
1364          if ( IsDebug() ) printf(" AGH! no results!\n");
1365          found = false;
1366        } else {
1367          row = result->Next();      
1368          bn = (UInt_t)atoll(row->GetField(0));
1369          for ( Int_t r=1; r<result->GetRowCount() ;r++){
1370            if ( !row ) throw -4;
1371            if ( IsDebug() ) printf(" BOOT number is %s \n",row->GetField(0));
1372            if ( bn != (UInt_t)atoll(row->GetField(0)) ){
1373              if ( IsDebug() ) printf(" AGH! bn = %u here instead %u \n",bn,(UInt_t)atoll(row->GetField(0)));
1374              found = false;
1375            };
1376            row = result->Next();
1377          };
1378      };      };
1379      };
1380      //
1381      Int_t sgn = 0;
1382      //
1383      if ( !found ){
1384        throw -29;
1385    } else {    } else {
1386      if ( !this->GetBOOTnumber() ) return(2);      if ( afound ){
1387          this->SetBOOTnumber(bn);
1388          sgn = 8;
1389        };
1390    };    };
1391    //    //
1392    oss.str("");    oss.str("");
# Line 1303  Int_t PamelaDBOperations::assignBOOT_NUM Line 1396  Int_t PamelaDBOperations::assignBOOT_NUM
1396    conn->Query(oss.str().c_str());          conn->Query(oss.str().c_str());      
1397    //    //
1398    delete result;    delete result;
1399    return(0);    return(sgn);
1400  };  };
1401    
1402  /**  /**
# Line 1621  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1714  Bool_t PamelaDBOperations::IsRunAlreadyI
1714    delete result;    delete result;
1715    //    //
1716    if ( signal && IsDebug() ) printf(" The run has already been inserted \n");        if ( signal && IsDebug() ) printf(" The run has already been inserted \n");    
1717      if ( !signal && IsDebug() ) printf(" The run existed and was deleted, fill the DB \n");
1718    return(signal);    return(signal);
1719  };  };
1720    
# Line 1734  void PamelaDBOperations::HandleRunFragme Line 1828  void PamelaDBOperations::HandleRunFragme
1828      //      //
1829    } else {    } else {
1830      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");
1831        return;
1832    };    };
1833    //    //
1834    //    //
# Line 2732  Int_t PamelaDBOperations::insertCALO_CAL Line 2827  Int_t PamelaDBOperations::insertCALO_CAL
2827                // no calibrations in the db contain our calibration                // no calibrations in the db contain our calibration
2828                //                //
2829                if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section);                if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section);
2830                if ( fromtime < 1150863400 ){                if ( fromtime < 1150871000 ){ //1150866904
2831                  if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);                  if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);
2832                  fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode                  fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode
2833                };                };
# Line 2877  void PamelaDBOperations::HandleTRK_CALIB Line 2972  void PamelaDBOperations::HandleTRK_CALIB
2972        // no calibrations in the db contain our calibration        // no calibrations in the db contain our calibration
2973        //        //
2974        if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n");        if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n");
2975        if ( fromtime < 1150863400 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode        if ( fromtime < 1150871000 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode
2976        //        //
2977        oss.str("");        oss.str("");
2978        oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE "        oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE "
# Line 3006  Int_t PamelaDBOperations::insertTRK_CALI Line 3101  Int_t PamelaDBOperations::insertTRK_CALI
3101      pkt1 = ph1->GetCounter();        pkt1 = ph1->GetCounter();  
3102      fromtime = this->GetAbsTime(ph1->GetOrbitalTime());        fromtime = this->GetAbsTime(ph1->GetOrbitalTime());  
3103      //      //
3104      valid = 1;  //     valid = 1;
3105      //  //     //
3106      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
3107      //      //
3108      //      //
3109      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) ){
3110        //        //
3111        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);
3112          //      
3113          valid = ValidateTrkCalib( caltrk1, eh1 );
3114          if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl;
3115        //        //
3116        // Do we have the second calibration packet?        // Do we have the second calibration packet?
3117        //        //
# Line 3030  Int_t PamelaDBOperations::insertTRK_CALI Line 3128  Int_t PamelaDBOperations::insertTRK_CALI
3128            obt2 = ph2->GetOrbitalTime();              obt2 = ph2->GetOrbitalTime();  
3129            pkt2 = ph2->GetCounter();              pkt2 = ph2->GetCounter();  
3130            //            //
3131            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
3132            //                  //      
3133          } else {          } else {
3134            //            //
# Line 3061  Int_t PamelaDBOperations::insertTRK_CALI Line 3159  Int_t PamelaDBOperations::insertTRK_CALI
3159          //          //
3160          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);
3161          //          //
3162            UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 );
3163            if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl;
3164            valid = valid & valid2;
3165            //
3166          // Handle good calib          // Handle good calib
3167          //          //
3168          this->HandleTRK_CALIB(true,true);          this->HandleTRK_CALIB(true,true);
# Line 3233  Int_t PamelaDBOperations::insertS4_CALIB Line 3335  Int_t PamelaDBOperations::insertS4_CALIB
3335            // no calibrations in the db contain our calibration            // no calibrations in the db contain our calibration
3336            //            //
3337            if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n");            if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n");
3338            if ( fromtime < 1150863400 ){            if ( fromtime < 1150871000 ){  
3339              if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);              if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);
3340              fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode              fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode
3341            };            };
# Line 4329  void PamelaDBOperations::RemoveCALIBS(){ Line 4431  void PamelaDBOperations::RemoveCALIBS(){
4431      //      //
4432    };    };
4433  };  };
4434    
4435    /**
4436     *
4437     * Rearrange calibration tables
4438     *
4439     **/
4440    UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){
4441    
4442        Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0};
4443        UInt_t timeaftercalib=120000; //2000;
4444    //  ----------
4445    //  Check CRCs
4446    //  ----------
4447        for(Int_t ipkt=0; ipkt<6; ipkt++){
4448            if( caltrk->crc_hcal[ipkt] )return 0; // :-(
4449            for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-(
4450        }
4451    //  -----------------------
4452    //  Check missing packets:
4453    //  -----------------------
4454    //    Readout order:
4455    //    ------------------
4456    //    DSP   packet board
4457    //    ------------------
4458    //    12    0      1
4459    //    10    1      1
4460    //     8    2      1
4461    //     4    3      1
4462    //     6    4      1
4463    //     2    5      1
4464    //    ------------------
4465    //    11    0      2
4466    //     9    1      2
4467    //     7    2      2
4468    //     3    3      2
4469    //     5    4      2
4470    //     1    5      2
4471    //    ------------------
4472    //  -------------------------------------------------
4473    //  Check if it is first or second calibration packet
4474    //  -------------------------------------------------
4475        UInt_t build=0;
4476        TString classname = caltrk->GetName();
4477        UInt_t base=0;
4478        UInt_t mask=0;
4479        if(classname.Contains("CalibTrk1Event")){
4480            base=12;
4481            mask=0x03F000;
4482        }
4483        if(classname.Contains("CalibTrk2Event")){
4484            base=18;
4485            mask=0xFC0000;
4486        }
4487    //  -------------------------------------------------
4488    //  Count number of packets and set build variable
4489    //  -------------------------------------------------
4490        Int_t  npkts=0;
4491        for(Int_t ipkt=0; ipkt<6; ipkt++){
4492            if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){
4493                npkts++;
4494                build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) );
4495            }
4496        }
4497    //    if( npkts==6 )return 1; // :-)
4498    
4499    //    cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl;
4500    
4501    //  -----------------------------------------------
4502    //  If missing packets: check the acq configuration
4503    //  (some DSPs might be excluded from acquisition)
4504    //  -----------------------------------------------
4505    
4506    //  -----------------------------------------------
4507    //  retrieve the first run header after calib
4508    //  -----------------------------------------------
4509         PacketType *pctp;
4510         EventCounter *cod;
4511         cod = eh->GetCounter();
4512         Int_t irun = cod->Get(pctp->RunHeader);
4513         TTree *rh=(TTree*)file->Get("RunHeader");
4514         if ( !rh || rh->IsZombie() ) throw -17;
4515         if( rh->GetEntries() == irun ){
4516              if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1)  -- cannot validate :-( "<<endl;
4517             return 0; // :-(
4518         }
4519    
4520         RunHeaderEvent *run  = 0;
4521         EventHeader    *hrun = 0;
4522         rh->SetBranchAddress("RunHeader", &run);
4523         rh->SetBranchAddress("Header", &hrun);
4524         rh->GetEntry(irun);
4525    //     cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl;
4526    
4527         if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){
4528              if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl;
4529             return 0; // :-(
4530         }
4531        
4532         if( !run->RM_ACQ_AFTER_CALIB ){
4533              if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0    -- cannot validate :-( "<<endl;
4534             return 0; // :-(
4535         }
4536    
4537         UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime());
4538         if( dtime > timeaftercalib ){
4539             if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl;
4540             return 0; // :-(
4541         }
4542        
4543    
4544    
4545         if( (run->ACQ_BUILD_INFO & mask) != build ){
4546             if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl;
4547             return 0; // :-(
4548         }
4549         return 1; // :-)
4550    
4551    }
4552    
4553    /**
4554     *
4555     * Check the DB (only for overlapping runs at the moment)
4556     *
4557     **/
4558    UInt_t PamelaDBOperations::Check(){
4559      //
4560      UInt_t test = 0;
4561      //
4562      UInt_t thisrht = 0;
4563      UInt_t thisrtt = 0;
4564      UInt_t thisid = 0;
4565      UInt_t prevrht = 0;
4566      UInt_t prevrtt = 0;
4567      UInt_t previd = 0;
4568      //
4569      UInt_t prevl0id = 0;
4570      UInt_t thisl0id = 0;
4571      //
4572      stringstream oss;
4573      TSQLResult *result = 0;
4574      TSQLRow    *row    = 0;
4575      TSQLResult *result2 = 0;
4576      TSQLRow    *row2    = 0;
4577      oss.str("");
4578      oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN order by RUNHEADER_TIME asc;";
4579      //  oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;";
4580      result = conn->Query(oss.str().c_str());
4581      //
4582      if ( !result ) throw -4;;
4583      //
4584      row = result->Next();
4585      //
4586      while ( row ){
4587        thisid = (UInt_t)atoll(row->GetField(0));
4588        thisl0id = (UInt_t)atoll(row->GetField(1));
4589        thisrht = (UInt_t)atoll(row->GetField(2));
4590        thisrtt = (UInt_t)atoll(row->GetField(3));
4591        //
4592        //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){
4593        //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){
4594        if ( (thisrht < prevrtt) && (thisrht != prevrht) ){
4595          if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);
4596          printf(" CHECK n.1 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid);
4597          TString prevf = "";
4598          TString thisf = "";
4599          oss.str("");
4600          oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";
4601          result2 = conn->Query(oss.str().c_str());
4602          if ( !result2 ) throw -4;;
4603          row2 = result2->Next();
4604          prevf = (TString)row2->GetField(0);
4605          oss.str("");
4606          oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";";
4607          result2 = conn->Query(oss.str().c_str());
4608          if ( !result2 ) throw -4;;
4609          row2 = result2->Next();
4610          thisf = (TString)row2->GetField(0);
4611          if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data());
4612          test = 1;
4613        };
4614        //
4615        if ( (thisrtt < prevrht) && (thisrht != prevrht) ){
4616          if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);
4617          printf(" CHECK n.2 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid);
4618          TString prevf = "";
4619          TString thisf = "";
4620          oss.str("");
4621          oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";
4622          result2 = conn->Query(oss.str().c_str());
4623          if ( !result2 ) throw -4;;
4624          row2 = result2->Next();
4625          prevf = (TString)row2->GetField(0);
4626          oss.str("");
4627          oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";";
4628          result2 = conn->Query(oss.str().c_str());
4629          if ( !result2 ) throw -4;;
4630          row2 = result2->Next();
4631          thisf = (TString)row2->GetField(0);
4632          if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data());
4633          test = 1;
4634        };
4635        //
4636        if ( (thisrht > thisrtt) && (thisrht != prevrht) ){
4637          if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);
4638          printf(" CHECK n.3 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid);
4639          TString prevf = "";
4640          TString thisf = "";
4641          oss.str("");
4642          oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";
4643          result2 = conn->Query(oss.str().c_str());
4644          if ( !result2 ) throw -4;;
4645          row2 = result2->Next();
4646          prevf = (TString)row2->GetField(0);
4647          oss.str("");
4648          oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)thisl0id <<";";
4649          result2 = conn->Query(oss.str().c_str());
4650          if ( !result2 ) throw -4;;
4651          row2 = result2->Next();
4652          thisf = (TString)row2->GetField(0);
4653          if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data());
4654          test = 1;
4655        };
4656    
4657        //
4658        prevrht = thisrht;
4659        prevrtt = thisrtt;
4660        previd = thisid;
4661        prevl0id = thisl0id;
4662        row = result->Next();
4663      };
4664      //
4665      return(test);
4666      //
4667    };

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.23