/[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.33 by mocchiut, Mon Apr 30 08:31:28 2007 UTC revision 1.50 by mocchiut, Wed Sep 5 15:34:49 2007 UTC
# Line 56  string getTleDatetime(cTle*); Line 56  string getTleDatetime(cTle*);
56   * @param debug        debug flag.   * @param debug        debug flag.
57   * @param tlefilename  ascii file with TLE 3 line elements.   * @param tlefilename  ascii file with TLE 3 line elements.
58   */   */
59  PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp){  PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp, Bool_t gpamela){
60    //    //
61    STATIC=false;    STATIC=false;
62    if ( staticp ) STATIC=true;    if ( staticp ) STATIC=true;
# Line 68  PamelaDBOperations::PamelaDBOperations(T Line 68  PamelaDBOperations::PamelaDBOperations(T
68    glrun = new GL_RUN();    glrun = new GL_RUN();
69    //    //
70    if ( !boot ) SetNOBOOT(false);    if ( !boot ) SetNOBOOT(false);
71    SetBOOTnumber(boot);    SetTsync(tsync,gpamela);
72    SetTsync(tsync);    SetBOOTnumber(boot,gpamela);
73    SetObt0(obt0);    SetObt0(obt0);
74    //    //
75    SetTLEPath(tlefilename);    SetTLEPath(tlefilename);
# Line 179  void PamelaDBOperations::SetNoFrag(Bool_ Line 179  void PamelaDBOperations::SetNoFrag(Bool_
179   * @param boot    BOOT number of the RAW file   * @param boot    BOOT number of the RAW file
180   */   */
181  void PamelaDBOperations::SetBOOTnumber(UInt_t boot){  void PamelaDBOperations::SetBOOTnumber(UInt_t boot){
182      this->SetBOOTnumber(boot,false);
183    };
184    
185    /**
186     * Store the BOOT number of the RAW file.
187     * @param boot    BOOT number of the RAW file
188     */
189    void PamelaDBOperations::SetBOOTnumber(UInt_t boot, Bool_t gpamela){
190    BOOTNO=boot;    BOOTNO=boot;
191      if ( gpamela ){
192        stringstream oss;
193        TSQLResult *result = 0;
194        TSQLRow    *row    = 0;    
195        if ( !boot ){
196          //
197          BOOTNO = 1;
198          //
199          // look in the DB for the last timesync and the last run
200          //
201          oss.str("");
202          oss << "SELECT BOOT_NUMBER FROM GL_RUN order by RUNHEADER_TIME desc limit 1;";
203          result = conn->Query(oss.str().c_str());
204          if ( result ){
205            row = result->Next();
206            if ( row ){
207              BOOTNO = (UInt_t)atoll(row->GetField(0)) + 1;
208            };
209          };
210        };
211      };
212  };  };
213    
214  /**  /**
# Line 187  void PamelaDBOperations::SetBOOTnumber(U Line 216  void PamelaDBOperations::SetBOOTnumber(U
216   * @param boot    time sync   * @param boot    time sync
217   */   */
218  void PamelaDBOperations::SetTsync(UInt_t ts){  void PamelaDBOperations::SetTsync(UInt_t ts){
219      this->SetTsync(ts,false);
220    };
221    
222    /**
223     * Store the time sync of the RAW file.
224     * @param boot    time sync
225     */
226    void PamelaDBOperations::SetTsync(UInt_t ts, Bool_t gpamela){
227      //
228      // if not gpamela or given tsync file set ts
229      //
230    tsync=ts;    tsync=ts;
231      if ( gpamela ){
232        stringstream oss;
233        TSQLResult *result = 0;
234        TSQLRow    *row    = 0;    
235        TSQLResult *result2 = 0;
236        TSQLRow    *row2    = 0;    
237        if ( !ts ){
238          //
239          tsync = 1;
240          //
241          // look in the DB for the last timesync and the last run
242          //
243          oss.str("");
244          oss << "SELECT TIMESYNC FROM GL_TIMESYNC order by TIMESYNC desc limit 1;";
245          result = conn->Query(oss.str().c_str());
246          if ( result ){
247            row = result->Next();
248            if ( row ){
249              tsync = (UInt_t)atoll(row->GetField(0)) + 1;
250              oss.str("");
251              oss << "SELECT (RUNTRAILER_TIME-RUNHEADER_TIME) FROM GL_RUN order by RUNHEADER_TIME desc limit 1;";
252              result2 = conn->Query(oss.str().c_str());
253              if ( result2 ){
254                row2 = result2->Next();
255                if ( row2 ){
256                  tsync += (UInt_t)atoll(row2->GetField(0));
257                };
258              }
259            };
260          };
261        };
262      };
263  };  };
264    
265  /**  /**
# Line 400  Int_t PamelaDBOperations::SetUpperLimits Line 472  Int_t PamelaDBOperations::SetUpperLimits
472    upperobt = OBT(obtlast);    upperobt = OBT(obtlast);
473    upperentry = nevent-1;    upperentry = nevent-1;
474    //    //
475    if ( IsDebug() ) printf(" First entries are: OBT %i pkt_num %i \n",obtfirst,pktfirst);    if ( IsDebug() ) printf(" First entries are: OBT %u pkt_num %u \n",obtfirst,pktfirst);
476    //    //
477    if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry);    if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry);
478    //    //
479    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(32);
480    //    //
481    if ( !nevent ) return(2);    if ( !nevent ) return(64);
482    //    //
483    if ( nevent < 2 ) return(4);    if ( nevent < 2 ) return(128);
484    if ( nevent < jump ) jump = 1;    if ( nevent < jump ) jump = 1;
485    //  if ( nevent < jump ) jump = int(nevent/10);    //  if ( nevent < jump ) jump = int(nevent/10);
486    //  if ( !jump ) jump = 1;    //  if ( !jump ) jump = 1;
# Line 447  Int_t PamelaDBOperations::SetUpperLimits Line 519  Int_t PamelaDBOperations::SetUpperLimits
519          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 ){
520            zomp = i + jump + 1;            zomp = i + jump + 1;
521            if ( zomp > nevent-2 ) zomp = nevent - 2;            if ( zomp > nevent-2 ) zomp = nevent - 2;
522            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);            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);
523            break;            break;
524          };          };
525          //          //
# Line 1035  Int_t PamelaDBOperations::insertPamelaGL Line 1107  Int_t PamelaDBOperations::insertPamelaGL
1107    TSQLResult *result = 0;    TSQLResult *result = 0;
1108    TSQLRow *row = 0;    TSQLRow *row = 0;
1109    UInt_t t0 = 0;    UInt_t t0 = 0;
1110      Int_t signal = 0;
1111      //
1112      signal = this->SetUpperLimits();
1113    //    //
1114    stringstream   oss;    stringstream   oss;
1115    //      //  
# Line 1087  Int_t PamelaDBOperations::insertPamelaGL Line 1162  Int_t PamelaDBOperations::insertPamelaGL
1162    };    };
1163    //    //
1164    TTree *T = 0;    TTree *T = 0;
   Int_t signal = 0;  
1165    //    //
1166    UInt_t nevent = 0;    UInt_t nevent = 0;
1167    UInt_t recEntries = 0;    UInt_t recEntries = 0;
# Line 1496  Int_t PamelaDBOperations::insertPamelaRU Line 1570  Int_t PamelaDBOperations::insertPamelaRU
1570    stringstream oss;    stringstream oss;
1571    oss.str("");    oss.str("");
1572    //    //
1573    signal = this->SetUpperLimits();    //  signal = this->SetUpperLimits();
1574    //    //
1575    // loop on runheader and runtrailer events    // loop on runheader and runtrailer events
1576    //    //
# Line 1514  Int_t PamelaDBOperations::insertPamelaRU Line 1588  Int_t PamelaDBOperations::insertPamelaRU
1588    rt->SetBranchAddress("RunTrailer", &runt);    rt->SetBranchAddress("RunTrailer", &runt);
1589    rt->SetBranchAddress("Header", &eht);    rt->SetBranchAddress("Header", &eht);
1590    //    //
1591      TTree *T = (TTree*)file->Get("Physics");
1592      if ( !T || T->IsZombie() ) throw -16;
1593      EventHeader *eh = 0;
1594      T->SetBranchAddress("Header", &eh);
1595      //
1596      if ( !(rh->GetEntries()) && !(rt->GetEntries()) && !(T->GetEntries()) ) return(16);
1597      //
1598    UInt_t obtt = 0;    UInt_t obtt = 0;
1599    UInt_t obth = 0;    UInt_t obth = 0;
1600    UInt_t pktt = 0;    UInt_t pktt = 0;
# Line 1547  Int_t PamelaDBOperations::insertPamelaRU Line 1628  Int_t PamelaDBOperations::insertPamelaRU
1628        //        //
1629        if ( !ptt &&  !(ptht+1) ){        if ( !ptt &&  !(ptht+1) ){
1630          //          //
1631          if ( IsDebug() ) printf(" Piece of run at the beginning of the file %i %i %i \n",ptht,pth,ptt);          if ( IsDebug() ) printf(" Piece of run at the beginning of the file %u %u %u \n",ptht,pth,ptt);
1632          //          //
1633          this->HandleRunFragments(true,false,0,(evbeft-1));          this->HandleRunFragments(true,false,0,(evbeft-1));
1634          //          //
1635          //          //
1636        } else if ( pth == ptht ){        } else if ( pth == ptht ){
1637          //          //
1638          if ( IsDebug() ) printf(" Missing header %i %i %i\n",ptht,pth,ptt);          if ( IsDebug() ) printf(" Missing header %u %u %u\n",ptht,pth,ptt);
1639          //          //
1640          if ( (ptt-1) < 0 ) throw -15; // should never arrive here!          if ( (ptt-1) < 0 ) throw -15; // should never arrive here!
1641          rt->GetEntry(ptt-1);          rt->GetEntry(ptt-1);
# Line 1563  Int_t PamelaDBOperations::insertPamelaRU Line 1644  Int_t PamelaDBOperations::insertPamelaRU
1644          rt->GetEntry(ptt);          rt->GetEntry(ptt);
1645          pht = eht->GetPscuHeader();          pht = eht->GetPscuHeader();
1646          //          //
1647          if ( IsDebug() ) printf(" Try to find the beginning of a run which has only the runtrailer   %i %i %i \n",ptht,pth,ptt);          if ( IsDebug() ) printf(" Try to find the beginning of a run which has only the runtrailer   %u %u %u \n",ptht,pth,ptt);
1648          if ( IsDebug() ) printf(" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  %i %i %i \n",pkth,obth,obtt);          if ( IsDebug() ) printf(" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  %u %u %u \n",pkth,obth,obtt);
1649          //          //
1650          this->HandleMissingHoT(true,false,evbefh,evbeft-1);          this->HandleMissingHoT(true,false,evbefh,evbeft-1);
1651          //          //
1652        } else {        } else {
1653          //          //
1654          if ( IsDebug() ) printf(" Could be a good run, we have a runheader followed by a runtrailer %i %i %i\n",ptht,pth,ptt);          if ( IsDebug() ) printf(" Could be a good run, we have a runheader followed by a runtrailer %u %u %u\n",ptht,pth,ptt);
1655          //          //
1656          rh->GetEntry(ptht);          rh->GetEntry(ptht);
1657          phh = ehh->GetPscuHeader();          phh = ehh->GetPscuHeader();
# Line 1578  Int_t PamelaDBOperations::insertPamelaRU Line 1659  Int_t PamelaDBOperations::insertPamelaRU
1659          obth = phh->GetOrbitalTime();          obth = phh->GetOrbitalTime();
1660          cod = ehh->GetCounter();          cod = ehh->GetCounter();
1661          evbefh = cod->Get(pctp->Physics);          evbefh = cod->Get(pctp->Physics);
1662          if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt);          if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt);
1663          //          //
1664          // handle this run          // handle this run
1665          //          //
# Line 1588  Int_t PamelaDBOperations::insertPamelaRU Line 1669  Int_t PamelaDBOperations::insertPamelaRU
1669          //          //
1670          if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){          if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){
1671            //            //
1672            if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER \n");            if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER evbefh = %u \n",evbefh);        
           //  
           this->HandleRunFragments(true,true,0,(evbefh-1));  
1673            //            //
1674              if ( evbefh == 0 ) {
1675                //
1676                signal = 8;
1677                if ( IsDebug() ) printf(" Not supported yet: run with no events, no runtrailer, no runheader \n");
1678                //
1679              } else {
1680                //
1681                this->HandleRunFragments(true,true,0,(evbefh-1));
1682                //
1683              };
1684          };          };
1685          //          //
1686          //          //
1687          if ( (ptht - pth) > 1 ){          if ( (ptht - pth) > 1 ){
1688            //            //
1689            if ( IsDebug() ) printf(" Missing runtrailers! \n");            if ( IsDebug() ) printf(" Missing runtrailers! \n");
1690            if ( IsDebug() ) printf(" Attention there is a jump in the runheader counter %i %i %i \n",ptht,pth,ptt);            if ( IsDebug() ) printf(" Attention there is a jump in the runheader counter %u %u %u \n",ptht,pth,ptt);
1691            // is not the consecutive header            // is not the consecutive header
1692            while ( pth != ptht ){                      while ( pth != ptht ){          
1693              //              //
# Line 1619  Int_t PamelaDBOperations::insertPamelaRU Line 1708  Int_t PamelaDBOperations::insertPamelaRU
1708              obth = phh->GetOrbitalTime();              obth = phh->GetOrbitalTime();
1709              evbefh = cod->Get(pctp->Physics);              evbefh = cod->Get(pctp->Physics);
1710              //              //
1711              if ( IsDebug() ) printf(" Try to find the end of a run which has only the runheader   %i %i %i \n",ptht,pth,ptt);              if ( IsDebug() ) printf(" Try to find the end of a run which has only the runheader   %u %u %u \n",ptht,pth,ptt);
1712              if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt);              if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt);
1713              //              //
1714              this->HandleMissingHoT(false,true,evbefh,evbeft-1);              this->HandleMissingHoT(false,true,evbefh,evbeft-1);
1715              //              //
# Line 1629  Int_t PamelaDBOperations::insertPamelaRU Line 1718  Int_t PamelaDBOperations::insertPamelaRU
1718          } else if ( !(ptht - pth) ){          } else if ( !(ptht - pth) ){
1719            //            //
1720            if ( IsDebug() ) printf(" Missing runheader! \n");            if ( IsDebug() ) printf(" Missing runheader! \n");
1721            if ( IsDebug() ) printf(" Attention! the runheader counter did not changed %i %i %i \n",ptht,pth,ptt);            if ( IsDebug() ) printf(" Attention! the runheader counter did not changed %u %u %u \n",ptht,pth,ptt);
1722            if ( IsDebug() ) printf(" The run should have already been handled by HandleRun() \n");            if ( IsDebug() ) printf(" The run should have already been handled by HandleRun() \n");
1723            //            //
1724          } else {          } else {
# Line 1650  Int_t PamelaDBOperations::insertPamelaRU Line 1739  Int_t PamelaDBOperations::insertPamelaRU
1739            obth = phh->GetOrbitalTime();            obth = phh->GetOrbitalTime();
1740            cod = ehh->GetCounter();            cod = ehh->GetCounter();
1741            evbefh = cod->Get(pctp->Physics);            evbefh = cod->Get(pctp->Physics);
1742            if ( IsDebug() ) printf(" Piece of run at the end of file %i %i %i \n",pkth,obth,obtt);            if ( IsDebug() ) printf(" Piece of run at the end of file %u %u %u \n",pkth,obth,obtt);
1743            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i %i %i \n",ptht,pth,ptt);            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u %u %u \n",ptht,pth,ptt);
1744            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i \n",rhev);            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u \n",rhev);
1745            //            //
1746            this->HandleRunFragments(false,true,evbefh,upperentry);            this->HandleRunFragments(false,true,evbefh,upperentry);
1747          } else {          } else {
# Line 1700  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1789  Bool_t PamelaDBOperations::IsRunAlreadyI
1789    //                                  ( runhead_time <= _our_runhead_time &&  runtrail_time >= _our_runtrail_time) &&    //                                  ( runhead_time <= _our_runhead_time &&  runtrail_time >= _our_runtrail_time) &&
1790    //                                  ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) &&    //                                  ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) &&
1791    //                                  ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) )    //                                  ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) )
1792      //                                  ||
1793      //                                  ( runhead_time = _our_runhead_time &&  runtrail_time = _our_runtrail_time && nevents > 100 )
1794      //                                  )
1795      //                                  ||
1796      //                                  ( runhead_time = _our_runhead_time &&  runtrail_time > _our_runtrail_time && nevents > 100 )
1797      //                                  )
1798      //                                  ||
1799      //                                  ( runhead_time < _our_runhead_time &&  runtrail_time = _our_runtrail_time && nevents > 100 )
1800    //                                  )    //                                  )
1801    //    //
1802    oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE "    oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE "
# Line 1715  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1812  Bool_t PamelaDBOperations::IsRunAlreadyI
1812        << " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR "        << " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR "
1813        << " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND ("        << " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND ("
1814        << " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR "        << " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR "
1815        << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));";        << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") OR "
1816          << " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //  these two lines in a certain way disable the patch below...
1817          << " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR"    //
1818          << " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //
1819          << " RUNTRAILER_TIME>" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR"    //
1820          << " (RUNHEADER_TIME<" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //
1821          << " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100)"    //
1822          << " ));";
1823    //    //
1824    if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str());
1825    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
# Line 1737  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1841  Bool_t PamelaDBOperations::IsRunAlreadyI
1841      //      //
1842      // the run has already been inserted      // the run has already been inserted
1843      //      //
1844      //    return(true);  //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here      if ( signal && IsDebug() ) printf(" The run has already been inserted \n");    
1845        return(true);  //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here
1846      //      //
1847      // PATCH!      // PATCH!
1848      // we keep the processing run if (in order of growing importance) 1) we have the runtrailer while the old run doesn't have it 2) we have the runheader      // we keep the processing run if (in order of growing importance) 1) we have the runtrailer while the old run doesn't have it 2) we have the runheader
# Line 2052  void PamelaDBOperations::HandleRunFragme Line 2157  void PamelaDBOperations::HandleRunFragme
2157        ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT());        ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT());
2158        UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT());        UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT());
2159        ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT());        ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT());
2160        if ( IsDebug() ) printf(" Check overlapping events: %i %i %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev);        if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev);
2161        TTree *T= 0;        TTree *T= 0;
2162        T = (TTree*)file->Get("Physics");        T = (TTree*)file->Get("Physics");
2163        if ( !T || T->IsZombie() ) throw -16;        if ( !T || T->IsZombie() ) throw -16;
# Line 2066  void PamelaDBOperations::HandleRunFragme Line 2171  void PamelaDBOperations::HandleRunFragme
2171          bobt = OBT(ph->GetOrbitalTime());                bobt = OBT(ph->GetOrbitalTime());      
2172          firstev++;          firstev++;
2173        };        };
2174        if ( IsDebug() ) printf(" Check overlapping events done: %i %i %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev);        if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev);
2175        //        //
2176        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());
2177        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());
# Line 2249  void PamelaDBOperations::HandleRunFragme Line 2354  void PamelaDBOperations::HandleRunFragme
2354        ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT());        ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT());
2355        UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT());        UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT());
2356        ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT());        ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT());
2357        if ( IsDebug() ) printf(" Check overlapping events: %i %i %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev);        if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev);
2358        TTree *T= 0;        TTree *T= 0;
2359        T = (TTree*)file->Get("Physics");        T = (TTree*)file->Get("Physics");
2360        if ( !T || T->IsZombie() ) throw -16;        if ( !T || T->IsZombie() ) throw -16;
# Line 2263  void PamelaDBOperations::HandleRunFragme Line 2368  void PamelaDBOperations::HandleRunFragme
2368          aobt = OBT(ph->GetOrbitalTime());                aobt = OBT(ph->GetOrbitalTime());      
2369          lastev--;          lastev--;
2370        };        };
2371        if ( IsDebug() ) printf(" Check overlapping events done: %i %i %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev);        if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev);
2372        //        //
2373        glrun->SetEV_TO(lastev);        glrun->SetEV_TO(lastev);
2374        glrun->SetNEVENTS(lastev-firstev+1);        glrun->SetNEVENTS(lastev-firstev+1);
# Line 2870  Int_t PamelaDBOperations::insertCALO_CAL Line 2975  Int_t PamelaDBOperations::insertCALO_CAL
2975          fromtime = this->GetAbsTime(ph->GetOrbitalTime());            fromtime = this->GetAbsTime(ph->GetOrbitalTime());  
2976          if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){          if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){
2977            //            //
2978            if ( IsDebug() ) printf(" Calo calibration for section %i at time %i obt %i pkt %i \n",section,fromtime,obt,pkt);            if ( IsDebug() ) printf(" Calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt);
2979            //            //
2980            // check if the calibration has already been inserted            // check if the calibration has already been inserted
2981            //            //
# Line 2915  Int_t PamelaDBOperations::insertCALO_CAL Line 3020  Int_t PamelaDBOperations::insertCALO_CAL
3020                //                //
3021                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);
3022                if ( fromtime < 1150871000 ){ //1150866904                if ( fromtime < 1150871000 ){ //1150866904
3023                  if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);                  if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime);
3024                  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
3025                };                };
3026                //                //
# Line 2977  Int_t PamelaDBOperations::insertCALO_CAL Line 3082  Int_t PamelaDBOperations::insertCALO_CAL
3082            //            //
3083          } else {          } else {
3084            //            //
3085            if ( IsDebug() ) printf(" Repeated calo calibration for section %i at time %i obt %i pkt %i \n",section,fromtime,obt,pkt);            if ( IsDebug() ) printf(" Repeated calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt);
3086            //            //
3087          };                };      
3088          //                //      
# Line 3195  Int_t PamelaDBOperations::insertTRK_CALI Line 3300  Int_t PamelaDBOperations::insertTRK_CALI
3300      //      //
3301      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) ){
3302        //        //
3303        if ( IsDebug() ) printf(" Trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1);        if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1);
3304        //              //      
3305        valid = ValidateTrkCalib( caltrk1, eh1 );        valid = ValidateTrkCalib( caltrk1, eh1 );
3306        if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl;        if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl;
# Line 3238  Int_t PamelaDBOperations::insertTRK_CALI Line 3343  Int_t PamelaDBOperations::insertTRK_CALI
3343          //          //
3344        };        };
3345        //        //
3346        if ( IsDebug() ) printf(" Found trk calibration2 at obt %i pkt %i t2 is %i \n",obt2,pkt2,t2);        if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2);
3347        //        //
3348        // The calibration is good        // The calibration is good
3349        //        //
3350        if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){        if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){
3351          //          //
3352          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 %u pkt %u t2 is %u is good \n",obt2,pkt2,t2);
3353          //          //
3354          UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 );          UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 );
3355          if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl;          if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl;
# Line 3258  Int_t PamelaDBOperations::insertTRK_CALI Line 3363  Int_t PamelaDBOperations::insertTRK_CALI
3363          //          //
3364          if ( t2 != pret2+1 ){          if ( t2 != pret2+1 ){
3365            //            //
3366            if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %i pkt %i t2 is %i pret2 is %i \n",obt2,pkt2,t2,pret2);            if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u pret2 is %u \n",obt2,pkt2,t2,pret2);
3367            //            //
3368            while ( t2 > pret2+1 ){            while ( t2 > pret2+1 ){
3369              //              //
# Line 3287  Int_t PamelaDBOperations::insertTRK_CALI Line 3392  Int_t PamelaDBOperations::insertTRK_CALI
3392          //          //
3393          // Check for missing calibtrk2          // Check for missing calibtrk2
3394          //          //
3395          if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %i pkt %i t2 is %i\n",obt2,pkt2,t2);          if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2);
3396          t2 = pret2;          t2 = pret2;
3397          //          //
3398          // handle missing calib2          // handle missing calib2
# Line 3301  Int_t PamelaDBOperations::insertTRK_CALI Line 3406  Int_t PamelaDBOperations::insertTRK_CALI
3406        //        //
3407      } else {      } else {
3408        //        //
3409        if ( IsDebug() ) printf(" Repetead trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1);        if ( IsDebug() ) printf(" Repetead trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1);
3410        //        //
3411      };      };
3412      //          //    
# Line 3326  Int_t PamelaDBOperations::insertTRK_CALI Line 3431  Int_t PamelaDBOperations::insertTRK_CALI
3431      valid = 0;      valid = 0;
3432      if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){      if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){
3433        //        //
3434        if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %i pkt %i t2 is %i\n",obt2,pkt2,t2);        if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2);
3435        //        //
3436        this->HandleTRK_CALIB(false,true);        this->HandleTRK_CALIB(false,true);
3437        //        //
# Line 3380  Int_t PamelaDBOperations::insertS4_CALIB Line 3485  Int_t PamelaDBOperations::insertS4_CALIB
3485      fromtime = this->GetAbsTime(ph->GetOrbitalTime());        fromtime = this->GetAbsTime(ph->GetOrbitalTime());  
3486      if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){      if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){
3487        //        //
3488        if ( IsDebug() ) printf(" S4 calibration at time %i obt %i pkt %i \n",fromtime,obt,pkt);        if ( IsDebug() ) printf(" S4 calibration at time %u obt %u pkt %u \n",fromtime,obt,pkt);
3489        //        //
3490        // check if the calibration has already been inserted        // check if the calibration has already been inserted
3491        //        //
# Line 3423  Int_t PamelaDBOperations::insertS4_CALIB Line 3528  Int_t PamelaDBOperations::insertS4_CALIB
3528            //            //
3529            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");
3530            if ( fromtime < 1150871000 ){              if ( fromtime < 1150871000 ){  
3531              if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);              if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime);
3532              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
3533            };            };
3534            //            //
# Line 3482  Int_t PamelaDBOperations::insertS4_CALIB Line 3587  Int_t PamelaDBOperations::insertS4_CALIB
3587        //        //
3588      } else {      } else {
3589        //        //
3590        if ( IsDebug() ) printf(" Repetead S4 calibration at time %i obt %i pkt %i \n",fromtime,obt,pkt);        if ( IsDebug() ) printf(" Repeated S4 calibration at time %u obt %u pkt %u \n",fromtime,obt,pkt);
3591        //        //
3592      };            };      
3593      //            //      
# Line 3693  Int_t PamelaDBOperations::ValidateRuns(T Line 3798  Int_t PamelaDBOperations::ValidateRuns(T
3798        row = result->Next();        row = result->Next();
3799        t_stop = (UInt_t)atoll(row->GetField(4));        t_stop = (UInt_t)atoll(row->GetField(4));
3800      };      };
3801      if ( IsDebug() ) printf("Validation interval: from time %i - to time %i \n\n",t_stop,t_start);      if ( IsDebug() ) printf("Validation interval: from time %u - to time %u \n\n",t_stop,t_start);
3802      // --------------------------------------------------------------      // --------------------------------------------------------------
3803      // now retrieves runs to be validated      // now retrieves runs to be validated
3804      // --------------------------------------------------------------      // --------------------------------------------------------------
# Line 3864  Int_t PamelaDBOperations::ValidateRuns(T Line 3969  Int_t PamelaDBOperations::ValidateRuns(T
3969                    }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);
3970            };            };
3971                        
3972            if ( IsDebug() ) printf("%i Run %i \n",nrow,this_run->ID);            if ( IsDebug() ) printf("%i Run %u \n",nrow,this_run->ID);
3973            nrow++;            nrow++;
3974                        
3975    };    };
# Line 3893  Bool_t PamelaDBOperations::MissingTRK_CA Line 3998  Bool_t PamelaDBOperations::MissingTRK_CA
3998          // which should be equal to the time between ascending-nodes.          // which should be equal to the time between ascending-nodes.
3999          //==============================================================          //==============================================================
4000          if ( t2 - trkcalib->FROM_TIME > 5700) {          if ( t2 - trkcalib->FROM_TIME > 5700) {
4001                  if ( IsDebug() )printf("Long time between calib and run start %i :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME);                  if ( IsDebug() )printf("Long time between calib and run start %u :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME);
4002          //==============================================================          //==============================================================
4003          // there might be a missing calibration, due to:          // there might be a missing calibration, due to:
4004          // - MM full          // - MM full
# Line 3914  Bool_t PamelaDBOperations::MissingTRK_CA Line 4019  Bool_t PamelaDBOperations::MissingTRK_CA
4019          // it is enough to say that there are no missing calibrations          // it is enough to say that there are no missing calibrations
4020          //==============================================================          //==============================================================
4021          // the long time interval bewteen runs might be due to download          // the long time interval bewteen runs might be due to download
4022          if ( IsDebug() )printf("Short time between calib and run start %i :-) ==> OK! \n",t2 - trkcalib->FROM_TIME);          if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME);
4023          return(false);          return(false);
4024                    
4025  };  };
# Line 4230  void PamelaDBOperations::ValidationOFF() Line 4335  void PamelaDBOperations::ValidationOFF()
4335        };        };
4336      };      };
4337    };    };
4338    if ( IsDebug() ) printf(" %i runs have been unvalidated \n",unv);    if ( IsDebug() ) printf(" %u runs have been unvalidated \n",unv);
4339  };  };
4340    
4341  /**  /**
# Line 4261  void PamelaDBOperations::RemoveRUNS(){ Line 4366  void PamelaDBOperations::RemoveRUNS(){
4366      if ( IsDebug() ) printf(" Deleting run from GL_RUN table \n");          if ( IsDebug() ) printf(" Deleting run from GL_RUN table \n");    
4367      while ( Row ){      while ( Row ){
4368        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");
4369        if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0)));        if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0)));
4370        drun++;        drun++;
4371        Row = pResult->Next();            Row = pResult->Next();    
4372      };      };
# Line 4282  void PamelaDBOperations::RemoveRUNS(){ Line 4387  void PamelaDBOperations::RemoveRUNS(){
4387    } else {    } else {
4388      if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN table \n");          if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN table \n");    
4389      while ( Row ){      while ( Row ){
4390        if ( IsDebug() ) printf(" restore run %i \n",(UInt_t)atoll(Row->GetField(1)));        if ( IsDebug() ) printf(" restore run %u \n",(UInt_t)atoll(Row->GetField(1)));
4391        delrun->RestoreRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN_FRAGMENTS");        delrun->RestoreRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN_FRAGMENTS");
4392        if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(1)));        if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(1)));
4393        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN");        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN");
4394        if ( (UInt_t)atoll(Row->GetField(1)) != (UInt_t)atoll(Row->GetField(0)) ){        if ( (UInt_t)atoll(Row->GetField(1)) != (UInt_t)atoll(Row->GetField(0)) ){
4395          if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0)));          if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0)));
4396          delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");          delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");
4397        };        };
4398        drun++;        drun++;
# Line 4313  void PamelaDBOperations::RemoveRUNS(){ Line 4418  void PamelaDBOperations::RemoveRUNS(){
4418    } else {    } else {
4419      if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_TRASH table \n");          if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_TRASH table \n");    
4420      while ( Row ){      while ( Row ){
4421        if ( IsDebug() ) printf(" del run idtrash %i \n",(UInt_t)atoll(Row->GetField(0)));        if ( IsDebug() ) printf(" del run idtrash %u \n",(UInt_t)atoll(Row->GetField(0)));
4422        myquery.str("");        myquery.str("");
4423        myquery << " DELETE FROM GL_RUN_TRASH where ID_TRASH=" << Row->GetField(0) <<";";              myquery << " DELETE FROM GL_RUN_TRASH where ID_TRASH=" << Row->GetField(0) <<";";      
4424        conn->Query(myquery.str().c_str());        conn->Query(myquery.str().c_str());
# Line 4322  void PamelaDBOperations::RemoveRUNS(){ Line 4427  void PamelaDBOperations::RemoveRUNS(){
4427      };      };
4428    };    };
4429    //      //  
4430    if ( IsDebug() ) printf(" Deleted %i run(s) from GL_RUN_TRASH table \n",drun);        if ( IsDebug() ) printf(" Deleted %u run(s) from GL_RUN_TRASH table \n",drun);    
4431    //    //
4432    //    //
4433    //    //
# Line 4340  void PamelaDBOperations::RemoveRUNS(){ Line 4445  void PamelaDBOperations::RemoveRUNS(){
4445    } else {    } else {
4446      if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_FRAGMENTS table \n");          if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_FRAGMENTS table \n");    
4447      while ( Row ){      while ( Row ){
4448        if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0)));        if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0)));
4449        myquery.str("");        myquery.str("");
4450        myquery << " DELETE FROM GL_RUN_FRAGMENTS where ID=" << Row->GetField(0) <<";";        myquery << " DELETE FROM GL_RUN_FRAGMENTS where ID=" << Row->GetField(0) <<";";
4451        conn->Query(myquery.str().c_str());        conn->Query(myquery.str().c_str());
# Line 4349  void PamelaDBOperations::RemoveRUNS(){ Line 4454  void PamelaDBOperations::RemoveRUNS(){
4454      };      };
4455    };    };
4456    //      //  
4457    if ( IsDebug() ) printf(" Deleted %i run(s) from GL_RUN_FRAGMENTS table \n",drun);        if ( IsDebug() ) printf(" Deleted %u run(s) from GL_RUN_FRAGMENTS table \n",drun);    
4458    //    //
4459    //    //
4460    //    //
# Line 4661  UInt_t PamelaDBOperations::Check(){ Line 4766  UInt_t PamelaDBOperations::Check(){
4766    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
4767    TSQLResult *result2 = 0;    TSQLResult *result2 = 0;
4768    TSQLRow    *row2    = 0;    TSQLRow    *row2    = 0;
4769      TSQLResult *result3 = 0;
4770      TSQLRow    *row3    = 0;
4771    oss.str("");    oss.str("");
4772    oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN order by RUNHEADER_TIME asc;";    oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME,NEVENTS FROM GL_RUN order by RUNHEADER_TIME asc;";
4773    //  oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;";    //  oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;";
4774    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
4775    //    //
4776    if ( !result ) throw -4;;    if ( !result ) throw -4;;
4777    //    //
4778    row = result->Next();    row = result->Next();
4779      UInt_t nid = 0;
4780    //    //
4781    while ( row ){    while ( row ){
4782        nid++;
4783        if ( !(nid%1000) && nid ) printf(" %iK run scanned \n",nid/1000);
4784      thisid = (UInt_t)atoll(row->GetField(0));      thisid = (UInt_t)atoll(row->GetField(0));
4785      thisl0id = (UInt_t)atoll(row->GetField(1));      thisl0id = (UInt_t)atoll(row->GetField(1));
4786      thisrht = (UInt_t)atoll(row->GetField(2));      thisrht = (UInt_t)atoll(row->GetField(2));
4787      thisrtt = (UInt_t)atoll(row->GetField(3));      thisrtt = (UInt_t)atoll(row->GetField(3));
4788      //      //
4789        if ( (UInt_t)atoll(row->GetField(4)) > 1 ){
4790          //
4791          //
4792          //
4793          oss.str("");
4794          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4795              << thisid << " AND ( RUNHEADER_TIME="
4796              << thisrht << " OR RUNTRAILER_TIME="
4797              << thisrtt << " ) AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
4798          result3 = conn->Query(oss.str().c_str());
4799          if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
4800          if ( result3 ){
4801            //
4802            oss.str("");
4803            oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4804                << thisid << " AND RUNHEADER_TIME="
4805                << thisrht << " AND RUNTRAILER_TIME!="
4806                << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
4807            result3 = conn->Query(oss.str().c_str());
4808            if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
4809            if ( result3 ){
4810              row3 = result3->Next();
4811              //
4812              while ( row3 ){
4813                //
4814                // 2 runs with same runheader
4815                //
4816                printf(" CHECK n.4 RUNs %u and %u HAVE SAME RUNHEADER \n",thisid,(UInt_t)atoll(row3->GetField(0)));  
4817                row3 = result3->Next();
4818              };
4819            };
4820            //
4821            oss.str("");
4822            oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4823                << thisid << " AND RUNHEADER_TIME!="
4824                << thisrht << " AND RUNTRAILER_TIME="
4825                << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
4826            result3 = conn->Query(oss.str().c_str());
4827            if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
4828            if ( result3 ){
4829              row3 = result3->Next();
4830              //
4831              while ( row3 ){
4832                //
4833                // 2 runs with same runtrailer
4834                //
4835                printf(" CHECK n.5 RUNs %u and %u HAVE SAME RUNTRAILER \n",thisid,(UInt_t)atoll(row3->GetField(0)));
4836                row3 = result3->Next();
4837              };
4838            };
4839            //
4840            oss.str("");
4841            oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4842                << thisid << " AND RUNHEADER_TIME="
4843                << thisrht << " AND RUNTRAILER_TIME="
4844                << thisrtt << " AND ID_RUN_FRAG!="
4845                << thisid << " order by RUNHEADER_TIME asc;";
4846            result3 = conn->Query(oss.str().c_str());
4847            if ( result3 ){
4848              row3 = result3->Next();
4849              //
4850              while ( row3 ){
4851                //
4852                // duplicated run
4853                //
4854                printf(" CHECK n.7 RUNs %u and %u HAVE SAME RUNTRAILER AND RUNHEADER (ARE THE SAME?) \n",thisid,(UInt_t)atoll(row3->GetField(0)));
4855                row3 = result3->Next();
4856              };
4857            };
4858          };
4859          //
4860          oss.str("");
4861          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4862              << thisid << " AND RUNHEADER_TIME>"
4863              << thisrht << " AND RUNTRAILER_TIME<"
4864              << thisrtt << " order by RUNHEADER_TIME asc;";
4865          result3 = conn->Query(oss.str().c_str());
4866          if ( result3 ){
4867            row3 = result3->Next();
4868            //
4869            while ( row3 ){
4870              //
4871              // run contained in the checked one
4872              //
4873              printf(" CHECK n.6 RUN %u CONTAINS RUN %u  \n",thisid,(UInt_t)atoll(row3->GetField(0)));
4874              row3 = result3->Next();
4875            };
4876          };
4877          //
4878        };
4879        //
4880      //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){      //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){
4881      //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){      //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){
4882      if ( (thisrht < prevrtt) && (thisrht != prevrht) ){      if ( (thisrht < prevrtt) && (thisrht != prevrht) ){
# Line 4707  UInt_t PamelaDBOperations::Check(){ Line 4908  UInt_t PamelaDBOperations::Check(){
4908        oss.str("");        oss.str("");
4909        oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";        oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";
4910        result2 = conn->Query(oss.str().c_str());        result2 = conn->Query(oss.str().c_str());
4911        if ( !result2 ) throw -4;;        if ( !result2 ) throw -4;
4912        row2 = result2->Next();        row2 = result2->Next();
4913        prevf = (TString)row2->GetField(0);        prevf = (TString)row2->GetField(0);
4914        oss.str("");        oss.str("");

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.50

  ViewVC Help
Powered by ViewVC 1.1.23