/[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.5 by pam-fi, Fri Sep 8 14:42:48 2006 UTC revision 1.8 by pam-fi, Mon Sep 11 16:38:18 2006 UTC
# Line 48  using namespace pamela; Line 48  using namespace pamela;
48   * @param tsync        file timesync.   * @param tsync        file timesync.
49   * @param debug        debug flag.   * @param debug        debug flag.
50   */   */
51  PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug){  PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, Long64_t olderthan){
52    //    //
53    //    //
54    SetConnection(host,user,password);    SetConnection(host,user,password);
# Line 63  PamelaDBOperations::PamelaDBOperations(T Line 63  PamelaDBOperations::PamelaDBOperations(T
63    SetObt0(obt0);    SetObt0(obt0);
64    //    //
65    //    //
66    SetRootName(filerootname);    INSERT_RAW =!filerawname.IsNull();
67    SetRawName(filerawname);    if(INSERT_RAW)SetRawName(filerawname);
68    //    //
69    this->OpenFile();    INSERT_ROOT = !filerootname.IsNull();
70      if(INSERT_ROOT){
71              file = TFile::Open(this->GetRootName().Data());
72              if ( !file ) INSERT_ROOT = false;
73      };
74    //  this->OpenFile();
75    //    //
76    this->SetID_RAW(0);    this->SetID_RAW(0);
77    this->SetID_ROOT(0);    this->SetID_ROOT(0);
78    //  
79      VALIDATE = false;
80      clean_time = new TDatime();
81      if(olderthan >= 0){
82            VALIDATE = true;
83            UInt_t timelim = 0;
84            // timelim = now - olderthan
85            timelim =  (UInt_t)clean_time->Convert() - olderthan;
86            clean_time->Set(timelim,false);
87      };
88      
89        //
90  };  };
91    
92  /**  /**
# Line 78  PamelaDBOperations::PamelaDBOperations(T Line 94  PamelaDBOperations::PamelaDBOperations(T
94   */   */
95  void PamelaDBOperations::Close(){  void PamelaDBOperations::Close(){
96    if( conn && conn->IsConnected() ) conn->Close();    if( conn && conn->IsConnected() ) conn->Close();
97      delete clean_time;
98    delete glrun;    delete glrun;
99    delete this;    delete this;
100  };  };
# Line 172  void PamelaDBOperations::SetNOBOOT(Bool_ Line 189  void PamelaDBOperations::SetNOBOOT(Bool_
189   * Store the olderthan variable   * Store the olderthan variable
190   * @param olderthan   * @param olderthan
191   */   */
192  void PamelaDBOperations::SetOlderThan(Long64_t oldthan){  // void PamelaDBOperations::SetOlderThan(Long64_t oldthan){
193    olderthan = oldthan;  //   olderthan = oldthan;
194  };  // };
195    
196  /**  /**
197   * Retrieve the ID_RAW, if exists, returns NULL if does not exist.   * Retrieve the ID_RAW, if exists, returns NULL if does not exist.
# Line 320  Int_t PamelaDBOperations::SetUpperLimits Line 337  Int_t PamelaDBOperations::SetUpperLimits
337    // check if last runtrailer is within limits, if not extend limits (one should check for all packets but we need only runtrailer)    // check if last runtrailer is within limits, if not extend limits (one should check for all packets but we need only runtrailer)
338    //    //
339    PacketType *pctp=0;    PacketType *pctp=0;
   T->GetEntry(upperentry);  
   code = eh->GetCounter();  
   Int_t lasttrail = code->Get(pctp->RunTrailer);  
   Int_t lasthead = code->Get(pctp->RunHeader);  
340    TTree *rh=(TTree*)file->Get("RunHeader");    TTree *rh=(TTree*)file->Get("RunHeader");
341    if ( !rh || rh->IsZombie() ) throw -17;    if ( !rh || rh->IsZombie() ) throw -17;
342    TTree *rt=(TTree*)file->Get("RunTrailer");    TTree *rt=(TTree*)file->Get("RunTrailer");
# Line 346  Int_t PamelaDBOperations::SetUpperLimits Line 359  Int_t PamelaDBOperations::SetUpperLimits
359    UInt_t pkth = 0;    UInt_t pkth = 0;
360    ULong64_t obth = 0;    ULong64_t obth = 0;
361    //    //
362      T->GetEntry(upperentry);
363      code = eh->GetCounter();
364      Int_t lasttrail = code->Get(pctp->RunTrailer);
365      Int_t lasthead = code->Get(pctp->RunHeader);
366    if ( lasttrail < rtev ){    if ( lasttrail < rtev ){
367      rt->GetEntry(lasttrail);      rt->GetEntry(lasttrail);
368      pht = eht->GetPscuHeader();      pht = eht->GetPscuHeader();
# Line 356  Int_t PamelaDBOperations::SetUpperLimits Line 373  Int_t PamelaDBOperations::SetUpperLimits
373    if ( lasthead < rhev ){    if ( lasthead < rhev ){
374      rh->GetEntry(lasthead);      rh->GetEntry(lasthead);
375      phh = ehh->GetPscuHeader();      phh = ehh->GetPscuHeader();
376      pkth = PKT(pht->GetCounter());      pkth = PKT(phh->GetCounter());
377      obth = OBT(pht->GetOrbitalTime());      obth = OBT(phh->GetOrbitalTime());
378    };    };
379    //    //
380    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 %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);
# Line 401  Int_t PamelaDBOperations::SetUpperLimits Line 418  Int_t PamelaDBOperations::SetUpperLimits
418      pkth = PKT(phh->GetCounter());      pkth = PKT(phh->GetCounter());
419      obth = OBT(phh->GetOrbitalTime());      obth = OBT(phh->GetOrbitalTime());
420      //      //
421    //    if ( IsDebug() ) printf(" k %i rhev before %i ph %u upperp %u oh %u uppero %u \n",k,rhev,pkth,spkth,obth,sobth);
422        //
423      if ( pkth < spkth && obth < sobth ){      if ( pkth < spkth && obth < sobth ){
       if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);  
424        if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i  \n",rhev);        if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i  \n",rhev);
425        //        //
426        rhev--;        rhev = k-1;
427        rh->GetEntry(rhev);        rh->GetEntry(rhev);
428        pkth = spkth;        pkth = spkth;
429        obth = sobth;        obth = sobth;
       if ( IsDebug() ) printf(" lasthead %i pt %i p1 %i ot %u o1 %u \n",rhev,pkth,spkth,obth,sobth);  
430        //        //
431        UInt_t evbefh = 0;        UInt_t evbefh = 0;
432        code = ehh->GetCounter();        code = ehh->GetCounter();
# Line 419  Int_t PamelaDBOperations::SetUpperLimits Line 436  Int_t PamelaDBOperations::SetUpperLimits
436          ph = eh->GetPscuHeader();          ph = eh->GetPscuHeader();
437          t_pktlast = PKT(ph->GetCounter());          t_pktlast = PKT(ph->GetCounter());
438          t_obtlast = OBT(ph->GetOrbitalTime());          t_obtlast = OBT(ph->GetOrbitalTime());
439          if ( t_pktlast < spkth && t_obtlast < sobth ){ // jump          if ( t_pktlast <= spkth && t_obtlast <= sobth ){ // jump
440            upperpkt = pkth;            upperpkt = pkth;
441            upperobt = obth;            upperobt = obth;
442            upperentry = evbefh-1;            upperentry = evbefh-1;
# Line 439  Int_t PamelaDBOperations::SetUpperLimits Line 456  Int_t PamelaDBOperations::SetUpperLimits
456          };              };    
457        };        };
458        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 %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);
459          goto kikko0;
460      };      };
461    };    };
462     kikko0:
463    //    //
464    //    //
465    //    //
# Line 458  Int_t PamelaDBOperations::SetUpperLimits Line 477  Int_t PamelaDBOperations::SetUpperLimits
477      pktt = PKT(pht->GetCounter());      pktt = PKT(pht->GetCounter());
478      obtt = OBT(pht->GetOrbitalTime());      obtt = OBT(pht->GetOrbitalTime());
479      //      //
480    //    if ( IsDebug() ) printf(" k %i rtev beforev %i  pt %i upperp %i ot %llu uppero %llu \n",k,rtev,pktt,spktt,obtt,sobtt);
481        //
482      if ( pktt < spktt && obtt < sobtt ){      if ( pktt < spktt && obtt < sobtt ){
       if ( IsDebug() ) printf(" rtev beforev %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);  
483        if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev);        if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev);
484        //        //
485        rtev--;        rtev = k-1;
486        rt->GetEntry(rtev);        rt->GetEntry(rtev);
487        pktt = spktt;        pktt = spktt;
488        obtt = sobtt;        obtt = sobtt;
# Line 476  Int_t PamelaDBOperations::SetUpperLimits Line 496  Int_t PamelaDBOperations::SetUpperLimits
496          ph = eh->GetPscuHeader();          ph = eh->GetPscuHeader();
497          t_pktlast = PKT(ph->GetCounter());          t_pktlast = PKT(ph->GetCounter());
498          t_obtlast = OBT(ph->GetOrbitalTime());          t_obtlast = OBT(ph->GetOrbitalTime());
499          if ( t_pktlast < spktt && t_obtlast < sobtt ){ // jump          if ( t_pktlast <= spktt && t_obtlast <= sobtt ){ // jump
500            upperpkt = pktt;            upperpkt = pktt;
501            upperobt = obtt;            upperobt = obtt;
502            upperentry = evbeft-1;            upperentry = evbeft-1;
# Line 496  Int_t PamelaDBOperations::SetUpperLimits Line 516  Int_t PamelaDBOperations::SetUpperLimits
516          };          };
517        };        };
518        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 %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);
519        break;        goto kikko;
520          //      break;
521        //        //
522      };      };
523      //        //  
524    };    };
525    //    //
526    // kikko:   kikko:
527      //
528      T->GetEntry(upperentry);
529      code = eh->GetCounter();
530      lasttrail = code->Get(pctp->RunTrailer);
531      lasthead = code->Get(pctp->RunHeader);
532      if ( lasttrail < rtev ){
533        rt->GetEntry(lasttrail);
534        pht = eht->GetPscuHeader();
535        pktt = PKT(pht->GetCounter());
536        obtt = OBT(pht->GetOrbitalTime());
537      };
538      //
539      if ( lasthead < rhev ){
540        rh->GetEntry(lasthead);
541        phh = ehh->GetPscuHeader();
542        pkth = PKT(phh->GetCounter());
543        obth = OBT(phh->GetOrbitalTime());
544      };
545      //
546      if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);
547      if ( pkth > upperpkt && obth > upperobt ){
548        if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %i upperp %i oh %llu uppero %llu \n",pkth,upperpkt,obth,upperobt);
549        upperpkt = pkth;
550        upperobt = obth;
551        rhev = lasthead+1;
552      } else {
553        rhev = lasthead;
554      };
555      if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt);
556      //
557      if ( IsDebug() ) printf(" rtev beforev %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);
558      if ( pktt > upperpkt && obtt > upperobt ){
559        if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %i upperp %i ot %llu uppero %llu \n",pktt,upperpkt,obtt,upperobt);
560        upperpkt = pktt;
561        upperobt = obtt;
562        rtev = lasttrail+1;
563      } else {
564        rtev = lasttrail;
565      };
566      if ( IsDebug() ) printf(" rtev after %i  pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt);
567    //    //
568    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 %llu pkt_num %i upper entry %i \n",upperobt,upperpkt,upperentry);
569    //    //
# Line 584  const PacketType* PamelaDBOperations::Ge Line 645  const PacketType* PamelaDBOperations::Ge
645  // PRIVATE FUNCTIONS  // PRIVATE FUNCTIONS
646  //  //
647    
648  /**  // /**
649   * Open the ROOT filename for reading  // * Open the ROOT filename for reading
650   */  // */
651  void PamelaDBOperations::OpenFile(){  // void PamelaDBOperations::OpenFile(){
652    file = TFile::Open(this->GetRootName().Data());  //   file = TFile::Open(this->GetRootName().Data());
653  };  //   //
654    //   if ( !file ) throw -12;
655    // };
656    
657    
658  /**  /**
659   * Check if LEVEL0 file and DB connection have really be opened   * Check if LEVEL0 file and DB connection have really be opened
660   */   */
661  void PamelaDBOperations::CheckFile(){    void PamelaDBOperations::CheckConnection(){  
   //  
   if ( !file ) throw -12;  
662    //    //
663    // check connection    // check connection
664    //    //
665    if( !conn ) throw -1;        if( !conn ) throw -1;
666    bool connect = conn->IsConnected();    bool connect = conn->IsConnected();
667    if( !connect ) throw -1;        if( !connect ) throw -1;
668  };  };
669    
670  /**  /**
# Line 3124  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 3185  Int_t PamelaDBOperations::CleanGL_RUN_FR
3185    TSQLRow    *row2   = 0;    TSQLRow    *row2   = 0;
3186    //    //
3187    UInt_t moved = 0;    UInt_t moved = 0;
3188    UInt_t timelim = 0;  //  UInt_t timelim = 0;
3189    TDatime *time = new TDatime();  //  TDatime *time = new TDatime();
3190    //    //
3191    stringstream oss;    stringstream oss;
3192    oss.str("");    oss.str("");
3193    //    //
3194    //    //
   //  
   if ( olderthan < 0 ){  
     if ( IsDebug() ) printf(" Do not clean GL_RUN_FRAGMENTS table \n");  
     return(1);  
   };  
   //  
   // timelim = now - olderthan  
   //  
   time->Set();  
   timelim =  (UInt_t)time->Convert() - olderthan;  
   time->Set(timelim,false);  
   //  
3195    // check if there are entries older than "olderthan" seconds from now    // check if there are entries older than "olderthan" seconds from now
3196    //    //
3197    oss.str("");    oss.str("");
3198    oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE"    oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE"
3199        << " INSERT_TIME <= '" << time->AsSQLString() << "';";        << " INSERT_TIME <= '" << clean_time->AsSQLString() << "';";
3200    //    //
3201    if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",time->AsSQLString(),oss.str().c_str());    if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str());
3202    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
3203    //    //
3204    if ( result ){    if ( result ){
# Line 3247  Int_t PamelaDBOperations::ValidateRuns() Line 3296  Int_t PamelaDBOperations::ValidateRuns()
3296    TSQLResult *result = 0;    TSQLResult *result = 0;
3297    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
3298    //    //
   UInt_t timelim = 0;  
   TDatime *time = new TDatime();  
   //  
3299    stringstream oss;    stringstream oss;
3300    oss.str("");    oss.str("");
3301    //    //
   //  
   //  
   if ( olderthan < 0 ){  
     if ( IsDebug() ) printf(" Do not validate runs \n");  
     return(1);  
   };  
   //  
   // timelim = now - olderthan  
   //  
   time->Set();  
   timelim =  (UInt_t)time->Convert() - olderthan;  
   time->Set(timelim,false);  
   
   printf("Validate runs older than %s \n",time->AsSQLString());  
   
3302    // =======================================================    // =======================================================
3303    // validate runs by checking missing calibrations    // validate runs by checking missing calibrations
3304    // =======================================================    // =======================================================
# Line 3277  Int_t PamelaDBOperations::ValidateRuns() Line 3308  Int_t PamelaDBOperations::ValidateRuns()
3308    // 1) get the OBT of the last run inserted after clean-time limit    // 1) get the OBT of the last run inserted after clean-time limit
3309    // --------------------------------------------------------------    // --------------------------------------------------------------
3310    oss.str("");    oss.str("");
3311    oss << " SELECT * FROM GL_RUN  WHERE INSERT_TIME <= '" << time->AsSQLString()    oss << " SELECT * FROM GL_RUN  WHERE INSERT_TIME <= '" << clean_time->AsSQLString()
3312        << "' ORDER BY INSERT_TIME DESC LIMIT 1;";            << "' ORDER BY RUNHEADER_TIME DESC LIMIT 1;";
3313    printf(" Get start validation-time: query is \n %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" Get start validation-time: query is \n %s \n",oss.str().c_str());
3314    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
3315    if ( !result ) throw -4;    if ( !result ) throw -4;
3316    if ( !result->GetRowCount() ) {    if ( !result->GetRowCount() ) {
# Line 3288  Int_t PamelaDBOperations::ValidateRuns() Line 3319  Int_t PamelaDBOperations::ValidateRuns()
3319    }else{    }else{
3320          row = result->Next();          row = result->Next();
3321          t_start = (UInt_t)atoll(row->GetField(4));          t_start = (UInt_t)atoll(row->GetField(4));
         printf("t_start %i\n",t_start);  
3322    };      };  
3323    // --------------------------------------------------------------    // --------------------------------------------------------------
3324    // 2) get the OBT of the last validated run    // 2) get the OBT of the last validated run
# Line 3296  Int_t PamelaDBOperations::ValidateRuns() Line 3326  Int_t PamelaDBOperations::ValidateRuns()
3326    oss.str("");    oss.str("");
3327    oss << " SELECT * FROM GL_RUN  WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start    oss << " SELECT * FROM GL_RUN  WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start
3328        <<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;";        <<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;";
3329    printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str());
3330    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
3331    if ( !result ) throw -4;    if ( !result ) throw -4;
3332    if ( result->GetRowCount() ){    if ( result->GetRowCount() ){
3333            row = result->Next();            row = result->Next();
3334            t_stop = (UInt_t)atoll(row->GetField(4));            t_stop = (UInt_t)atoll(row->GetField(4));
3335    };    };
3336    printf("t_stop %i\n",t_stop);    if ( IsDebug() ) printf("Validation interval: from time %i - to time %i \n\n",t_stop,t_start);
3337    // --------------------------------------------------------------    // --------------------------------------------------------------
3338    // now retrieves runs to be validated    // now retrieves runs to be validated
3339    // --------------------------------------------------------------    // --------------------------------------------------------------
# Line 3312  Int_t PamelaDBOperations::ValidateRuns() Line 3342  Int_t PamelaDBOperations::ValidateRuns()
3342    oss << " AND RUNHEADER_TIME >="<< t_stop;    oss << " AND RUNHEADER_TIME >="<< t_stop;
3343    oss << " ORDER BY RUNHEADER_TIME DESC;";    oss << " ORDER BY RUNHEADER_TIME DESC;";
3344  //  if ( IsDebug() )  //  if ( IsDebug() )
3345    printf(" Check runs for validation: query is \n %s \n",oss.str().c_str());    if ( IsDebug() )printf(" Check runs for validation: query is \n %s \n",oss.str().c_str());
3346    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
3347    if ( !result ) throw -4;    if ( !result ) throw -4;
3348    if ( !result->GetRowCount() ) printf(" No runs to validate \n");    if ( !result->GetRowCount() ) printf(" No runs to validate \n");
3349    printf("------------------------------------------------------------------------------- \n");  //  printf("------------------------------------------------------------------------------- \n");
3350        
3351    Int_t nrow = 0;    Int_t nrow = 0;
3352    GL_RUN* this_run = new GL_RUN();    GL_RUN* this_run = new GL_RUN();
3353    GL_RUN* next_run = new GL_RUN();    GL_RUN* next_run = new GL_RUN();
3354    Int_t   nseq_max = 100;    Int_t   nseq_max = 1000;
3355  //  UInt_t* sequence = new UInt_t[100];  //  UInt_t* sequence = new UInt_t[100];
3356    vector<UInt_t> sequence(nseq_max);    vector<UInt_t> sequence(nseq_max);
3357    Int_t   nseq = 0;    Int_t   nseq = 0;
# Line 3344  Int_t PamelaDBOperations::ValidateRuns() Line 3374  Int_t PamelaDBOperations::ValidateRuns()
3374            //get run info            //get run info
3375            //------------            //------------
3376            this_run->Set_GL_RUN(row);            this_run->Set_GL_RUN(row);
3377                                
           printf(" RUN ID %i --- TRK_CALIB_USED %i --- RM_ACQ_AFTER_CALIB %i --- TIME %i %i \n",this_run->ID,this_run->TRK_CALIB_USED,this_run->RM_ACQ_AFTER_CALIB,this_run->RUNHEADER_TIME, this_run->RUNTRAILER_TIME);  
             
3378            Bool_t this_BAD = false;            Bool_t this_BAD = false;
3379            if(this_run->GetTRK_CALIB_USED() == 1 || this_run->GetTRK_CALIB_USED() == 2) this_ONLINE = true;            if(this_run->GetTRK_CALIB_USED() == 1 || this_run->GetTRK_CALIB_USED() == 2) this_ONLINE = true;
3380            else if (this_run->GetTRK_CALIB_USED() == 104)                          this_ONLINE = false;            else if (this_run->GetTRK_CALIB_USED() == 104)                          this_ONLINE = false;
3381            else{            else{
3382                    printf("Missing or corrupted header!! \n");  //                printf("Missing or corrupted header!! \n");
3383                    this_ONLINE = false;                    this_ONLINE = false;
3384                    this_BAD = true;                    this_BAD = true;
3385            };            };
# Line 3375  Int_t PamelaDBOperations::ValidateRuns() Line 3403  Int_t PamelaDBOperations::ValidateRuns()
3403                                                        
3404                            if( interval >= 60 )CHECK = true;                     //more than 60 s => there might be a calibration                            if( interval >= 60 )CHECK = true;                     //more than 60 s => there might be a calibration
3405                                                        
 /*                        if( CHECK && !next_run->GetRM_ACQ_AFTER_CALIB() )  
                                   printf(" ValidateRuns ***WARNING*** : DT = %i but RM_ACQ_AFTER_CALIB = %i \n",(t2-t1),next_run->GetRM_ACQ_AFTER_CALIB());*/  
                                                     
                             
3406                            if( !CHECK && this_run->VALIDATION ){                            if( !CHECK && this_run->VALIDATION ){
3407                                    for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true);                                    for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true);
3408                                    nseq=0;                                    nseq=0;
# Line 3387  Int_t PamelaDBOperations::ValidateRuns() Line 3411  Int_t PamelaDBOperations::ValidateRuns()
3411                    }else if( !this_ONLINE && next_ONLINE) {              // this: DEFAULT + next:ON-LINE                    }else if( !this_ONLINE && next_ONLINE) {              // this: DEFAULT + next:ON-LINE
3412                                                        
3413                            CHECK = true;                            CHECK = true;
 //                        if( interval < 60 ) printf(" ValidateRuns ***WARNING*** : kkkkkk DT = %i \n",interval);  
3414    
3415                    }else if( !next_ONLINE ){                                             // this:ANY + next:DEFAULT                    }else if( !next_ONLINE ){                                             // this:ANY + next:DEFAULT
3416                                                        
# Line 3401  Int_t PamelaDBOperations::ValidateRuns() Line 3424  Int_t PamelaDBOperations::ValidateRuns()
3424            //----------------------------            //----------------------------
3425            if( CHECK ){            if( CHECK ){
3426                    // check if calibration exists                    // check if calibration exists
3427                    printf("DT %i ===> CHECK Missing calibration\n",interval);                    if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval);
3428                    Bool_t MISSING = MissingTRK_CALIB(t1,t2);                    Bool_t MISSING = MissingTRK_CALIB(t1,t2);
3429                    for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING);                    for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING);
3430                    nseq=0;                    nseq=0;
3431            } else printf("DT %i\n",interval);            };
3432            //--------------            //--------------
3433            //store run info            //store run info
3434            //--------------            //--------------
# Line 3418  Int_t PamelaDBOperations::ValidateRuns() Line 3441  Int_t PamelaDBOperations::ValidateRuns()
3441                    }else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max);                    }else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max);
3442            };            };
3443                        
3444              if ( IsDebug() ) printf("%i Run %i \n",nrow,this_run->ID);
3445            nrow++;            nrow++;
3446                        
3447    };    };
# Line 3446  Bool_t PamelaDBOperations::MissingTRK_CA Line 3470  Bool_t PamelaDBOperations::MissingTRK_CA
3470          // which should be equal to the time between ascending-nodes.          // which should be equal to the time between ascending-nodes.
3471          //==============================================================          //==============================================================
3472          if ( t2 - trkcalib->FROM_TIME > 5700) {          if ( t2 - trkcalib->FROM_TIME > 5700) {
3473                  printf("Long time to previous calib %i :-( \n",t2 - trkcalib->FROM_TIME);                  if ( IsDebug() )printf("Long time between calib and run start %i :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME);
3474          //==============================================================          //==============================================================
3475          // there might be a missing calibration, due to:          // there might be a missing calibration, due to:
3476          // - MM full          // - MM full
# Line 3467  Bool_t PamelaDBOperations::MissingTRK_CA Line 3491  Bool_t PamelaDBOperations::MissingTRK_CA
3491          // it is enough to say that there are no missing calibrations          // it is enough to say that there are no missing calibrations
3492          //==============================================================          //==============================================================
3493          // the long time interval bewteen runs might be due to download          // the long time interval bewteen runs might be due to download
3494          printf("Short time to previous calib %i :-) \n",t2 - trkcalib->FROM_TIME);          if ( IsDebug() )printf("Short time between calib and run start %i :-) ==> OK! \n",t2 - trkcalib->FROM_TIME);
3495          return(false);          return(false);
3496                    
3497  };  };
# Line 3480  Int_t PamelaDBOperations::assignVALIDATI Line 3504  Int_t PamelaDBOperations::assignVALIDATI
3504          TSQLResult *result = 0;          TSQLResult *result = 0;
3505          stringstream oss;          stringstream oss;
3506          oss.str("");          oss.str("");
3507          oss << " UPDATE GL_RUN SET VALIDATION="<< (UInt_t)validation <<" WHERE ID= " << idrun << "';";          oss << " UPDATE GL_RUN SET VALIDATION="<< (UInt_t)validation <<" WHERE ID= " << idrun << ";";
3508          //          //
3509  //      if ( IsDebug() )  //      if ( IsDebug() )
3510          printf(" Set VALIDATION = %i for run %i \n",validation,idrun);  //      printf(" Set VALIDATION = %i for run %i \n",validation,idrun);
3511  //      printf(" Set VALIDATION = %i for run %i : query is \n %s \n",validation,idrun,oss.str().c_str());          if ( IsDebug() )printf(" Query: %s \n",oss.str().c_str());
3512  //      result = conn->Query(oss.str().c_str());          result = conn->Query(oss.str().c_str());
3513  //      if ( !result ) throw -4;          if ( !result ) throw -4;
3514          return(0);          return(0);
3515  }  }
3516    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.23