17#include "GaudiKernel/Kernel.h"
18#include "GaudiKernel/IInterface.h"
19#include "GaudiKernel/StatusCode.h"
20#include "GaudiKernel/SvcFactory.h"
21#include "GaudiKernel/MsgStream.h"
22#include "GaudiKernel/ISvcLocator.h"
23#include "GaudiKernel/SmartDataPtr.h"
24#include "GaudiKernel/IDataProviderSvc.h"
25#include "GaudiKernel/PropertyMgr.h"
28#include "GaudiKernel/IIncidentSvc.h"
29#include "GaudiKernel/Incident.h"
30#include "GaudiKernel/IIncidentListener.h"
32#include "GaudiKernel/ISvcLocator.h"
33#include "GaudiKernel/Bootstrap.h"
44 base_class (name, svcloc){
46 declareProperty(
"Host" , host = std::string(
"bes3db2.ihep.ac.cn"));
47 declareProperty(
"DbName" , dbName = std::string(
"offlinedb"));
48 declareProperty(
"UserName" , userName = std::string(
"guest"));
49 declareProperty(
"Password" , password = std::string(
"guestpass"));
66 MsgStream log(messageService(), name());
67 log << MSG::INFO <<
"ScanEnergySvc::initialize()" << endreq;
69 StatusCode sc = Service::initialize();
70 if( sc.isFailure() )
return sc;
74 sc = service(
"IncidentSvc", incsvc);
77 incsvc -> addListener(
this,
"NewRun", priority);
80 sc = serviceLocator()->service(
"DatabaseSvc",
m_dbsvc,
true);
81 if (sc .isFailure() ) {
82 log << MSG::ERROR <<
"Unable to find DatabaseSvc " << endreq;
86 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
87 if (sc .isFailure() ) {
88 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
92 return StatusCode::SUCCESS;
96 MsgStream log(messageService(), name());
97 log << MSG::INFO <<
"ScanEnergySvc::finalize()" << endreq;
99 return StatusCode::SUCCESS;
103 MsgStream log( messageService(), name() );
104 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
106 if ( inc.type() ==
"NewRun" ){
107 log << MSG::DEBUG <<
"NewRun" << endreq;
109 log << MSG::ERROR <<
"can not initilize Tof energy Calib Constants" << endreq;
116 MsgStream log(messageService(), name());
117 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
118 int run = eventHeader->runNumber();
120 if (run>=55054&&run<=55859){
122 cout<<
"Run in getScanEnergySvcInfo() is: "<<run<<endl;
126 cout <<
"This data is the MC sample with the Run Number: " << run << endl;
130 sprintf(stmt1,
"select runStart,runEnd,Energy from ScanEnergy where runStart <= %d and runEnd >= %d ", run, run);
131 cout<<
"stmt is:"<<stmt1<<endl;
136 m_ScanEnergy = dbrec.
GetDouble(
"Energy");
137 m_RunStart =dbrec.
GetInt(
"runStart");
138 m_RunEnd =dbrec.
GetInt(
"runEnd");
139 cout<<
"m_ScanEnergy is:"<<m_ScanEnergy<<
" m_RunStart is:"<<m_RunStart<<
" m_RunEnd is:"<<m_RunEnd<<endl;
140 cout <<
"Successfully fetch ScanEnergySvc information for run: "
143 }
else if( row_no<=0 ) {
144 cout <<
" ScanEnergySvc:: can not found ScanEnergySvc information of run:"
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)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
bool getScanEnergySvcInfo()
virtual StatusCode initialize()
virtual StatusCode finalize()
void handle(const Incident &)