/[PAMELA software]/YodaProfiler/src/GLTables.cpp
ViewVC logotype

Diff of /YodaProfiler/src/GLTables.cpp

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

revision 1.33 by mocchiut, Fri Oct 19 07:48:18 2007 UTC revision 1.34 by mocchiut, Thu Oct 25 13:23:36 2007 UTC
# Line 24  ClassImp(GL_ROOT); Line 24  ClassImp(GL_ROOT);
24  ClassImp(GL_PARAM);  ClassImp(GL_PARAM);
25  ClassImp(GL_S4_CALIB);  ClassImp(GL_S4_CALIB);
26  ClassImp(GL_CALO_CALIB);  ClassImp(GL_CALO_CALIB);
27    ClassImp(GL_CALOPULSE_CALIB);
28  ClassImp(GL_TIMESYNC);  ClassImp(GL_TIMESYNC);
29  ClassImp(GL_TLE);  ClassImp(GL_TLE);
30  //  //
# Line 63  Bool_t GL_TABLES::IsConnected(TSQLServer Line 64  Bool_t GL_TABLES::IsConnected(TSQLServer
64      return true;      return true;
65    };    };
66    //    //
   //  
   //  
67    //    printf(" host is %s \n",fHost->Data());    //    printf(" host is %s \n",fHost->Data());
68    //    //
69    stringstream myquery;      stringstream myquery;  
# Line 85  Bool_t GL_TABLES::IsConnected(TSQLServer Line 84  Bool_t GL_TABLES::IsConnected(TSQLServer
84        };        };
85      };      };
86    };    };
87    //  printf("porca di quella \n");    //
88    if ( true ) {    if ( true ) {
89      //      //
90      printf(" WARNING: Lost connection to DB! try to recover... \n");      printf(" WARNING: Lost connection to DB! try to recover... \n");
# Line 100  Bool_t GL_TABLES::IsConnected(TSQLServer Line 99  Bool_t GL_TABLES::IsConnected(TSQLServer
99      myquery << "show databases;";      myquery << "show databases;";
100      dbc->Query(myquery.str().c_str());      dbc->Query(myquery.str().c_str());
101      fNquery++;      fNquery++;
     //    printf(" e riporca di quella \n");  
     //  
102      //    if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){      //    if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){
103      if ( !(dbc->GetErrorCode()) ){      if ( !(dbc->GetErrorCode()) ){
104        //        //
# Line 249  GL_CALO_CALIB::GL_CALO_CALIB(){ Line 246  GL_CALO_CALIB::GL_CALO_CALIB(){
246    FROM_TIME = 0;    FROM_TIME = 0;
247    TO_TIME   = 0;    TO_TIME   = 0;
248    SECTION   = 0;    SECTION   = 0;
249      OBT = 0;
250      PKT = 0;
251      BOOT_NUMBER                = 0;
252      VALIDATION                 = 0;
253    }
254    
255    GL_CALOPULSE_CALIB::GL_CALOPULSE_CALIB(){
256      ID        = 0;
257      ID_ROOT_L0  = 0;
258      EV_ROOT = 0;
259      FROM_TIME = 0;
260      TO_TIME   = 0;
261      SECTION   = 0;
262      PULSED_STRIP = 0;
263      PULSE_AMPLITUDE = 0;
264      OBT = 0;
265      PKT = 0;
266      BOOT_NUMBER                = 0;
267      VALIDATION                 = 0;
268  }  }
269    
270  GL_S4_CALIB::GL_S4_CALIB(){  GL_S4_CALIB::GL_S4_CALIB(){
# Line 257  GL_S4_CALIB::GL_S4_CALIB(){ Line 273  GL_S4_CALIB::GL_S4_CALIB(){
273    EV_ROOT = 0;    EV_ROOT = 0;
274    FROM_TIME = 0;    FROM_TIME = 0;
275    TO_TIME   = 0;    TO_TIME   = 0;
276    PARAM_FIT0 = 0.;    OBT = 0;
277    PARAM_FIT1 = 0.;    PKT = 0;
278      BOOT_NUMBER                = 0;
279  }  }
280    
281  GL_TIMESYNC::GL_TIMESYNC(){  GL_TIMESYNC::GL_TIMESYNC(){
# Line 1297  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB Line 1314  Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB
1314    pResult->Delete();    pResult->Delete();
1315    return 0;    return 0;
1316  };  };
1317    
1318    
1319    // ****************************************************
1320    /**
1321     * Function to query the GL_CALOPULSE_CALIB table of the DB.
1322     *
1323     * \param  run starting time
1324     * \return struct of type GL_CALOPULSE_CALIB_data, which stores the query result
1325     */
1326    Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){
1327      // MySQL variables
1328      TSQLResult *pResult;
1329      TSQLRow *Row;
1330      int t;
1331      stringstream myquery;
1332      //
1333      // select the correct calibration i.e. the closest to our time
1334      //
1335      myquery.str("");
1336      myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALOPULSE_CALIB where SECTION=" << section;
1337      myquery << " and PULSE_AMPLITUDE=" << pampli;
1338      myquery << " and VALIDATION=1 and (PULSED_STRIP IS NULL OR PULSED_STRIP<100) ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;";
1339      //  printf(" myq is %s \n",myquery.str().c_str());
1340      //
1341      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1342      this->GetGLTABLES()->AddQ();
1343      pResult = dbc->Query(myquery.str().c_str());
1344      //
1345      if( !pResult ) return(-54);
1346      //
1347      Row = pResult->Next();
1348      //
1349      if( !Row ) return (-54);
1350      //
1351      // store infos and exit
1352      //
1353      for( t = 0; t < pResult->GetFieldCount(); t++){
1354        //    printf(" field %i is %s \n",t,Row->GetField(t));
1355        if (t==0) ID_ROOT_L0  = (UInt_t)atoll(Row->GetField(t));
1356        if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
1357        if (t==2) TO_TIME   = (UInt_t)atoll(Row->GetField(t));            
1358        if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t));
1359      };
1360      pResult->Delete();
1361      return 0;
1362    };
1363    
1364    
1365  // ****************************************************  // ****************************************************
1366  /**  /**
1367   * Function to query the GL_S4_CALIB table of the DB.   * Function to query the GL_S4_CALIB table of the DB.
# Line 1313  Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UIn Line 1378  Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UIn
1378    stringstream myquery;    stringstream myquery;
1379    // ----------------    // ----------------
1380    myquery.str("");    myquery.str("");
1381    myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time;    myquery << "select ID,ID_ROOT_L0,EV_ROOT,FROM_TIME,TO_TIME from GL_S4_CALIB where FROM_TIME <= "<< time;
1382    myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1383    //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1384    if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
# Line 1325  Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UIn Line 1390  Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UIn
1390        if( Row == NULL ) break;        if( Row == NULL ) break;
1391        for( t = 0; t < pResult->GetFieldCount(); t++){        for( t = 0; t < pResult->GetFieldCount(); t++){
1392          if (t==0) ID               = (UInt_t)atoll(Row->GetField(t));          if (t==0) ID               = (UInt_t)atoll(Row->GetField(t));
1393            if (t==1) ID_ROOT_L0  = (UInt_t)atoll(Row->GetField(t));          if (t==1) ID_ROOT_L0  = (UInt_t)atoll(Row->GetField(t));
1394            if (t==2) EV_ROOT    = (UInt_t)atoll(Row->GetField(t));          if (t==2) EV_ROOT    = (UInt_t)atoll(Row->GetField(t));
1395            if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t));          if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
1396            if (t==4) TO_TIME   = (UInt_t)atoll(Row->GetField(t));          if (t==4) TO_TIME   = (UInt_t)atoll(Row->GetField(t));
           if (t==5) PARAM_FIT0   = atof(Row->GetField(t));  
           if (t==6) PARAM_FIT1   = atof(Row->GetField(t));  
1397        };        };
1398    };    };
1399    delete pResult;        delete pResult;    

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

  ViewVC Help
Powered by ViewVC 1.1.23