2#include "GaudiKernel/Kernel.h"
3#include "GaudiKernel/IInterface.h"
4#include "GaudiKernel/StatusCode.h"
5#include "GaudiKernel/SvcFactory.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/SmartDataPtr.h"
8#include "GaudiKernel/DataSvc.h"
10#include "GaudiKernel/IIncidentSvc.h"
11#include "GaudiKernel/Incident.h"
12#include "GaudiKernel/IIncidentListener.h"
15#include "CLHEP/Vector/ThreeVector.h"
29using CLHEP::Hep3Vector;
33 Service (name, svcloc) {
40 if( IID_IDedxSimSvc.versionMatch(riid) ){
43 return Service::queryInterface(riid, ppvInterface);
45 return StatusCode::SUCCESS;
49 MsgStream log(messageService(), name());
50 log << MSG::INFO << name() <<
"DedxSimSvc::initialize()" << endreq;
52 StatusCode sc = Service::initialize();
53 if( sc.isFailure() )
return sc;
56 sc = service(
"IncidentSvc", incsvc);
59 incsvc -> addListener(
this,
"NewRun", priority);
61 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
62 if (sc .isFailure() ) {
63 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
73 m_dedx_hists =
nullptr;
75 return StatusCode::SUCCESS;
79 MsgStream log(messageService(), name());
80 log << MSG::INFO << name() <<
"DedxSimSvc::finalize()" << endreq;
81 return StatusCode::SUCCESS;
85 MsgStream log( messageService(), name() );
86 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
88 if ( inc.type() ==
"NewRun" ){
89 log << MSG::DEBUG <<
"New Run" << endreq;
90 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,
"/Event/EventHeader");
93 runNo = evt -> runNumber();
94 log << MSG::DEBUG <<
"The runNumber of current event is "<<
runNo<<endreq;
97 log << MSG::ERROR <<
"ERROR accessing Event" <<endreq;
99 if(runNo<m_runfrom || runNo>m_runto){
107DedxSimSvc::update_param_svc() {
108 MsgStream log(messageService(), name());
109 IDataProviderSvc* pCalibDataSvc;
110 StatusCode sc = service(
"CalibDataSvc", pCalibDataSvc,
true);
111 if ( !sc.isSuccess() ) {
113 <<
"Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
118 <<
"Retrieved IDataProviderSvc interface of CalibXmlCnvSvc"
122 std::string fullPath =
"/Calib/DedxSim";
124 m_calibDataSvc =
dynamic_cast<CalibDataSvc*
>(pCalibDataSvc);
125 SmartDataPtr<CalibData::DedxSimData> pDedxSimData(m_calibDataSvc, fullPath);
126 m_runfrom = pDedxSimData->getrunfrm();
127 m_runto = pDedxSimData->getrunto();
128 m_version = pDedxSimData->getVersion();
129 m_numDedxHists = pDedxSimData->gethistNo();
130 m_numBg = pDedxSimData->getRangeNo();
131 if (m_version == 0) m_numTheta = 10;
132 else m_numTheta = pDedxSimData->getThetaNo();
133 m_dedx_hists = pDedxSimData->getHist();
134 m_bgRange = pDedxSimData->getRange();
135 log << MSG::DEBUG <<
"DedxSimSvc::update_param_svc() finish" << endreq;
virtual StatusCode finalize()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
DedxSimSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode initialize()
void handle(const Incident &)