/[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.12 by mocchiut, Tue Oct 17 15:20:04 2006 UTC revision 1.15 by mocchiut, Tue Oct 24 14:24:23 2006 UTC
# Line 31  Line 31 
31  #include <varDump/VarDumpRecord.h>  #include <varDump/VarDumpRecord.h>
32  #include <physics/S4/S4Event.h>  #include <physics/S4/S4Event.h>
33  //  //
34  #include <cTle.h>  #include <sgp4.h>
 #include <cEci.h>  
 #include <cJulian.h>  
35    
36  #include <PamelaDBOperations.h>  #include <PamelaDBOperations.h>
37  //  //
# Line 81  PamelaDBOperations::PamelaDBOperations(T Line 79  PamelaDBOperations::PamelaDBOperations(T
79    INSERT_ROOT = !filerootname.IsNull();    INSERT_ROOT = !filerootname.IsNull();
80    if( INSERT_ROOT ){    if( INSERT_ROOT ){
81      this->SetRootName(filerootname);      this->SetRootName(filerootname);
82        this->SetOrbitNo();
83      file = TFile::Open(this->GetRootName().Data());      file = TFile::Open(this->GetRootName().Data());
84    };    };
85    //    //
# Line 126  void PamelaDBOperations::CheckValidate(L Line 125  void PamelaDBOperations::CheckValidate(L
125   * @param password     password for the SQL connection.   * @param password     password for the SQL connection.
126   */   */
127  void PamelaDBOperations::SetConnection(TString host, TString user, TString password){  void PamelaDBOperations::SetConnection(TString host, TString user, TString password){
128      if ( IsDebug() ) printf(" Connecting using host = %s user = %s password = %s \n",host.Data(),user.Data(),password.Data());
129    conn = TSQLServer::Connect(host.Data(),user.Data(),password.Data());    conn = TSQLServer::Connect(host.Data(),user.Data(),password.Data());
130  };  };
131    
# Line 194  void PamelaDBOperations::SetRootName(TSt Line 194  void PamelaDBOperations::SetRootName(TSt
194  };  };
195    
196  /**  /**
197     * Store the downlink orbit number from filename.
198     */
199    void PamelaDBOperations::SetOrbitNo(){
200      dworbit = 0;
201      TString name = this->GetRootFile();
202      Int_t nlength = name.Length();
203      if ( nlength < 5 ) return;
204      TString dwo = 0;
205      for (Int_t i = 0; i<5; i++){
206        dwo.Append(name[i],1);
207      };
208      if ( dwo.IsDigit() ){
209        dworbit = (UInt_t)dwo.Atoi();
210      } else {
211        dwo="";
212        for (Int_t i = 8; i<13; i++){
213          dwo.Append(name[i],1);
214        };    
215        if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi();
216      };
217      if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data());
218      return;
219    };
220    
221    
222    
223    /**
224   * Store the NOBOOT flag.   * Store the NOBOOT flag.
225   * @param noboot    true/false.   * @param noboot    true/false.
226   */   */
# Line 265  Int_t PamelaDBOperations::SetUpperLimits Line 292  Int_t PamelaDBOperations::SetUpperLimits
292    UInt_t jump = 50000; // was 5000    UInt_t jump = 50000; // was 5000
293    EventCounter *code=0;    EventCounter *code=0;
294    //    //
295      UInt_t deltapkt = 5000;
296      ULong64_t deltaobt = 50000;
297      //
298    //   pcksList packetsNames;    //   pcksList packetsNames;
299    //   pcksList::iterator Iter;    //   pcksList::iterator Iter;
300    //   getPacketsNames(packetsNames);    //   getPacketsNames(packetsNames);
# Line 311  Int_t PamelaDBOperations::SetUpperLimits Line 341  Int_t PamelaDBOperations::SetUpperLimits
341    //    //
342    if ( nevent < 2 ) return(4);    if ( nevent < 2 ) return(4);
343    //    //
344    if ( PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst) ){    if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) ){
345        //
346      // go back      // go back
347      zomp = nevent - 2;      zomp = nevent - 2;
348      //      //
# Line 593  Int_t PamelaDBOperations::SetUpperLimits Line 624  Int_t PamelaDBOperations::SetUpperLimits
624    return(0);    return(0);
625  }  }
626    
627    /**
628     *
629     * Trick to have unique RUN ID numbers even when runs are deleted and mysql deamon restarted.
630     * Entries in the _RUNID_GEN table are never deleted.
631     *
632     **/
633    UInt_t PamelaDBOperations::AssignRunID(){
634      //
635      TSQLResult *result = 0;
636      TSQLRow *row = 0;
637      UInt_t runid = 0;
638      //
639      stringstream   oss;
640      //  
641      oss.str("");
642      oss << "INSERT INTO _RUNID_GEN VALUES (NULL);";
643      result = conn->Query(oss.str().c_str());
644      if ( !result ) throw -10;
645      oss.str("");
646      oss << "SELECT ID FROM _RUNID_GEN ORDER BY ID DESC LIMIT 1;";
647      result = conn->Query(oss.str().c_str());
648      if ( !result ) throw -10;
649      //
650      row = result->Next();
651      //
652      if ( !row ) throw -28;
653      //
654      runid = (UInt_t)atoll(row->GetField(0));
655      //
656      return(runid);
657    };
658    
659  //  //
660  // GETTERS  // GETTERS
661  //  //
# Line 690  void PamelaDBOperations::CheckConnection Line 753  void PamelaDBOperations::CheckConnection
753    if( !conn ) throw -1;    if( !conn ) throw -1;
754    bool connect = conn->IsConnected();    bool connect = conn->IsConnected();
755    if( !connect ) throw -1;    if( !connect ) throw -1;
756      if ( !dworbit ) throw -27;
757  };  };
758    
759  /**  /**
# Line 869  Int_t PamelaDBOperations::insertPamelaGL Line 933  Int_t PamelaDBOperations::insertPamelaGL
933    if ( this->GetID_RAW() == 0 )  throw -11;    if ( this->GetID_RAW() == 0 )  throw -11;
934    //    //
935    oss.str("");    oss.str("");
936    oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= "    oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='"
937        << id << " AND TO_ID_RAW >= "        << this->GetRawFile().Data() << "';";
       << id << ";";  
938    if ( IsDebug() ) printf(" %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
939    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
940    if ( !result ) throw -10;    if ( !result ) throw -10;
941    row = result->Next();    row = result->Next();
942    if ( !row ) throw -10;    //
943      if ( !row ){
944        oss.str("");
945        oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "
946            << dworbit << " order by FROM_ORBIT desc limit 1;";
947        if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
948        result = conn->Query(oss.str().c_str());
949        if ( !result ) throw -10;
950        row = result->Next();
951        if ( !row ) throw -10;
952      };
953    //    //
954    t0 = (UInt_t)TDatime(row->GetField(0)).Convert();    t0 = (UInt_t)TDatime(row->GetField(0)).Convert();
955    /*    /*
# Line 1483  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1556  Bool_t PamelaDBOperations::IsRunAlreadyI
1556      if ( glrun->GetNEVENTS() > (UInt_t)atoll(row->GetField(1)) ){      if ( glrun->GetNEVENTS() > (UInt_t)atoll(row->GetField(1)) ){
1557        //        //
1558        if ( IsDebug() ) printf(" The new run has more events than the old one \n");        if ( IsDebug() ) printf(" The new run has more events than the old one \n");
1559        oss.str("");        glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN");
1560        oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";";  //       oss.str("");
1561        if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str());        //       oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";";
1562        conn->Query(oss.str().c_str());  //       if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str());      
1563    //       conn->Query(oss.str().c_str());
1564        if ( signal ) signal = false;        if ( signal ) signal = false;
1565        goto gonext;              goto gonext;      
1566        //        //
# Line 1500  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1574  Bool_t PamelaDBOperations::IsRunAlreadyI
1574        //        //
1575        if ( IsDebug() ) printf(" The new run has the same number of events and the runheader the old one miss the runheader \n");        if ( IsDebug() ) printf(" The new run has the same number of events and the runheader the old one miss the runheader \n");
1576        //        //
1577        oss.str("");        glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN");
1578        oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";";  //       oss.str("");
1579        if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str());        //       oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";";
1580        conn->Query(oss.str().c_str());  //       if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str());      
1581    //       conn->Query(oss.str().c_str());
1582        //        //
1583        if ( signal ) signal = false;        if ( signal ) signal = false;
1584        goto gonext;        goto gonext;
# Line 1517  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1592  Bool_t PamelaDBOperations::IsRunAlreadyI
1592        //        //
1593        if ( IsDebug() ) printf(" The new run has the same number of events, the runheader and the runtrailer the old one miss the runtrailer \n");        if ( IsDebug() ) printf(" The new run has the same number of events, the runheader and the runtrailer the old one miss the runtrailer \n");
1594        //        //
1595        oss.str("");        glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN");
1596        oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";";  //       oss.str("");
1597        if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str());        //       oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";";
1598        conn->Query(oss.str().c_str());  //       if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str());      
1599    //       conn->Query(oss.str().c_str());
1600        if ( signal ) signal = false;        if ( signal ) signal = false;
1601        //        //
1602      };      };
# Line 1556  void PamelaDBOperations::HandleRun(){   Line 1632  void PamelaDBOperations::HandleRun(){  
1632      //      //
1633      this->FillClass();      this->FillClass();
1634      //      //
1635      if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);      if ( !IsRunAlreadyInserted() ){
1636          glrun->SetID(this->AssignRunID());
1637          glrun->SetID_RUN_FRAG(0);
1638          glrun->Fill_GL_RUN(conn);
1639        };
1640    } else {    } else {
1641      //      //
1642      if ( IsDebug() ) printf(" oh no! the distance between runheader and runtrailer seems wrong: check %llu pktt %llu \n",chkpkt,pktt);      if ( IsDebug() ) printf(" oh no! the distance between runheader and runtrailer seems wrong: check %llu pktt %llu \n",chkpkt,pktt);
# Line 1728  void PamelaDBOperations::HandleRunFragme Line 1808  void PamelaDBOperations::HandleRunFragme
1808        };        };
1809        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: %i %i %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev);
1810        //        //
       glrun1->SetID(0);  
1811        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());
1812        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());
1813        glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME());        glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME());
# Line 1756  void PamelaDBOperations::HandleRunFragme Line 1835  void PamelaDBOperations::HandleRunFragme
1835        //        //
1836        if ( !IsRunAlreadyInserted() ){        if ( !IsRunAlreadyInserted() ){
1837          //          //
1838            glrun->SetID(this->AssignRunID());
1839            glrun->SetID_RUN_FRAG(glrun1->GetID());
1840          glrun->Fill_GL_RUN(conn);          glrun->Fill_GL_RUN(conn);
1841          //          //
1842          // get id number          // get id number
1843          //          //
1844          oss.str("");  //      oss.str("");
1845          oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "  //      oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "
1846              << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "  //          << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "
1847              << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";  //          << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";
1848          //  //      //
1849          if ( IsDebug() ) printf(" search for idrun0 , query is : \n%s\n",oss.str().c_str());  //      if ( IsDebug() ) printf(" search for idrun0 , query is : \n%s\n",oss.str().c_str());
1850          //  //      //
1851          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
1852          if ( !result ) throw -4;  //      if ( !result ) throw -4;
1853          row = result->Next();  //      row = result->Next();
1854          //  //      //
1855          UInt_t idrun0 = 0;  //      UInt_t idrun0 = 0;
1856          if ( !row ){  //      if ( !row ){
1857            throw -10;  //        throw -10;
1858          } else {  //      } else {
1859            idrun0 = (UInt_t)atoll(row->GetField(0));  //        idrun0 = (UInt_t)atoll(row->GetField(0));
1860          };  //      };
         //  
         glrun1->SetID_RUN_FRAG(idrun0);  
1861          //          //
1862            //      glrun1->SetID_RUN_FRAG(idrun0);
1863            glrun1->SetID_RUN_FRAG(glrun->GetID());
1864          glrun1->Fill_GL_RUN(conn);          glrun1->Fill_GL_RUN(conn);
1865          //          //
1866          oss.str("");  //      oss.str("");
1867          oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";  //      oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";
1868          //  //      //
1869          if ( IsDebug() ) printf(" search for idrun1 , query is : \n%s\n",oss.str().c_str());  //      if ( IsDebug() ) printf(" search for idrun1 , query is : \n%s\n",oss.str().c_str());
1870          //  //      //
1871          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
1872          if ( !result ) throw -4;  //      if ( !result ) throw -4;
1873          row = result->Next();  //      row = result->Next();
1874          //  //      //
1875          UInt_t idrun1 = 0;  //      UInt_t idrun1 = 0;
1876          if ( !row ){  //      if ( !row ){
1877            throw -10;  //        throw -10;
1878          } else {  //      } else {
1879            idrun1 = (UInt_t)atoll(row->GetField(0));  //        idrun1 = (UInt_t)atoll(row->GetField(0));
1880          };  //      };
1881          //  //      //
1882          oss.str("");  //      oss.str("");
1883          oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";  //      oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";
1884          //  //      //
1885          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
1886          if ( !result ) throw -4;  //      if ( !result ) throw -4;
1887          //          //
1888        };        };
1889        //        //
# Line 1810  void PamelaDBOperations::HandleRunFragme Line 1891  void PamelaDBOperations::HandleRunFragme
1891        //        //
1892        // delete old entry in fragment table        // delete old entry in fragment table
1893        //        //
1894        oss.str("");        glrun->DeleteRun(conn,idfrag,"GL_RUN_FRAGMENTS");
1895        //  //       oss.str("");
1896        oss << " DELETE FROM GL_RUN_FRAGMENTS WHERE ID = " << idfrag << ";";  //       //
1897        //  //       oss << " DELETE FROM GL_RUN_FRAGMENTS WHERE ID = " << idfrag << ";";
1898        if ( IsDebug() ) printf(" Delete from frag table the old run :\n query is \n %s \n",oss.str().c_str());  //       //
1899        result =  conn->Query(oss.str().c_str());  //       if ( IsDebug() ) printf(" Delete from frag table the old run :\n query is \n %s \n",oss.str().c_str());
1900        if ( !result ) throw -4;  //       result =  conn->Query(oss.str().c_str());
1901    //       if ( !result ) throw -4;
1902        //        //
1903        return;        return;
1904        //        //
# Line 1952  void PamelaDBOperations::HandleRunFragme Line 2034  void PamelaDBOperations::HandleRunFragme
2034        glrun->SetRUNTRAILER_OBT(glrun1->GetRUNTRAILER_OBT());        glrun->SetRUNTRAILER_OBT(glrun1->GetRUNTRAILER_OBT());
2035        glrun->SetRUNTRAILER_PKT(glrun1->GetRUNTRAILER_PKT());        glrun->SetRUNTRAILER_PKT(glrun1->GetRUNTRAILER_PKT());
2036        //        //
       glrun1->SetID(0);  
2037        glrun1->SetRUNHEADER_TIME(glrun->GetRUNHEADER_TIME());        glrun1->SetRUNHEADER_TIME(glrun->GetRUNHEADER_TIME());
2038        glrun1->SetRUNHEADER_OBT(glrun->GetRUNHEADER_OBT());        glrun1->SetRUNHEADER_OBT(glrun->GetRUNHEADER_OBT());
2039        glrun1->SetRUNHEADER_PKT(glrun->GetRUNHEADER_PKT());        glrun1->SetRUNHEADER_PKT(glrun->GetRUNHEADER_PKT());
# Line 1972  void PamelaDBOperations::HandleRunFragme Line 2053  void PamelaDBOperations::HandleRunFragme
2053        //        //
2054        if ( !IsRunAlreadyInserted() ){        if ( !IsRunAlreadyInserted() ){
2055          //          //
2056            glrun->SetID(this->AssignRunID());
2057            //
2058            glrun->SetID_RUN_FRAG(glrun1->GetID());
2059          glrun->Fill_GL_RUN(conn);          glrun->Fill_GL_RUN(conn);
2060          //          //
2061          // get id number          // get id number
2062          //          //
2063          oss.str("");  //      oss.str("");
2064          oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "  //      oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "
2065              << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "  //          << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "
2066              << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";  //          << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";
2067          //  //      //
2068          if ( IsDebug() ) printf(" search for idrun0 , query is : \n%s\n",oss.str().c_str());  //      if ( IsDebug() ) printf(" search for idrun0 , query is : \n%s\n",oss.str().c_str());
2069          //  //      //
2070          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
2071          if ( !result ) throw -4;  //      if ( !result ) throw -4;
2072          row = result->Next();  //      row = result->Next();
2073          //  //      //
2074          UInt_t idrun0 = 0;  //      UInt_t idrun0 = 0;
2075          if ( !row ){  //      if ( !row ){
2076            throw -10;  //        throw -10;
2077          } else {  //      } else {
2078            idrun0 = (UInt_t)atoll(row->GetField(0));  //        idrun0 = (UInt_t)atoll(row->GetField(0));
2079          };  //      };
2080          //  //      //
2081          glrun1->SetID_RUN_FRAG(idrun0);  //      glrun1->SetID_RUN_FRAG(idrun0);
2082          //  //
2083            glrun1->SetID_RUN_FRAG(glrun->GetID());
2084          glrun1->Fill_GL_RUN(conn);          glrun1->Fill_GL_RUN(conn);
2085          //          //
2086          oss.str("");  //      oss.str("");
2087          oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";  //      oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";
2088          //  //      //
2089          if ( IsDebug() ) printf(" search for idrun1 , query is : \n%s\n",oss.str().c_str());  //      if ( IsDebug() ) printf(" search for idrun1 , query is : \n%s\n",oss.str().c_str());
2090          //  //      //
2091          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
2092          if ( !result ) throw -4;  //      if ( !result ) throw -4;
2093          row = result->Next();  //      row = result->Next();
2094          //  //      //
2095          UInt_t idrun1 = 0;  //      UInt_t idrun1 = 0;
2096          if ( !row ){  //      if ( !row ){
2097            throw -10;  //        throw -10;
2098          } else {  //      } else {
2099            idrun1 = (UInt_t)atoll(row->GetField(0));  //        idrun1 = (UInt_t)atoll(row->GetField(0));
2100          };  //      };
2101          //  //      //
2102          oss.str("");  //      oss.str("");
2103          oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";  //      oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";
2104          //  //      //
2105          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
2106          if ( !result ) throw -4;  //      if ( !result ) throw -4;
2107          //          //
2108        };        };
2109        //        //
# Line 2026  void PamelaDBOperations::HandleRunFragme Line 2111  void PamelaDBOperations::HandleRunFragme
2111        //        //
2112        // delete old entry in fragment table        // delete old entry in fragment table
2113        //        //
2114        oss.str("");        glrun->DeleteRun(conn,idfrag,"GL_RUN_FRAGMENTS");
2115        //  //       oss.str("");
2116        oss << " DELETE FROM GL_RUN_FRAGMENTS WHERE ID = " << idfrag << ";";  //       //
2117        //  //       oss << " DELETE FROM GL_RUN_FRAGMENTS WHERE ID = " << idfrag << ";";
2118        if ( IsDebug() ) printf(" Delete from frag table the old run :\n query is \n %s \n",oss.str().c_str());  //       //
2119        result =  conn->Query(oss.str().c_str());  //       if ( IsDebug() ) printf(" Delete from frag table the old run :\n query is \n %s \n",oss.str().c_str());
2120        if ( !result ) throw -4;  //       result =  conn->Query(oss.str().c_str());
2121    //       if ( !result ) throw -4;
2122        //        //
2123        //        //
2124        return;        return;
# Line 2102  void PamelaDBOperations::HandleRunFragme Line 2188  void PamelaDBOperations::HandleRunFragme
2188          if ( IsDebug() ) printf(" The run is new \n");          if ( IsDebug() ) printf(" The run is new \n");
2189          if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n");          if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n");
2190          //          //
2191            glrun->SetID(this->AssignRunID());
2192            glrun->SetID_RUN_FRAG(0);
2193          glrun->Fill_GL_RUN_FRAGMENTS(conn);          glrun->Fill_GL_RUN_FRAGMENTS(conn);
2194          //          //
2195        } else {        } else {
# Line 2134  void PamelaDBOperations::HandleMissingHo Line 2222  void PamelaDBOperations::HandleMissingHo
2222      //      //
2223      this->FillClass(mishead,mistrail,firstev,lastev);      this->FillClass(mishead,mistrail,firstev,lastev);
2224      //      //
2225      if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);          if ( !IsRunAlreadyInserted() ){
2226          glrun->SetID(this->AssignRunID());
2227          glrun->SetID_RUN_FRAG(0);
2228          glrun->Fill_GL_RUN(conn);    
2229        };
2230      //      //
2231    };    };
2232    //    //
# Line 2301  Bool_t PamelaDBOperations::IsRunConsiste Line 2393  Bool_t PamelaDBOperations::IsRunConsiste
2393            //                  //      
2394            this->SetCommonGLRUN(firstTime,lastTime);            this->SetCommonGLRUN(firstTime,lastTime);
2395            //            //
2396            if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                  if ( !IsRunAlreadyInserted() ){
2397                glrun->SetID(this->AssignRunID());
2398                glrun->SetID_RUN_FRAG(0);
2399                glrun->Fill_GL_RUN(conn);      
2400              };
2401            //            //
2402            firstevno = lastentry + 1;            firstevno = lastentry + 1;
2403            //            //
# Line 2377  void PamelaDBOperations::HandleSuspiciou Line 2473  void PamelaDBOperations::HandleSuspiciou
2473      if ( IsDebug() ) printf(" Checking but no events in the run! \n");      if ( IsDebug() ) printf(" Checking but no events in the run! \n");
2474      //      //
2475      this->FillClass();      this->FillClass();
2476      if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);          if ( !IsRunAlreadyInserted() ){
2477          glrun->SetID(this->AssignRunID());
2478          glrun->SetID_RUN_FRAG(0);
2479          glrun->Fill_GL_RUN(conn);    
2480        };
2481      //      //
2482    } else {    } else {
2483      //      //
# Line 2405  void PamelaDBOperations::HandleSuspiciou Line 2505  void PamelaDBOperations::HandleSuspiciou
2505        if ( IsDebug() ) printf(" No packets but physics inside the run, I will consider it as good\n");        if ( IsDebug() ) printf(" No packets but physics inside the run, I will consider it as good\n");
2506        //        //
2507        this->FillClass();        this->FillClass();
2508        if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                if ( !IsRunAlreadyInserted() ){
2509            glrun->SetID(this->AssignRunID());
2510            glrun->SetID_RUN_FRAG(0);
2511            glrun->Fill_GL_RUN(conn);        
2512          };
2513        //        //
2514      } else {      } else {
2515        //        //
# Line 2503  void PamelaDBOperations::HandleSuspiciou Line 2607  void PamelaDBOperations::HandleSuspiciou
2607            //                  //      
2608            this->SetCommonGLRUN(firstTime,lastTime);            this->SetCommonGLRUN(firstTime,lastTime);
2609            //            //
2610            if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                  if ( !IsRunAlreadyInserted() ){
2611                glrun->SetID(this->AssignRunID());
2612                glrun->SetID_RUN_FRAG(0);
2613                glrun->Fill_GL_RUN(conn);      
2614              };
2615            //            //
2616            if ( i == lastev && checkfirst < check ){ // if the last event gives a wrong check...            if ( i == lastev && checkfirst < check ){ // if the last event gives a wrong check...
2617              //              //
# Line 2538  void PamelaDBOperations::HandleSuspiciou Line 2646  void PamelaDBOperations::HandleSuspiciou
2646              //                  //    
2647              this->SetCommonGLRUN(firstTime,lastTime);              this->SetCommonGLRUN(firstTime,lastTime);
2648              //              //
2649              if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                    if ( !IsRunAlreadyInserted() ){
2650                  glrun->SetID(this->AssignRunID());
2651                  glrun->SetID_RUN_FRAG(0);
2652                  glrun->Fill_GL_RUN(conn);      
2653                };
2654            };            };
2655            //            //
2656            firstevno = lastentry + 1;            firstevno = lastentry + 1;
# Line 3281  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 3393  Int_t PamelaDBOperations::CleanGL_RUN_FR
3393          if ( IsDebug() ) printf(" The run is new \n");          if ( IsDebug() ) printf(" The run is new \n");
3394          if ( IsDebug() ) printf(" -> fill the DB \n");                if ( IsDebug() ) printf(" -> fill the DB \n");      
3395          //          //
3396          glrun->SetID(0);          //      glrun->SetID(this->AssignRunID()); we use the old run number!
3397            glrun->SetID_RUN_FRAG(glrun->GetID());
3398          glrun->Fill_GL_RUN(conn);            glrun->Fill_GL_RUN(conn);  
3399          //          //
3400          oss.str("");  //      oss.str("");
3401          oss << " SELECT ID FROM GL_RUN WHERE "  //      oss << " SELECT ID FROM GL_RUN WHERE "
3402              << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND "  //          << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND "
3403              << " RUNHEADER_PKT=" << (UInt_t)glrun->GetRUNHEADER_PKT() << " AND "  //          << " RUNHEADER_PKT=" << (UInt_t)glrun->GetRUNHEADER_PKT() << " AND "
3404              << " RUNTRAILER_PKT=" << (UInt_t)glrun->GetRUNTRAILER_PKT() << " AND "  //          << " RUNTRAILER_PKT=" << (UInt_t)glrun->GetRUNTRAILER_PKT() << " AND "
3405              << " RUNHEADER_OBT=" << (UInt_t)glrun->GetRUNHEADER_OBT() << " AND "  //          << " RUNHEADER_OBT=" << (UInt_t)glrun->GetRUNHEADER_OBT() << " AND "
3406              << " RUNTRAILER_OBT=" << (UInt_t)glrun->GetRUNTRAILER_OBT() << "; ";  //          << " RUNTRAILER_OBT=" << (UInt_t)glrun->GetRUNTRAILER_OBT() << "; ";
3407          //  //      //
3408          if ( IsDebug() ) printf(" Look for the ID of the inserted run: query is \n %s \n",oss.str().c_str());  //      if ( IsDebug() ) printf(" Look for the ID of the inserted run: query is \n %s \n",oss.str().c_str());
3409          result2 = conn->Query(oss.str().c_str());  //      result2 = conn->Query(oss.str().c_str());
3410          //  //      //
3411          if ( !result2 ) throw -4;  //      if ( !result2 ) throw -4;
3412          //  //      //
3413          row2 = result2->Next();  //      row2 = result2->Next();
3414          //  //      //
3415          if ( !row2 ) throw -25;  //      if ( !row2 ) throw -25;
3416          //  //      //
3417          oss.str("");  //      oss.str("");
3418          oss << " UPDATE GL_RUN SET ID_RUN_FRAG = " << row2->GetField(0) << " WHERE ID = " << row2->GetField(0);  //      oss << " UPDATE GL_RUN SET ID_RUN_FRAG = " << row2->GetField(0) << " WHERE ID = " << row2->GetField(0);
3419          if ( IsDebug() ) printf(" Update the ID_RUN_FRAG of the inserted run: query is \n %s \n",oss.str().c_str());  //      if ( IsDebug() ) printf(" Update the ID_RUN_FRAG of the inserted run: query is \n %s \n",oss.str().c_str());
3420          result2 = conn->Query(oss.str().c_str());  //      result2 = conn->Query(oss.str().c_str());
3421          //  //      //
3422          if ( !result2 ) throw -4;  //      if ( !result2 ) throw -4;
3423          //          //
3424          moved++;          moved++;
3425          //          //
# Line 3316  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 3429  Int_t PamelaDBOperations::CleanGL_RUN_FR
3429        if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0));              if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0));      
3430        //        //
3431        //        //
3432        oss.str("");        glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS");
3433        oss << " DELETE from GL_RUN_FRAGMENTS where ID = " << row->GetField(0);  //      oss.str("");
3434        if ( IsDebug() ) printf(" Clean the GL_RUN_FRAGMENTS table: query is \n %s \n",oss.str().c_str());  //       oss << " DELETE from GL_RUN_FRAGMENTS where ID = " << row->GetField(0);
3435        result2 = conn->Query(oss.str().c_str());  //       if ( IsDebug() ) printf(" Clean the GL_RUN_FRAGMENTS table: query is \n %s \n",oss.str().c_str());
3436        //  //       result2 = conn->Query(oss.str().c_str());
3437        if ( !result2 ) throw -4;  //      //
3438        //  //      if ( !result2 ) throw -4;
3439    //      //
3440        row = result->Next();        row = result->Next();
3441      };      };
3442    };    };

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.23