15#include "GaudiKernel/IDataProviderSvc.h"
16#include "GaudiKernel/IInterface.h"
17#include "GaudiKernel/ISvcLocator.h"
18#include "GaudiKernel/Kernel.h"
19#include "GaudiKernel/MsgStream.h"
20#include "GaudiKernel/PropertyMgr.h"
21#include "GaudiKernel/SmartDataPtr.h"
22#include "GaudiKernel/StatusCode.h"
25#include "GaudiKernel/IIncidentListener.h"
26#include "GaudiKernel/IIncidentSvc.h"
27#include "GaudiKernel/Incident.h"
29#include "EventModel/Event.h"
30#include "EventModel/EventHeader.h"
31#include "EventModel/EventModel.h"
32#include "GaudiKernel/Bootstrap.h"
33#include "GaudiKernel/ISvcLocator.h"
41 : base_class( name, svcloc ) {
43 declareProperty(
"Host", host = std::string(
"bes3db2.ihep.ac.cn" ) );
44 declareProperty(
"DbName", dbName = std::string(
"offlinedb" ) );
45 declareProperty(
"UserName", userName = std::string(
"guest" ) );
46 declareProperty(
"Password", password = std::string(
"guestpass" ) );
62 MsgStream log(
msgSvc(), name() );
63 log << MSG::INFO <<
"ScanEnergySvc::initialize()" << endmsg;
65 StatusCode sc = Service::initialize();
66 if ( sc.isFailure() )
return sc;
69 sc = service(
"IncidentSvc", incsvc );
71 if ( sc.isSuccess() ) { incsvc->addListener(
this,
"NewRun", priority ); }
73 sc = serviceLocator()->service(
"DatabaseSvc",
m_dbsvc,
true );
76 log << MSG::ERROR <<
"Unable to find DatabaseSvc " << endmsg;
80 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true );
83 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endmsg;
87 return StatusCode::SUCCESS;
91 MsgStream log(
msgSvc(), name() );
92 log << MSG::INFO <<
"ScanEnergySvc::finalize()" << endmsg;
94 return StatusCode::SUCCESS;
98 MsgStream log(
msgSvc(), name() );
99 log << MSG::DEBUG <<
"handle: " << inc.type() << endmsg;
101 if ( inc.type() ==
"NewRun" )
103 log << MSG::DEBUG <<
"NewRun" << endmsg;
105 { log << MSG::ERROR <<
"can not initilize Tof energy Calib Constants" << endmsg; }
110 MsgStream log(
msgSvc(), name() );
111 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc,
"/Event/EventHeader" );
112 int run = eventHeader->runNumber();
114 if ( run >= 55054 && run <= 55859 )
117 cout <<
"Run in getScanEnergySvcInfo() is: " << run << endl;
122 cout <<
"This data is the MC sample with the Run Number: " << run << endl;
128 "select runStart,runEnd,Energy from ScanEnergy where runStart <= %d and runEnd >= %d ",
130 cout <<
"stmt is:" << stmt1 << endl;
132 int row_no =
m_dbsvc->query(
"offlinedb", stmt1, res );
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
140 <<
" m_RunEnd is:" << m_RunEnd << endl;
141 cout <<
"Successfully fetch ScanEnergySvc information for run: " << run << endl;
144 else if ( row_no <= 0 )
146 cout <<
" ScanEnergySvc:: can not found ScanEnergySvc information of run:" << run
DECLARE_COMPONENT(BesBdkRc)
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)
bool getScanEnergySvcInfo()
virtual StatusCode initialize()
virtual StatusCode finalize()
ScanEnergySvc(const std::string &name, ISvcLocator *svcloc)
void handle(const Incident &)