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"
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_From = std::abs(runFrom);
81 int run_To = std::abs(runTo);
86 StatusCode sc = Gaudi::svcLocator()->service(
"DatabaseSvc",m_dbsvc,
true);
87 if (sc .isFailure() ) {
88 std::cout<<
"MSG::ERROR " <<
"Unable to find DatabaseSvc " << std::endl;
92 sprintf(stmt1,
"select run_number,BPR_PRB,BER_PRB from RunParams where run_number >= %d and run_number <= %d ",run_From,run_To);
94 int row_no = m_dbsvc->
query(
"run",stmt1,results);
96 std::cout <<
"ERROR:"<<
"Run:"<<run_From<<
" Can not read the beam energy from the Database" << endl;
108 for(
int i=0;i<row_no;i++)
111 int run_No = dbrec.
GetInt(
"run_number");
112 std::vector<double> beamEnergy;
113 beamEnergy.push_back(dbrec.
GetDouble(
"BPR_PRB"));
114 beamEnergy.push_back(dbrec.
GetDouble(
"BER_PRB"));
115 m_mapBeamEnergy[run_No] = beamEnergy;
119 cout<<
"map of run:"<<run_No<<
"BPR_PRB:"<<beam1<<
"BER_PRB:"<<beam2<<endl;
130 int run_From = std::abs(runFrom);
131 int run_To = std::abs(runTo);
136 StatusCode sc = Gaudi::svcLocator()->service(
"DatabaseSvc",m_dbsvc,
true);
137 if (sc .isFailure() ) {
138 std::cout<<
"MSG::ERROR " <<
"Unable to find DatabaseSvc " << std::endl;
141 sprintf(stmt1,
"select run_number,Magnet_Current,SCQL,SCQR from SC_magnet where run_number >= %d and run_number<=%d ",run_From,run_To);
143 int row_no = m_dbsvc->
query(
"run",stmt1,results);
145 std::cout <<
"ERROR Read the SSM and SCQ current from the Database"<<
" Run:"<<run_From << endl; exit(1); }
148 for(
int i=0;i<row_no;i++)
151 int run_No = dbrec.
GetInt(
"run_number");
152 std::vector<double> SCMagnet;
153 SCMagnet.push_back(dbrec.
GetDouble(
"Magnet_Current"));
154 SCMagnet.push_back(dbrec.
GetDouble(
"SCQL"));
155 SCMagnet.push_back(dbrec.
GetDouble(
"SCQR"));
156 m_mapMagnetInfo[run_No] = SCMagnet;
167 int run_No = std::abs(
runNo);
169 sprintf(stmt1,
"select BPR_PRB,BER_PRB from RunParams where run_number = %d ",run_No);
173 int status = m_dbsvc->
query(
"run",stmt1,results);
175 std::cout <<
"ERROR Read the beam energy from the Database" << endreq;
179 int RowNumber = results.size();
182 beamE.push_back(1.843);
183 beamE.push_back(1.843);
189 std::cout<<
"ERROR:error searching beam energy in the database, check your selection criterions"<<std::endl;
193 beamE.push_back(atof((*results[0])[
"BPR_PRB"]));
194 beamE.push_back(atof((*results[0])[
"BER_PRB"]));
196 beam1=atof((*results[0])[
"BPR_PRB"]);
197 beam2=atof((*results[0])[
"BER_PRB"]);
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
double GetDouble(std::string key)
int GetInt(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