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

Diff of /chewbacca/YodaProfiler/src/PamelaDBOperations.cpp

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

revision 1.9 by mocchiut, Tue Nov 4 17:11:41 2008 UTC revision 1.16 by mocchiut, Fri Dec 12 10:49:54 2008 UTC
# Line 101  PamelaDBOperations::PamelaDBOperations(T Line 101  PamelaDBOperations::PamelaDBOperations(T
101    if (INSERT_RAW) SetRawName(filerawname);    if (INSERT_RAW) SetRawName(filerawname);
102    //    //
103    INSERT_ROOT = !filerootname.IsNull();    INSERT_ROOT = !filerootname.IsNull();
104      if ( INSERT_ROOT ) this->SetRootName(filerootname);
105    this->SetOrbitNo(dwinput);    this->SetOrbitNo(dwinput);
106    //    //
107    this->SetID_RAW(0);    this->SetID_RAW(0);
# Line 189  void PamelaDBOperations::OpenL0File(TStr Line 190  void PamelaDBOperations::OpenL0File(TStr
190          throw -85;          throw -85;
191        };        };
192        filerootname = chpath + chfile;// + ".root";        filerootname = chpath + chfile;// + ".root";
       if ( debug ) printf(" chewbacca: filename is %s \n",filerootname.Data());  
193      };      };
194      this->SetRootName(filerootname);      this->SetRootName(filerootname);
     file = TFile::Open(this->GetRootName().Data());  
   } else {  
     this->SetRootName("");  
195    };    };
196      if ( debug ) printf(" Filename is %s \n",filerootname.Data());
197      file = TFile::Open(this->GetRootName().Data());
198      //  } else {
199      //    this->SetRootName("");
200      //    this->SetRootName(filerootname);
201      //  };
202  }  }
203    
204  //  //
# Line 395  void PamelaDBOperations::SetOrbitNo(UInt Line 398  void PamelaDBOperations::SetOrbitNo(UInt
398      return;      return;
399    };    };
400    //    //
401    TString name = this->GetRootFile();    if ( !chewbacca ){
402    Int_t nlength = name.Length();      TString name = this->GetRootFile();
403    if ( nlength < 5 ) return;      Int_t nlength = name.Length();
404    TString dwo = 0;      if ( nlength < 5 ){
405    for (Int_t i = 0; i<5; i++){        if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data());
406      dwo.Append(name[i],1);        return;
407    };      };
408    if ( dwo.IsDigit() ){      TString dwo = 0;
409      dworbit = (UInt_t)dwo.Atoi();      for (Int_t i = 0; i<5; i++){
   } else {  
     dwo="";  
     for (Int_t i = 8; i<13; i++){  
410        dwo.Append(name[i],1);        dwo.Append(name[i],1);
411      };          };
412      if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi();      if ( dwo.IsDigit() ){
413          dworbit = (UInt_t)dwo.Atoi();
414        } else {
415          dwo="";
416          for (Int_t i = 8; i<13; i++){
417            dwo.Append(name[i],1);
418          };    
419          if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi();
420        };
421        if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data());
422    };    };
   if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data());  
423    return;    return;
424  };  };
425    
# Line 1352  Long64_t PamelaDBOperations::OBT(UInt_t Line 1360  Long64_t PamelaDBOperations::OBT(UInt_t
1360    //    //
1361    //  if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u  (numeric_limits<UInt_t>::max()/2) is %u  \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2));    //  if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u  (numeric_limits<UInt_t>::max()/2) is %u  \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2));
1362    //    //
1363    if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){    if ( obt < ((Long64_t)pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){
1364      //    if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max());      //    if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max());
1365      return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max());      return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max());
1366    };    };
# Line 1577  Int_t PamelaDBOperations::insertPamelaGL Line 1585  Int_t PamelaDBOperations::insertPamelaGL
1585      result = conn->Query(oss.str().c_str());      result = conn->Query(oss.str().c_str());
1586      if ( !result ) throw -10;      if ( !result ) throw -10;
1587      row = result->Next();      row = result->Next();
1588        if ( !row ) throw -92;
1589      idresof = (UInt_t)atoll(row->GetField(0));      idresof = (UInt_t)atoll(row->GetField(0));
1590      existsts = true;      existsts = true;
1591      goto eout;      goto eout;
# Line 2239  Int_t PamelaDBOperations::insertPamelaRU Line 2248  Int_t PamelaDBOperations::insertPamelaRU
2248          ptht = cod->Get(pctp->RunHeader) - 1;          ptht = cod->Get(pctp->RunHeader) - 1;
2249          //      evbeft = cod->Get(pctp->Physics);          //      evbeft = cod->Get(pctp->Physics);
2250          tcod = (UInt_t)cod->Get(pctp->Physics);          tcod = (UInt_t)cod->Get(pctp->Physics);
2251          if ( !tcod ) tcod = 1;          //      if ( !tcod ) tcod = 1;    // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2252          evbeft = TMath::Min(upperentry,(tcod-1));          evbeft = TMath::Min(upperentry,(tcod-1));
2253          if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics));          if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics));
2254          //          //
# Line 2278  Int_t PamelaDBOperations::insertPamelaRU Line 2287  Int_t PamelaDBOperations::insertPamelaRU
2287            obth = phh->GetOrbitalTime();            obth = phh->GetOrbitalTime();
2288            cod = ehh->GetCounter();            cod = ehh->GetCounter();
2289            tcod = (UInt_t)cod->Get(pctp->Physics);            tcod = (UInt_t)cod->Get(pctp->Physics);
2290            if ( !tcod ) tcod = 1;            //      if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2291            evbefh = TMath::Max(chminentry,(tcod-1));            evbefh = TMath::Max(chminentry,(tcod-1));
2292            //            //
2293            if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){            if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){
# Line 2317  Int_t PamelaDBOperations::insertPamelaRU Line 2326  Int_t PamelaDBOperations::insertPamelaRU
2326                //                //
2327                this->HandleRunFragments(true,true,chminentry,(evbefh));                this->HandleRunFragments(true,true,chminentry,(evbefh));
2328                //                //
2329                  // what about pth=ptht-1
2330              };              };
2331            };            };
2332            //            //
# Line 2339  Int_t PamelaDBOperations::insertPamelaRU Line 2349  Int_t PamelaDBOperations::insertPamelaRU
2349                cod = ehh->GetCounter();                cod = ehh->GetCounter();
2350                //            evbeft = cod->Get(pctp->Physics);                //            evbeft = cod->Get(pctp->Physics);
2351                tcod = (UInt_t)cod->Get(pctp->Physics);                tcod = (UInt_t)cod->Get(pctp->Physics);
2352                if ( !tcod ) tcod = 1;                //              if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2353                evbeft = TMath::Min(upperentry,(tcod-1));                evbeft = TMath::Min(upperentry,(tcod-1));
2354                rh->GetEntry(pth);                rh->GetEntry(pth);
2355                phh = ehh->GetPscuHeader();                phh = ehh->GetPscuHeader();
# Line 2379  Int_t PamelaDBOperations::insertPamelaRU Line 2389  Int_t PamelaDBOperations::insertPamelaRU
2389          //      if ( ptt+1 == rtev){            //      if ( ptt+1 == rtev){  
2390          if ( conptt+1 == nrtev ){            if ( conptt+1 == nrtev ){  
2391            //    if ( conptt+1 == (nrtev+nrtbef )){              //    if ( conptt+1 == (nrtev+nrtbef )){  
2392              if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt);
2393            ptht++;            ptht++;
2394            if ( ptht < rhev ){            if ( ptht < rhev ){
2395              rh->GetEntry(ptht);              rh->GetEntry(ptht);
2396                //pth++;
2397                //if ( pth < rhev ){
2398                //rh->GetEntry(pth);
2399              phh = ehh->GetPscuHeader();              phh = ehh->GetPscuHeader();
2400              pkth = phh->GetCounter();              pkth = phh->GetCounter();
2401              obth = phh->GetOrbitalTime();              obth = phh->GetOrbitalTime();
# Line 2405  Int_t PamelaDBOperations::insertPamelaRU Line 2419  Int_t PamelaDBOperations::insertPamelaRU
2419              if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){              if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){
2420                if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1);                if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1);
2421                //                //
2422                if ( (ptt-1) < 0 ) throw -15; // should never arrive here!                //              if ( (ptt-1) < 0 ) throw -15; // should never arrive here!
2423                rt->GetEntry(ptt-1);                if ( (rtev-1) < 0 || ptt < 0 ) throw -15; // should never arrive here!
2424                  //              rt->GetEntry(ptt-1);
2425                  rt->GetEntry(rtev-1);
2426                cod = eht->GetCounter();                cod = eht->GetCounter();
2427                tcod = (UInt_t)cod->Get(pctp->Physics);                tcod = (UInt_t)cod->Get(pctp->Physics)+1;
2428                evbefh = TMath::Max(chminentry,tcod);                evbefh = TMath::Max(chminentry,tcod);
2429                //            evbefh = cod->Get(pctp->Physics);                //            evbefh = cod->Get(pctp->Physics);
2430                rt->GetEntry(ptt);                rt->GetEntry(ptt);
# Line 2639  void PamelaDBOperations::HandleRunFragme Line 2655  void PamelaDBOperations::HandleRunFragme
2655      //      //
2656      // we have now the good first piece of a run, fill the glrun object      // we have now the good first piece of a run, fill the glrun object
2657      //      //
2658      if ( rhfirstev != firstev && !mishead ) mishead = true;      if ( firstev != (lastev+1) ){ // could be a problem sometimes (?)
2659      if ( rtlastev != lastev && !mistrail ) mistrail = true;        if ( rhfirstev != firstev && !mishead ) mishead = true;
2660          if ( rtlastev != lastev && !mistrail ) mistrail = true;
2661        };
2662      //      //
2663        if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev);
2664      this->FillClass(mishead,mistrail,firstev,lastev);      this->FillClass(mishead,mistrail,firstev,lastev);
2665        if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev);
2666      //      //
2667      if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n");      if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n");
2668      if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT());      if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT());
# Line 2737  void PamelaDBOperations::HandleRunFragme Line 2757  void PamelaDBOperations::HandleRunFragme
2757          //          //
2758          found = false; // default value          found = false; // default value
2759          //          //
2760          if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n");          if ( IsDebug() ) printf(" A Found a possible candidate, checking if it is the good one... \n");
2761          //          //
2762          // if we have both runheader and runtrailer we can check with pkt_counter:          // if we have both runheader and runtrailer we can check with pkt_counter:
2763          //          //
# Line 2753  void PamelaDBOperations::HandleRunFragme Line 2773  void PamelaDBOperations::HandleRunFragme
2773              if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt);              if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt);
2774              //              //
2775              found = true;              found = true;
2776                if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev);
2777              //              //
2778            } else {            } else {
2779              //              //
# Line 2818  void PamelaDBOperations::HandleRunFragme Line 2839  void PamelaDBOperations::HandleRunFragme
2839          oss << " ID="<<row->GetField(0)<<";";          oss << " ID="<<row->GetField(0)<<";";
2840          //          //
2841          glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos          glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos
2842            if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev);
2843          //          //
2844          // merge infos          // merge infos
2845          //          //
# Line 2848  void PamelaDBOperations::HandleRunFragme Line 2870  void PamelaDBOperations::HandleRunFragme
2870          glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT());          glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT());
2871          glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT());          glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT());
2872          //          //
2873            if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev);
2874            //
2875          glrun->SetEV_FROM(firstev);          glrun->SetEV_FROM(firstev);
2876          glrun->SetNEVENTS(lastev-firstev+1);          glrun->SetNEVENTS(lastev-firstev+1);
2877          //          //
# Line 2940  void PamelaDBOperations::HandleRunFragme Line 2964  void PamelaDBOperations::HandleRunFragme
2964          //          //
2965          found = false; // default value          found = false; // default value
2966          //          //
2967          if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n");          if ( IsDebug() ) printf(" B Found a possible candidate, checking if it is the good one... \n");
2968          //          //
2969          // if we have both runheader and runtrailer we can check with pkt_counter:          // if we have both runheader and runtrailer we can check with pkt_counter:
2970          //          //
# Line 3169  void PamelaDBOperations::HandleMissingHo Line 3193  void PamelaDBOperations::HandleMissingHo
3193        glrun->SetID(this->AssignRunID());        glrun->SetID(this->AssignRunID());
3194        glrun->SetID_RUN_FRAG(0);        glrun->SetID_RUN_FRAG(0);
3195        glrun->Fill_GL_RUN(conn);    // it'ok we arrive here only inside a file hence in the middle of the runs...        glrun->Fill_GL_RUN(conn);    // it'ok we arrive here only inside a file hence in the middle of the runs...
3196      };        };
3197      //      //
3198    };    };
3199    //    //
# Line 3213  Bool_t PamelaDBOperations::IsRunConsiste Line 3237  Bool_t PamelaDBOperations::IsRunConsiste
3237    if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run!    if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run!
3238      //if ( firstev <= lastev+1 ) { // no events inside the run!      //if ( firstev <= lastev+1 ) { // no events inside the run!
3239      if ( IsDebug() ) printf(" Checking but no events in the run! \n");      if ( IsDebug() ) printf(" Checking but no events in the run! \n");
3240        firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files
3241      // return true is correct      // return true is correct
3242      return(true);      return(true);
3243      //      //
# Line 3242  Bool_t PamelaDBOperations::IsRunConsiste Line 3267  Bool_t PamelaDBOperations::IsRunConsiste
3267        //        //
3268      } else {      } else {
3269        //        //
3270        if ( IsDebug() ) printf(" There are no-phyics packets inside the run!\n");        if ( IsDebug() ) printf(" There are no-physics packets inside the run!\n");
3271        //        //
3272        // HERE WE MUST HANDLE THAT RUNS AND GO BACK        // HERE WE MUST HANDLE THAT RUNS AND GO BACK
3273        //        //
# Line 3252  Bool_t PamelaDBOperations::IsRunConsiste Line 3277  Bool_t PamelaDBOperations::IsRunConsiste
3277        UInt_t check = 0;        UInt_t check = 0;
3278        UInt_t lastevtemp = lastev;        UInt_t lastevtemp = lastev;
3279        UInt_t firstevno = firstev;        UInt_t firstevno = firstev;
3280          UInt_t rhchko=0;
3281          UInt_t rhchk=0;
3282        //        //
3283        for (UInt_t i=firstev; i<=lastev; i++){        for (UInt_t i=firstev; i<=lastev; i++){
3284          //          //
# Line 3260  Bool_t PamelaDBOperations::IsRunConsiste Line 3287  Bool_t PamelaDBOperations::IsRunConsiste
3287          //          //
3288          check = 0;          check = 0;
3289          //          //
3290    
3291            // if we have a runheader set lastev then exit
3292            //
3293          for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){          for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){
3294            if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter));            if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter));
3295          };          };
3296            // check here if we have a runheader
3297            rhchko = rhchk;  
3298            rhchk = code->Get(GetPacketType("RunHeader"));    
3299          //          //
3300          if ( checkfirst < check || i == lastev ){          if ( checkfirst < check || i == lastev ){
3301            //            //
# Line 3460  Bool_t PamelaDBOperations::IsRunConsiste Line 3493  Bool_t PamelaDBOperations::IsRunConsiste
3493                  //                  //
3494                  found = false; // default value                  found = false; // default value
3495                  //                  //
3496                  if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n");                  if ( IsDebug() ) printf(" C Found a possible candidate, checking if it is the good one... \n");
3497                  //                  //
3498                  // if we have both runheader and runtrailer we can check with pkt_counter:                  // if we have both runheader and runtrailer we can check with pkt_counter:
3499                  //                  //
# Line 3679  Bool_t PamelaDBOperations::IsRunConsiste Line 3712  Bool_t PamelaDBOperations::IsRunConsiste
3712            //            //
3713          };          };
3714          //          //
3715            if ( i > firstev ){
3716              if ( rhchko != rhchk ){
3717                if ( IsDebug() ) printf("oh oh... we have a runheader! stop here and handle later the remaining piece\n");
3718                lastev = i;
3719                return(false);
3720              };
3721            };
3722            //
3723          if ( check == checklast && i != lastev ){          if ( check == checklast && i != lastev ){
3724            lastevtemp = i - 1;            lastevtemp = i - 1;
3725            i = lastev - 1;            i = lastev - 1;
# Line 6060  Int_t PamelaDBOperations::ValidateRuns(T Line 6101  Int_t PamelaDBOperations::ValidateRuns(T
6101      // 2) get the OBT of the last validated run      // 2) get the OBT of the last validated run
6102      // --------------------------------------------------------------      // --------------------------------------------------------------
6103      oss.str("");      oss.str("");
6104      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
6105        oss << " SELECT * FROM GL_RUN  WHERE VALIDATION>0 AND RUNHEADER_TIME<="<< t_start
6106          <<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;";          <<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;";
6107      if ( IsDebug() ) 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());
6108      result = conn->Query(oss.str().c_str());      result = conn->Query(oss.str().c_str());
# Line 6203  Int_t PamelaDBOperations::ValidateRuns(T Line 6245  Int_t PamelaDBOperations::ValidateRuns(T
6245          if( interval >= calibtime )CHECK = true;                        //more than calibtime s => there might be a calibration          if( interval >= calibtime )CHECK = true;                        //more than calibtime s => there might be a calibration
6246                                                        
6247          if( !CHECK && this_run->VALIDATION ){          if( !CHECK && this_run->VALIDATION ){
6248            for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true);            //      for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true);
6249              for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],this_run->VALIDATION);
6250            nseq=0;            nseq=0;
6251          }          }
6252                                        
# Line 6224  Int_t PamelaDBOperations::ValidateRuns(T Line 6267  Int_t PamelaDBOperations::ValidateRuns(T
6267      if( CHECK ){      if( CHECK ){
6268        // check if calibration exists        // check if calibration exists
6269        if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval);        if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval);
6270        Bool_t MISSING = MissingTRK_CALIB(t1,t2);        //      Bool_t MISSING = MissingTRK_CALIB(t1,t2);
6271        for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING);        UInt_t MISSING = MissingTRK_CALIB(t1,t2);
6272          UInt_t val = 0;
6273          if ( MISSING == 1 ) val = 0;
6274          if ( MISSING == 0 ) val = 1;
6275          if ( MISSING == 2 ) val = 2;
6276          for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],val);
6277        nseq=0;        nseq=0;
6278      };      };
6279      //--------------      //--------------
# Line 6255  Int_t PamelaDBOperations::ValidateRuns(T Line 6303  Int_t PamelaDBOperations::ValidateRuns(T
6303   * @param t2 To absolute time   * @param t2 To absolute time
6304   * @return true if there might be a missing calibration   * @return true if there might be a missing calibration
6305   */   */
6306  Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){  //Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){
6307    UInt_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){
6308                    
6309    GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB();    GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB();
6310                    
6311    // get the closest calibration before the run start (t2)    // get the closest calibration before the run start (t2)
6312    if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true);    //>>> missing    //  if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true);        //>>> missing
6313      if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(1);       //>>> missing
6314                    
6315    if ( trkcalib->TO_TIME  < t2 ) return(true);                                  //>>> missing    //  if ( trkcalib->TO_TIME  < t2 ) return(true);                                      //>>> missing
6316      if ( trkcalib->TO_TIME  < t2 ) return(1);                                     //>>> missing
6317                    
6318    //==============================================================    //==============================================================
6319    // Check is done first on the basis of time between calibration,    // Check is done first on the basis of time between calibration,
# Line 6279  Bool_t PamelaDBOperations::MissingTRK_CA Line 6330  Bool_t PamelaDBOperations::MissingTRK_CA
6330      //==============================================================      //==============================================================
6331      Bool_t DOWNLOAD = false;      Bool_t DOWNLOAD = false;
6332      // check if the calib was skipped becouse of download .... DA FARE!!      // check if the calib was skipped becouse of download .... DA FARE!!
6333      if(DOWNLOAD)return(false);      //    if(DOWNLOAD)return(false);
6334        if(DOWNLOAD)return(0);
6335                                    
6336      return(true);                                       //>>> missing      //    return(true);                                         //>>> missing
6337        return(1);                                  //>>> missing
6338                                    
6339    };    };
6340                    
# Line 6291  Bool_t PamelaDBOperations::MissingTRK_CA Line 6344  Bool_t PamelaDBOperations::MissingTRK_CA
6344    //==============================================================    //==============================================================
6345    // the long time interval bewteen runs might be due to download    // the long time interval bewteen runs might be due to download
6346    if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME);    if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME);
6347    return(false);    if ( trkcalib->VALIDATION ) return(0);
6348      if ( IsDebug() )printf("Calibration is not validated... :-/ ==> OK but with VALIDATION=2! \n");
6349      return(2);
6350                    
6351  };  };
6352  /**  /**
# Line 6300  Bool_t PamelaDBOperations::MissingTRK_CA Line 6355  Bool_t PamelaDBOperations::MissingTRK_CA
6355   * @param validation true/false   * @param validation true/false
6356   */   */
6357  Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){  Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){
6358      return(this->assignVALIDATION(idrun,(UInt_t)validation));
6359    }
6360    
6361    Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, UInt_t validation){
6362    TSQLResult *result = 0;    TSQLResult *result = 0;
6363    stringstream oss;    stringstream oss;
6364    oss.str("");    oss.str("");
# Line 6496  Int_t PamelaDBOperations::removeFile(TSt Line 6555  Int_t PamelaDBOperations::removeFile(TSt
6555    stringstream myquery;    stringstream myquery;
6556    //      //  
6557    myquery.str("");    myquery.str("");
6558    myquery << " SELECT ID, ID_RAW FROM GL_ROOT where NAME='"<<remfile.Data() <<"';";    myquery << " SELECT ID,ID_RAW,ID_TIMESYNC FROM GL_ROOT where NAME='"<<remfile.Data() <<"';";
6559    //    //
6560    pResult = conn->Query(myquery.str().c_str());    pResult = conn->Query(myquery.str().c_str());
6561    //    //
# Line 6512  Int_t PamelaDBOperations::removeFile(TSt Line 6571  Int_t PamelaDBOperations::removeFile(TSt
6571    //    //
6572    this->SetID_ROOT((UInt_t)atoll(Row->GetField(0)));    this->SetID_ROOT((UInt_t)atoll(Row->GetField(0)));
6573    this->SetID_RAW((UInt_t)atoll(Row->GetField(1)));    this->SetID_RAW((UInt_t)atoll(Row->GetField(1)));
6574      UInt_t idtsy=(UInt_t)atoll(Row->GetField(2));
6575    //    //
6576    this->ValidationOFF();    this->ValidationOFF();
6577    //    //
# Line 6519  Int_t PamelaDBOperations::removeFile(TSt Line 6579  Int_t PamelaDBOperations::removeFile(TSt
6579    //    //
6580    this->RemoveRUNS();    this->RemoveRUNS();
6581    //    //
6582    this->RemoveFILES();    this->RemoveFILES(idtsy);
6583    //    //
6584    this->SetID_ROOT(0);    this->SetID_ROOT(0);
6585    this->SetID_RAW(0);    this->SetID_RAW(0);
# Line 6739  void PamelaDBOperations::RemoveRUNS(){ Line 6799  void PamelaDBOperations::RemoveRUNS(){
6799   * Rearrange calibration tables   * Rearrange calibration tables
6800   *   *
6801   **/   **/
6802  void PamelaDBOperations::RemoveFILES(){  void PamelaDBOperations::RemoveFILES(UInt_t idtsy){
6803    stringstream myquery;    stringstream myquery;
6804    //    //
6805    myquery.str("");    myquery.str("");
# Line 6749  void PamelaDBOperations::RemoveFILES(){ Line 6809  void PamelaDBOperations::RemoveFILES(){
6809    //    //
6810    conn->Query(myquery.str().c_str());    conn->Query(myquery.str().c_str());
6811    //    //
6812      myquery.str("");
6813      myquery << " DELETE FROM GL_ROOT WHERE ID=" <<this->GetID_ROOT() <<";";
6814      //
6815      if ( IsDebug() ) printf("  query is \n %s \n",myquery.str().c_str());
6816      //
6817      conn->Query(myquery.str().c_str());  //
6818      //
6819      if ( !chewbacca ){
6820        myquery.str("");
6821        myquery << " DELETE FROM GL_TIMESYNC WHERE ID=" << idtsy <<";";
6822        //
6823        if ( IsDebug() ) printf("  query is \n %s \n",myquery.str().c_str());
6824        //
6825        conn->Query(myquery.str().c_str());
6826      };
6827      //
6828  };  };
6829    
6830  /**  /**

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

  ViewVC Help
Powered by ViewVC 1.1.23