/[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.10 by mocchiut, Fri Nov 7 08:56:13 2008 UTC revision 1.20 by mocchiut, Tue Dec 23 20:43:10 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 134  void PamelaDBOperations::OpenL0File(TStr Line 135  void PamelaDBOperations::OpenL0File(TStr
135        stringstream qu;        stringstream qu;
136        TSQLResult *result = 0;        TSQLResult *result = 0;
137        TSQLResult *result2 = 0;        TSQLResult *result2 = 0;
138          TSQLResult *result3 = 0;
139        TSQLRow    *row    = 0;            TSQLRow    *row    = 0;    
140        TSQLRow    *row2    = 0;            TSQLRow    *row2    = 0;    
141          TSQLRow    *row3    = 0;    
142        TString chpath;        TString chpath;
143        TString chfile;        TString chfile;
144        UInt_t ridn = 0;        UInt_t ridn = 0;
# Line 160  void PamelaDBOperations::OpenL0File(TStr Line 163  void PamelaDBOperations::OpenL0File(TStr
163        };        };
164        delete result;        delete result;
165        qu.str("");        qu.str("");
166        qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL from ROOT_TABLE where ID_N=" << ridn << ";";        qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,REAL_TIME_INIT from ROOT_TABLE where ID_N=" << ridn << ";";
167        if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());        if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
168        result2 = conn->Query(qu.str().c_str());        result2 = conn->Query(qu.str().c_str());
169        if ( result2 ){        if ( result2 ){
# Line 177  void PamelaDBOperations::OpenL0File(TStr Line 180  void PamelaDBOperations::OpenL0File(TStr
180            chresursts = (UInt_t)atoll(row2->GetField(4));            chresursts = (UInt_t)atoll(row2->GetField(4));
181            chboot = (UInt_t)atoll(row2->GetField(5));            chboot = (UInt_t)atoll(row2->GetField(5));
182            //            //
183              if ( !chboot ){
184                qu.str("");
185                qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND (REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;";
186                if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
187                result3 = conn->Query(qu.str().c_str());
188                if ( result3 ){
189                  row3 = result3->Next();
190                  if ( row3 && result3->GetRowCount() == 1 ){
191                    chboot = (UInt_t)atoll(row3->GetField(0));
192                    if ( debug ) printf(" Found boot_number = %u \n",chboot);
193                  } else {
194                    if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n");
195                    throw -29;
196                  };
197                };
198              };
199              //
200            chpktinit = (UInt_t)atoll(row2->GetField(6));            chpktinit = (UInt_t)atoll(row2->GetField(6));
201            chpktfinal = (UInt_t)atoll(row2->GetField(7));            chpktfinal = (UInt_t)atoll(row2->GetField(7));
202            chobtinit = (UInt_t)atoll(row2->GetField(8));            chobtinit = (UInt_t)atoll(row2->GetField(8));
# Line 189  void PamelaDBOperations::OpenL0File(TStr Line 209  void PamelaDBOperations::OpenL0File(TStr
209          throw -85;          throw -85;
210        };        };
211        filerootname = chpath + chfile;// + ".root";        filerootname = chpath + chfile;// + ".root";
       if ( debug ) printf(" chewbacca: filename is %s \n",filerootname.Data());  
212      };      };
213      this->SetRootName(filerootname);      this->SetRootName(filerootname);
     file = TFile::Open(this->GetRootName().Data());  
   } else {  
     this->SetRootName("");  
214    };    };
215      if ( debug ) printf(" Filename is %s \n",filerootname.Data());
216      file = TFile::Open(this->GetRootName().Data());
217      //  } else {
218      //    this->SetRootName("");
219      //    this->SetRootName(filerootname);
220      //  };
221  }  }
222    
223  //  //
# Line 395  void PamelaDBOperations::SetOrbitNo(UInt Line 417  void PamelaDBOperations::SetOrbitNo(UInt
417      return;      return;
418    };    };
419    //    //
420    TString name = this->GetRootFile();    if ( !chewbacca ){
421    Int_t nlength = name.Length();      TString name = this->GetRootFile();
422    if ( nlength < 5 ) return;      Int_t nlength = name.Length();
423    TString dwo = 0;      if ( nlength < 5 ){
424    for (Int_t i = 0; i<5; i++){        if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data());
425      dwo.Append(name[i],1);        return;
426    };      };
427    if ( dwo.IsDigit() ){      TString dwo = 0;
428      dworbit = (UInt_t)dwo.Atoi();      for (Int_t i = 0; i<5; i++){
   } else {  
     dwo="";  
     for (Int_t i = 8; i<13; i++){  
429        dwo.Append(name[i],1);        dwo.Append(name[i],1);
430      };          };
431      if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi();      if ( dwo.IsDigit() ){
432          dworbit = (UInt_t)dwo.Atoi();
433        } else {
434          dwo="";
435          for (Int_t i = 8; i<13; i++){
436            dwo.Append(name[i],1);
437          };    
438          if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi();
439        };
440        if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data());
441    };    };
   if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data());  
442    return;    return;
443  };  };
444    
# Line 1352  Long64_t PamelaDBOperations::OBT(UInt_t Line 1379  Long64_t PamelaDBOperations::OBT(UInt_t
1379    //    //
1380    //  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));
1381    //    //
1382    if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){    if ( obt < ((Long64_t)pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){
1383      //    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());
1384      return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max());      return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max());
1385    };    };
# Line 1577  Int_t PamelaDBOperations::insertPamelaGL Line 1604  Int_t PamelaDBOperations::insertPamelaGL
1604      result = conn->Query(oss.str().c_str());      result = conn->Query(oss.str().c_str());
1605      if ( !result ) throw -10;      if ( !result ) throw -10;
1606      row = result->Next();      row = result->Next();
1607        if ( !row ) throw -92;
1608      idresof = (UInt_t)atoll(row->GetField(0));      idresof = (UInt_t)atoll(row->GetField(0));
1609      existsts = true;      existsts = true;
1610      goto eout;      goto eout;
# Line 1598  Int_t PamelaDBOperations::insertPamelaGL Line 1626  Int_t PamelaDBOperations::insertPamelaGL
1626      if ( !row ){      if ( !row ){
1627        oss.str("");        oss.str("");
1628        oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID 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),ID FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "
1629            << dworbit << " order by FROM_ORBIT desc limit 1;";            << dworbit << " AND SPECIAL_FILE='' order by FROM_ORBIT desc limit 1;";
1630        if ( IsDebug() ) printf(" %s \n",oss.str().c_str());        if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
1631        result = conn->Query(oss.str().c_str());        result = conn->Query(oss.str().c_str());
1632        if ( !result ) throw -10;        if ( !result ) throw -10;
# Line 2239  Int_t PamelaDBOperations::insertPamelaRU Line 2267  Int_t PamelaDBOperations::insertPamelaRU
2267          ptht = cod->Get(pctp->RunHeader) - 1;          ptht = cod->Get(pctp->RunHeader) - 1;
2268          //      evbeft = cod->Get(pctp->Physics);          //      evbeft = cod->Get(pctp->Physics);
2269          tcod = (UInt_t)cod->Get(pctp->Physics);          tcod = (UInt_t)cod->Get(pctp->Physics);
2270          if ( !tcod ) tcod = 1;          if ( !tcod ) tcod = 1;    // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2271          evbeft = TMath::Min(upperentry,(tcod-1));          evbeft = TMath::Min(upperentry,(tcod-1));
2272          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));
2273          //          //
# Line 2278  Int_t PamelaDBOperations::insertPamelaRU Line 2306  Int_t PamelaDBOperations::insertPamelaRU
2306            obth = phh->GetOrbitalTime();            obth = phh->GetOrbitalTime();
2307            cod = ehh->GetCounter();            cod = ehh->GetCounter();
2308            tcod = (UInt_t)cod->Get(pctp->Physics);            tcod = (UInt_t)cod->Get(pctp->Physics);
2309            if ( !tcod ) tcod = 1;            if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2310            evbefh = TMath::Max(chminentry,(tcod-1));            evbefh = TMath::Max(chminentry,(tcod-1));
2311            //            //
2312            if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){            if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){
# Line 2340  Int_t PamelaDBOperations::insertPamelaRU Line 2368  Int_t PamelaDBOperations::insertPamelaRU
2368                cod = ehh->GetCounter();                cod = ehh->GetCounter();
2369                //            evbeft = cod->Get(pctp->Physics);                //            evbeft = cod->Get(pctp->Physics);
2370                tcod = (UInt_t)cod->Get(pctp->Physics);                tcod = (UInt_t)cod->Get(pctp->Physics);
2371                if ( !tcod ) tcod = 1;                if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2372                evbeft = TMath::Min(upperentry,(tcod-1));                evbeft = TMath::Min(upperentry,(tcod-1));
2373                rh->GetEntry(pth);                rh->GetEntry(pth);
2374                phh = ehh->GetPscuHeader();                phh = ehh->GetPscuHeader();
# Line 2382  Int_t PamelaDBOperations::insertPamelaRU Line 2410  Int_t PamelaDBOperations::insertPamelaRU
2410            //    if ( conptt+1 == (nrtev+nrtbef )){              //    if ( conptt+1 == (nrtev+nrtbef )){  
2411            if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt);            if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt);
2412            ptht++;            ptht++;
2413            if ( ptht < rhev ){            if ( ptht < rhev ){
2414              rh->GetEntry(ptht);              rh->GetEntry(ptht);
2415              //pth++;              //pth++;
2416              //if ( pth < rhev ){              //if ( pth < rhev ){
# Line 2410  Int_t PamelaDBOperations::insertPamelaRU Line 2438  Int_t PamelaDBOperations::insertPamelaRU
2438              if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){              if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){
2439                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);
2440                //                //
2441                if ( (ptt-1) < 0 ) throw -15; // should never arrive here!                //              if ( (ptt-1) < 0 ) throw -15; // should never arrive here!
2442                  if ( (rtev-1) < 0 || ptt < 0 ) throw -15; // should never arrive here!
2443                //              rt->GetEntry(ptt-1);                //              rt->GetEntry(ptt-1);
2444                rt->GetEntry(rtev-1);                rt->GetEntry(rtev-1);
2445                cod = eht->GetCounter();                cod = eht->GetCounter();
# Line 2645  void PamelaDBOperations::HandleRunFragme Line 2674  void PamelaDBOperations::HandleRunFragme
2674      //      //
2675      // 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
2676      //      //
2677      if ( rhfirstev != firstev && !mishead ) mishead = true;      if ( firstev != (lastev+1) ){ // could be a problem sometimes (?)
2678      if ( rtlastev != lastev && !mistrail ) mistrail = true;        if ( rhfirstev != firstev && !mishead ) mishead = true;
2679          if ( rtlastev != lastev && !mistrail ) mistrail = true;
2680        };
2681      //      //
2682        if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev);
2683      this->FillClass(mishead,mistrail,firstev,lastev);      this->FillClass(mishead,mistrail,firstev,lastev);
2684        if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev);
2685      //      //
2686      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");
2687      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 2743  void PamelaDBOperations::HandleRunFragme Line 2776  void PamelaDBOperations::HandleRunFragme
2776          //          //
2777          found = false; // default value          found = false; // default value
2778          //          //
2779          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");
2780          //          //
2781          // 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:
2782          //          //
# Line 2759  void PamelaDBOperations::HandleRunFragme Line 2792  void PamelaDBOperations::HandleRunFragme
2792              if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt);              if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt);
2793              //              //
2794              found = true;              found = true;
2795                if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev);
2796              //              //
2797            } else {            } else {
2798              //              //
# Line 2824  void PamelaDBOperations::HandleRunFragme Line 2858  void PamelaDBOperations::HandleRunFragme
2858          oss << " ID="<<row->GetField(0)<<";";          oss << " ID="<<row->GetField(0)<<";";
2859          //          //
2860          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
2861            if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev);
2862          //          //
2863          // merge infos          // merge infos
2864          //          //
# Line 2854  void PamelaDBOperations::HandleRunFragme Line 2889  void PamelaDBOperations::HandleRunFragme
2889          glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT());          glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT());
2890          glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT());          glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT());
2891          //          //
2892            if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev);
2893            //
2894          glrun->SetEV_FROM(firstev);          glrun->SetEV_FROM(firstev);
2895          glrun->SetNEVENTS(lastev-firstev+1);          glrun->SetNEVENTS(lastev-firstev+1);
2896          //          //
# Line 2946  void PamelaDBOperations::HandleRunFragme Line 2983  void PamelaDBOperations::HandleRunFragme
2983          //          //
2984          found = false; // default value          found = false; // default value
2985          //          //
2986          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");
2987          //          //
2988          // 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:
2989          //          //
# Line 3175  void PamelaDBOperations::HandleMissingHo Line 3212  void PamelaDBOperations::HandleMissingHo
3212        glrun->SetID(this->AssignRunID());        glrun->SetID(this->AssignRunID());
3213        glrun->SetID_RUN_FRAG(0);        glrun->SetID_RUN_FRAG(0);
3214        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...
3215      };        };
3216      //      //
3217    };    };
3218    //    //
# Line 3219  Bool_t PamelaDBOperations::IsRunConsiste Line 3256  Bool_t PamelaDBOperations::IsRunConsiste
3256    if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run!    if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run!
3257      //if ( firstev <= lastev+1 ) { // no events inside the run!      //if ( firstev <= lastev+1 ) { // no events inside the run!
3258      if ( IsDebug() ) printf(" Checking but no events in the run! \n");      if ( IsDebug() ) printf(" Checking but no events in the run! \n");
3259        firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files
3260      // return true is correct      // return true is correct
3261      return(true);      return(true);
3262      //      //
# Line 3474  Bool_t PamelaDBOperations::IsRunConsiste Line 3512  Bool_t PamelaDBOperations::IsRunConsiste
3512                  //                  //
3513                  found = false; // default value                  found = false; // default value
3514                  //                  //
3515                  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");
3516                  //                  //
3517                  // 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:
3518                  //                  //
# Line 6082  Int_t PamelaDBOperations::ValidateRuns(T Line 6120  Int_t PamelaDBOperations::ValidateRuns(T
6120      // 2) get the OBT of the last validated run      // 2) get the OBT of the last validated run
6121      // --------------------------------------------------------------      // --------------------------------------------------------------
6122      oss.str("");      oss.str("");
6123      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
6124        oss << " SELECT * FROM GL_RUN  WHERE VALIDATION>0 AND RUNHEADER_TIME<="<< t_start
6125          <<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;";          <<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;";
6126      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());
6127      result = conn->Query(oss.str().c_str());      result = conn->Query(oss.str().c_str());
# Line 6225  Int_t PamelaDBOperations::ValidateRuns(T Line 6264  Int_t PamelaDBOperations::ValidateRuns(T
6264          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
6265                                                        
6266          if( !CHECK && this_run->VALIDATION ){          if( !CHECK && this_run->VALIDATION ){
6267            for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true);            //      for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true);
6268              for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],this_run->VALIDATION);
6269            nseq=0;            nseq=0;
6270          }          }
6271                                        
# Line 6246  Int_t PamelaDBOperations::ValidateRuns(T Line 6286  Int_t PamelaDBOperations::ValidateRuns(T
6286      if( CHECK ){      if( CHECK ){
6287        // check if calibration exists        // check if calibration exists
6288        if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval);        if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval);
6289        Bool_t MISSING = MissingTRK_CALIB(t1,t2);        //      Bool_t MISSING = MissingTRK_CALIB(t1,t2);
6290        for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING);        UInt_t MISSING = MissingTRK_CALIB(t1,t2);
6291          UInt_t val = 0;
6292          if ( MISSING == 1 ) val = 0;
6293          if ( MISSING == 0 ) val = 1;
6294          if ( MISSING == 2 ) val = 2;
6295          for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],val);
6296        nseq=0;        nseq=0;
6297      };      };
6298      //--------------      //--------------
# Line 6277  Int_t PamelaDBOperations::ValidateRuns(T Line 6322  Int_t PamelaDBOperations::ValidateRuns(T
6322   * @param t2 To absolute time   * @param t2 To absolute time
6323   * @return true if there might be a missing calibration   * @return true if there might be a missing calibration
6324   */   */
6325  Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){  //Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){
6326    UInt_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){
6327                    
6328    GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB();    GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB();
6329                    
6330    // get the closest calibration before the run start (t2)    // get the closest calibration before the run start (t2)
6331    if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true);    //>>> missing    //  if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true);        //>>> missing
6332      if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(1);       //>>> missing
6333                    
6334    if ( trkcalib->TO_TIME  < t2 ) return(true);                                  //>>> missing    //  if ( trkcalib->TO_TIME  < t2 ) return(true);                                      //>>> missing
6335      if ( trkcalib->TO_TIME  < t2 ) return(1);                                     //>>> missing
6336                    
6337    //==============================================================    //==============================================================
6338    // Check is done first on the basis of time between calibration,    // Check is done first on the basis of time between calibration,
# Line 6301  Bool_t PamelaDBOperations::MissingTRK_CA Line 6349  Bool_t PamelaDBOperations::MissingTRK_CA
6349      //==============================================================      //==============================================================
6350      Bool_t DOWNLOAD = false;      Bool_t DOWNLOAD = false;
6351      // check if the calib was skipped becouse of download .... DA FARE!!      // check if the calib was skipped becouse of download .... DA FARE!!
6352      if(DOWNLOAD)return(false);      //    if(DOWNLOAD)return(false);
6353        if(DOWNLOAD)return(0);
6354                                    
6355      return(true);                                       //>>> missing      //    return(true);                                         //>>> missing
6356        return(1);                                  //>>> missing
6357                                    
6358    };    };
6359                    
# Line 6313  Bool_t PamelaDBOperations::MissingTRK_CA Line 6363  Bool_t PamelaDBOperations::MissingTRK_CA
6363    //==============================================================    //==============================================================
6364    // the long time interval bewteen runs might be due to download    // the long time interval bewteen runs might be due to download
6365    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);
6366    return(false);    if ( trkcalib->VALIDATION ) return(0);
6367      if ( IsDebug() )printf("Calibration is not validated... :-/ ==> OK but with VALIDATION=2! \n");
6368      return(2);
6369                    
6370  };  };
6371  /**  /**
# Line 6322  Bool_t PamelaDBOperations::MissingTRK_CA Line 6374  Bool_t PamelaDBOperations::MissingTRK_CA
6374   * @param validation true/false   * @param validation true/false
6375   */   */
6376  Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){  Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){
6377      return(this->assignVALIDATION(idrun,(UInt_t)validation));
6378    }
6379    
6380    Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, UInt_t validation){
6381    TSQLResult *result = 0;    TSQLResult *result = 0;
6382    stringstream oss;    stringstream oss;
6383    oss.str("");    oss.str("");

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.23