/[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.14 by mocchiut, Fri Oct 20 11:39:37 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 1556  void PamelaDBOperations::HandleRun(){   Line 1629  void PamelaDBOperations::HandleRun(){  
1629      //      //
1630      this->FillClass();      this->FillClass();
1631      //      //
1632      if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);      if ( !IsRunAlreadyInserted() ){
1633          glrun->SetID(this->AssignRunID());
1634          glrun->SetID_RUN_FRAG(0);
1635          glrun->Fill_GL_RUN(conn);
1636        };
1637    } else {    } else {
1638      //      //
1639      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 1805  void PamelaDBOperations::HandleRunFragme
1805        };        };
1806        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);
1807        //        //
       glrun1->SetID(0);  
1808        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());
1809        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());
1810        glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME());        glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME());
# Line 1756  void PamelaDBOperations::HandleRunFragme Line 1832  void PamelaDBOperations::HandleRunFragme
1832        //        //
1833        if ( !IsRunAlreadyInserted() ){        if ( !IsRunAlreadyInserted() ){
1834          //          //
1835            glrun->SetID(this->AssignRunID());
1836            glrun->SetID_RUN_FRAG(glrun1->GetID());
1837          glrun->Fill_GL_RUN(conn);          glrun->Fill_GL_RUN(conn);
1838          //          //
1839          // get id number          // get id number
1840          //          //
1841          oss.str("");  //      oss.str("");
1842          oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "  //      oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "
1843              << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "  //          << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "
1844              << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";  //          << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";
1845          //  //      //
1846          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());
1847          //  //      //
1848          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
1849          if ( !result ) throw -4;  //      if ( !result ) throw -4;
1850          row = result->Next();  //      row = result->Next();
1851          //  //      //
1852          UInt_t idrun0 = 0;  //      UInt_t idrun0 = 0;
1853          if ( !row ){  //      if ( !row ){
1854            throw -10;  //        throw -10;
1855          } else {  //      } else {
1856            idrun0 = (UInt_t)atoll(row->GetField(0));  //        idrun0 = (UInt_t)atoll(row->GetField(0));
1857          };  //      };
         //  
         glrun1->SetID_RUN_FRAG(idrun0);  
1858          //          //
1859            //      glrun1->SetID_RUN_FRAG(idrun0);
1860            glrun1->SetID_RUN_FRAG(glrun->GetID());
1861          glrun1->Fill_GL_RUN(conn);          glrun1->Fill_GL_RUN(conn);
1862          //          //
1863          oss.str("");  //      oss.str("");
1864          oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";  //      oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";
1865          //  //      //
1866          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());
1867          //  //      //
1868          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
1869          if ( !result ) throw -4;  //      if ( !result ) throw -4;
1870          row = result->Next();  //      row = result->Next();
1871          //  //      //
1872          UInt_t idrun1 = 0;  //      UInt_t idrun1 = 0;
1873          if ( !row ){  //      if ( !row ){
1874            throw -10;  //        throw -10;
1875          } else {  //      } else {
1876            idrun1 = (UInt_t)atoll(row->GetField(0));  //        idrun1 = (UInt_t)atoll(row->GetField(0));
1877          };  //      };
1878          //  //      //
1879          oss.str("");  //      oss.str("");
1880          oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";  //      oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";
1881          //  //      //
1882          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
1883          if ( !result ) throw -4;  //      if ( !result ) throw -4;
1884          //          //
1885        };        };
1886        //        //
# Line 1952  void PamelaDBOperations::HandleRunFragme Line 2030  void PamelaDBOperations::HandleRunFragme
2030        glrun->SetRUNTRAILER_OBT(glrun1->GetRUNTRAILER_OBT());        glrun->SetRUNTRAILER_OBT(glrun1->GetRUNTRAILER_OBT());
2031        glrun->SetRUNTRAILER_PKT(glrun1->GetRUNTRAILER_PKT());        glrun->SetRUNTRAILER_PKT(glrun1->GetRUNTRAILER_PKT());
2032        //        //
       glrun1->SetID(0);  
2033        glrun1->SetRUNHEADER_TIME(glrun->GetRUNHEADER_TIME());        glrun1->SetRUNHEADER_TIME(glrun->GetRUNHEADER_TIME());
2034        glrun1->SetRUNHEADER_OBT(glrun->GetRUNHEADER_OBT());        glrun1->SetRUNHEADER_OBT(glrun->GetRUNHEADER_OBT());
2035        glrun1->SetRUNHEADER_PKT(glrun->GetRUNHEADER_PKT());        glrun1->SetRUNHEADER_PKT(glrun->GetRUNHEADER_PKT());
# Line 1972  void PamelaDBOperations::HandleRunFragme Line 2049  void PamelaDBOperations::HandleRunFragme
2049        //        //
2050        if ( !IsRunAlreadyInserted() ){        if ( !IsRunAlreadyInserted() ){
2051          //          //
2052            glrun->SetID(this->AssignRunID());
2053            //
2054            glrun->SetID_RUN_FRAG(glrun1->GetID());
2055          glrun->Fill_GL_RUN(conn);          glrun->Fill_GL_RUN(conn);
2056          //          //
2057          // get id number          // get id number
2058          //          //
2059          oss.str("");  //      oss.str("");
2060          oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "  //      oss << " SELECT ID FROM GL_RUN WHERE BOOT_NUMBER="<<this->GetBOOTnumber()<<" AND "
2061              << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "  //          << " RUNHEADER_OBT="<<glrun->GetRUNHEADER_OBT()<<" AND "
2062              << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";  //          << " RUNTRAILER_OBT="<<glrun->GetRUNTRAILER_OBT()<<";";
2063          //  //      //
2064          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());
2065          //  //      //
2066          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
2067          if ( !result ) throw -4;  //      if ( !result ) throw -4;
2068          row = result->Next();  //      row = result->Next();
2069          //  //      //
2070          UInt_t idrun0 = 0;  //      UInt_t idrun0 = 0;
2071          if ( !row ){  //      if ( !row ){
2072            throw -10;  //        throw -10;
2073          } else {  //      } else {
2074            idrun0 = (UInt_t)atoll(row->GetField(0));  //        idrun0 = (UInt_t)atoll(row->GetField(0));
2075          };  //      };
2076          //  //      //
2077          glrun1->SetID_RUN_FRAG(idrun0);  //      glrun1->SetID_RUN_FRAG(idrun0);
2078          //  //
2079            glrun1->SetID_RUN_FRAG(glrun->GetID());
2080          glrun1->Fill_GL_RUN(conn);          glrun1->Fill_GL_RUN(conn);
2081          //          //
2082          oss.str("");  //      oss.str("");
2083          oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";  //      oss << " SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG="<<idrun0<<" ;";
2084          //  //      //
2085          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());
2086          //  //      //
2087          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
2088          if ( !result ) throw -4;  //      if ( !result ) throw -4;
2089          row = result->Next();  //      row = result->Next();
2090          //  //      //
2091          UInt_t idrun1 = 0;  //      UInt_t idrun1 = 0;
2092          if ( !row ){  //      if ( !row ){
2093            throw -10;  //        throw -10;
2094          } else {  //      } else {
2095            idrun1 = (UInt_t)atoll(row->GetField(0));  //        idrun1 = (UInt_t)atoll(row->GetField(0));
2096          };  //      };
2097          //  //      //
2098          oss.str("");  //      oss.str("");
2099          oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";  //      oss << " UPDATE GL_RUN SET ID_RUN_FRAG="<<idrun1<<" WHERE ID="<<idrun0<<" ;";
2100          //  //      //
2101          result =  conn->Query(oss.str().c_str());  //      result =  conn->Query(oss.str().c_str());
2102          if ( !result ) throw -4;  //      if ( !result ) throw -4;
2103          //          //
2104        };        };
2105        //        //
# Line 2102  void PamelaDBOperations::HandleRunFragme Line 2183  void PamelaDBOperations::HandleRunFragme
2183          if ( IsDebug() ) printf(" The run is new \n");          if ( IsDebug() ) printf(" The run is new \n");
2184          if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n");          if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n");
2185          //          //
2186            glrun->SetID(this->AssignRunID());
2187            glrun->SetID_RUN_FRAG(0);
2188          glrun->Fill_GL_RUN_FRAGMENTS(conn);          glrun->Fill_GL_RUN_FRAGMENTS(conn);
2189          //          //
2190        } else {        } else {
# Line 2134  void PamelaDBOperations::HandleMissingHo Line 2217  void PamelaDBOperations::HandleMissingHo
2217      //      //
2218      this->FillClass(mishead,mistrail,firstev,lastev);      this->FillClass(mishead,mistrail,firstev,lastev);
2219      //      //
2220      if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);          if ( !IsRunAlreadyInserted() ){
2221          glrun->SetID(this->AssignRunID());
2222          glrun->SetID_RUN_FRAG(0);
2223          glrun->Fill_GL_RUN(conn);    
2224        };
2225      //      //
2226    };    };
2227    //    //
# Line 2301  Bool_t PamelaDBOperations::IsRunConsiste Line 2388  Bool_t PamelaDBOperations::IsRunConsiste
2388            //                  //      
2389            this->SetCommonGLRUN(firstTime,lastTime);            this->SetCommonGLRUN(firstTime,lastTime);
2390            //            //
2391            if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                  if ( !IsRunAlreadyInserted() ){
2392                glrun->SetID(this->AssignRunID());
2393                glrun->SetID_RUN_FRAG(0);
2394                glrun->Fill_GL_RUN(conn);      
2395              };
2396            //            //
2397            firstevno = lastentry + 1;            firstevno = lastentry + 1;
2398            //            //
# Line 2377  void PamelaDBOperations::HandleSuspiciou Line 2468  void PamelaDBOperations::HandleSuspiciou
2468      if ( IsDebug() ) printf(" Checking but no events in the run! \n");      if ( IsDebug() ) printf(" Checking but no events in the run! \n");
2469      //      //
2470      this->FillClass();      this->FillClass();
2471      if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);          if ( !IsRunAlreadyInserted() ){
2472          glrun->SetID(this->AssignRunID());
2473          glrun->SetID_RUN_FRAG(0);
2474          glrun->Fill_GL_RUN(conn);    
2475        };
2476      //      //
2477    } else {    } else {
2478      //      //
# Line 2405  void PamelaDBOperations::HandleSuspiciou Line 2500  void PamelaDBOperations::HandleSuspiciou
2500        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");
2501        //        //
2502        this->FillClass();        this->FillClass();
2503        if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                if ( !IsRunAlreadyInserted() ){
2504            glrun->SetID(this->AssignRunID());
2505            glrun->SetID_RUN_FRAG(0);
2506            glrun->Fill_GL_RUN(conn);        
2507          };
2508        //        //
2509      } else {      } else {
2510        //        //
# Line 2503  void PamelaDBOperations::HandleSuspiciou Line 2602  void PamelaDBOperations::HandleSuspiciou
2602            //                  //      
2603            this->SetCommonGLRUN(firstTime,lastTime);            this->SetCommonGLRUN(firstTime,lastTime);
2604            //            //
2605            if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                  if ( !IsRunAlreadyInserted() ){
2606                glrun->SetID(this->AssignRunID());
2607                glrun->SetID_RUN_FRAG(0);
2608                glrun->Fill_GL_RUN(conn);      
2609              };
2610            //            //
2611            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...
2612              //              //
# Line 2538  void PamelaDBOperations::HandleSuspiciou Line 2641  void PamelaDBOperations::HandleSuspiciou
2641              //                  //    
2642              this->SetCommonGLRUN(firstTime,lastTime);              this->SetCommonGLRUN(firstTime,lastTime);
2643              //              //
2644              if ( !IsRunAlreadyInserted() ) glrun->Fill_GL_RUN(conn);                    if ( !IsRunAlreadyInserted() ){
2645                  glrun->SetID(this->AssignRunID());
2646                  glrun->SetID_RUN_FRAG(0);
2647                  glrun->Fill_GL_RUN(conn);      
2648                };
2649            };            };
2650            //            //
2651            firstevno = lastentry + 1;            firstevno = lastentry + 1;
# Line 3281  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 3388  Int_t PamelaDBOperations::CleanGL_RUN_FR
3388          if ( IsDebug() ) printf(" The run is new \n");          if ( IsDebug() ) printf(" The run is new \n");
3389          if ( IsDebug() ) printf(" -> fill the DB \n");                if ( IsDebug() ) printf(" -> fill the DB \n");      
3390          //          //
3391          glrun->SetID(0);          //      glrun->SetID(this->AssignRunID()); we use the old run number!
3392            glrun->SetID_RUN_FRAG(glrun->GetID());
3393          glrun->Fill_GL_RUN(conn);            glrun->Fill_GL_RUN(conn);  
3394          //          //
3395          oss.str("");  //      oss.str("");
3396          oss << " SELECT ID FROM GL_RUN WHERE "  //      oss << " SELECT ID FROM GL_RUN WHERE "
3397              << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND "  //          << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND "
3398              << " RUNHEADER_PKT=" << (UInt_t)glrun->GetRUNHEADER_PKT() << " AND "  //          << " RUNHEADER_PKT=" << (UInt_t)glrun->GetRUNHEADER_PKT() << " AND "
3399              << " RUNTRAILER_PKT=" << (UInt_t)glrun->GetRUNTRAILER_PKT() << " AND "  //          << " RUNTRAILER_PKT=" << (UInt_t)glrun->GetRUNTRAILER_PKT() << " AND "
3400              << " RUNHEADER_OBT=" << (UInt_t)glrun->GetRUNHEADER_OBT() << " AND "  //          << " RUNHEADER_OBT=" << (UInt_t)glrun->GetRUNHEADER_OBT() << " AND "
3401              << " RUNTRAILER_OBT=" << (UInt_t)glrun->GetRUNTRAILER_OBT() << "; ";  //          << " RUNTRAILER_OBT=" << (UInt_t)glrun->GetRUNTRAILER_OBT() << "; ";
3402          //  //      //
3403          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());
3404          result2 = conn->Query(oss.str().c_str());  //      result2 = conn->Query(oss.str().c_str());
3405          //  //      //
3406          if ( !result2 ) throw -4;  //      if ( !result2 ) throw -4;
3407          //  //      //
3408          row2 = result2->Next();  //      row2 = result2->Next();
3409          //  //      //
3410          if ( !row2 ) throw -25;  //      if ( !row2 ) throw -25;
3411          //  //      //
3412          oss.str("");  //      oss.str("");
3413          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);
3414          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());
3415          result2 = conn->Query(oss.str().c_str());  //      result2 = conn->Query(oss.str().c_str());
3416          //  //      //
3417          if ( !result2 ) throw -4;  //      if ( !result2 ) throw -4;
3418          //          //
3419          moved++;          moved++;
3420          //          //

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

  ViewVC Help
Powered by ViewVC 1.1.23