2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/SvcFactory.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/SmartDataPtr.h"
6#include "GaudiKernel/Bootstrap.h"
8#include "facilities/Util.h"
10#include "DatabaseSvc/DatabaseSvc.h"
17#include "MagneticField/ConnectionDB.h"
25 StatusCode sc = Gaudi::svcLocator()->service(
"DatabaseSvc", m_dbsvc,
true);
26 if (sc .isFailure() ) {
27 std::cout <<
"ERROR: In ConnectionDB()--> Unable to find DatabaseSvc " << std::endl;
38 m_dbsvc = DatabaseSvc::instance();
44 int run_No = std::abs(
runNo);
46 sprintf(stmt1,
"select Magnet_Current,SCQL,SCQR from SC_magnet where run_number = %d ",run_No);
50 int status = m_dbsvc->
query(
"run",stmt1,results);
53 std::cout <<
"ERROR Read the SSM and SCQ current from the Database" << endl;
57 int RowNumber = results.size();
59 std::cout<<
"ERROR:error searching SC_Magnet Data in the database, check your selection criterions"<<std::endl;
64 double ssm_curr = rec.
GetDouble(
"Magnet_Current");
70 current[0] = ssm_curr;
71 current[1] = scql_curr;
72 current[2] = scqr_curr;
80 int run_No = std::abs(
runNo);
82 sprintf(stmt1,
"select BPR_PRB,BER_PRB from RunParams where run_number = %d ",run_No);
86 int status = m_dbsvc->
query(
"run",stmt1,results);
88 std::cout <<
"ERROR Read the beam energy from the Database" << endreq;
92 int RowNumber = results.size();
95 beamE.push_back(1.843);
96 beamE.push_back(1.843);
102 std::cout<<
"ERROR:error searching beam energy in the database, check your selection criterions"<<std::endl;
106 beamE.push_back(atof((*results[0])[
"BPR_PRB"]));
107 beamE.push_back(atof((*results[0])[
"BER_PRB"]));
double GetDouble(std::string key)
int query(const std::string &dbName, const std::string &sql)
ConnectionDB()
Constructor keeps track of table of interest.
ConnectionDB::eRet getReadSC_MagnetInfo(std::vector< double > ¤t, int runNo)
ConnectionDB::eRet getBeamEnergy(std::vector< double > &beamE, int runNo)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0