13#include "GaudiKernel/StatusCode.h"
14#include "GaudiKernel/SvcFactory.h"
15#include "GaudiKernel/MsgStream.h"
16#include "GaudiKernel/IIncidentSvc.h"
17#include "GaudiKernel/Incident.h"
18#include "GaudiKernel/IIncidentListener.h"
19#include "GaudiKernel/IDataProviderSvc.h"
20#include "GaudiKernel/DataSvc.h"
21#include "GaudiKernel/SmartDataPtr.h"
22#include "GaudiKernel/Service.h"
29 declareProperty(
"Run",m_run=1);
34 if ( IID_ITofSimSvc.versionMatch(riid) ) {
35 *ppvInterface =
static_cast<ITofSimSvc*
> (
this);
37 return Service::queryInterface(riid, ppvInterface) ;
39 return StatusCode::SUCCESS;
43 m_hasbeeninitialized=
false;
45 MsgStream log(
msgSvc(), name());
46 log << MSG::INFO << name() <<
": Start of run initialisation" << endreq;
48 StatusCode sc = Service::initialize();
49 if ( sc.isFailure() )
return sc;
52 sc = service(
"IncidentSvc", incsvc);
55 incsvc -> addListener(
this,
"NewRun", priority);
60 log<<MSG::INFO <<
"setProperties()" << endreq;
61 scc = service(
"CalibDataSvc", m_pSimDataSvc,
true);
62 if ( !scc.isSuccess() ) {
63 log<<MSG::ERROR<<
"Could not get IDataProviderSvc interface of SimXmlCnvSvc"<<endreq;
66 log << MSG::DEBUG<<
"Retrieved IDataProviderSvc interface of SimXmlCnvSvc"<<endreq;
69 scc = setProperties();
75 MsgStream log(
msgSvc(), name());
76 log << MSG::INFO << name() <<
": End of Run" << endreq;
77 return StatusCode::SUCCESS;
81 MsgStream log(
msgSvc(), name());
82 log << MSG::INFO << name() <<
": Destructor function of TofSimSvc" << endreq;
84 for(vector<TofConst*>::iterator it1 = fTofConst.begin(); it1 != fTofConst.end(); it1++) {
delete (*it1); }
86 for(vector<BTofSim*>::iterator it2 = fBTofSim.begin(); it2 != fBTofSim.end(); it2++) {
delete (*it2); }
88 for(vector<ETofSim*>::iterator it3 = fETofSim.begin(); it3 != fETofSim.end(); it3++) {
delete (*it3); }
94StatusCode TofSimSvc::FillfromDatabase(){
96 MsgStream log(
msgSvc(), name());
97 std::string fullPath =
"/Calib/TofSim";
98 log << MSG::INFO<<
" Tof simulation fullPath = "<<fullPath<< endreq;
99 SmartDataPtr<CalibData::TofSimData>
test(m_pSimDataSvc, fullPath);
101 log << MSG::FATAL <<
"TofSimSvc could not find TofSimData in TDS!!" << endreq;
102 return StatusCode::FAILURE;
105 for(vector<TofConst*>::iterator it1 = fTofConst.begin(); it1 != fTofConst.end(); it1++) {
delete (*it1); }
107 for(vector<BTofSim*>::iterator it2 = fBTofSim.begin(); it2 != fBTofSim.end(); it2++) {
delete (*it2); }
109 for(vector<ETofSim*>::iterator it3 = fETofSim.begin(); it3 != fETofSim.end(); it3++) {
delete (*it3); }
122 fTofConst.push_back(tofConst);
124 for(
unsigned int id=0;
id<176;
id++ ) {
130 fBTofSim.push_back(btof);
133 for(
unsigned int id=0;
id<96;
id++ ) {
138 fETofSim.push_back(etof);
141 return StatusCode::SUCCESS;
145 std::cout<<
"Now We can get the TOF Simulation Service"<<std::endl;
150 MsgStream log( messageService(), name() );
151 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
153 if ( inc.type() ==
"NewRun" ){
154 log << MSG::DEBUG <<
"New Run" << endreq;
155 StatusCode sc= FillfromDatabase();
157 m_hasbeeninitialized=
true;
164 return fTofConst[0]->getBarLowThres();
168 return fTofConst[0]->getBarHighThres();
172 return fTofConst[0]->getEndLowThres();
176 return fTofConst[0]->getEndHighThres();
180 return fTofConst[0]->getBarPMTGain();
184 return fTofConst[0]->getEndPMTGain();
188 return fTofConst[0]->getBarConstant();
192 return fTofConst[0]->getEndConstant();
196 return fTofConst[0]->getEndNoiseSwitch();
201 return fBTofSim[id]->getGain1();
204 std::cout<<
"TofSimSvc::BarGain1: bad id="<<
id<<std::endl;
211 return fBTofSim[id]->getGain2();
214 std::cout<<
"TofSimSvc::BarGain2: bad id="<<
id<<std::endl;
221 return fETofSim[id]->getGain();
224 std::cout<<
"TofSimSvc::EndGain: bad id="<<
id<<std::endl;
231 return fBTofSim[id]->getAttenLength();
234 std::cout<<
"TofSimSvc::BarAttenLength: bad id="<<
id<<std::endl;
241 return fETofSim[id]->getAttenLength();
244 std::cout<<
"TofSimSvc::EndAttenLength: bad id="<<
id<<std::endl;
251 return fETofSim[id]->getNoiseSmear();
254 std::cout<<
"TofSimSvc::EndNoiseSmear: bad id="<<
id<<std::endl;
void setAttenLength(double length)
void setGain(double gain)
void setRatio(double ratio)
void setGain(double gain)
void setNoiseSmear(double noisesmear)
void setAttenLength(double length)
void setBarPMTGain(double bg)
void setBarConstant(double bc)
void setEndConstant(double ec)
void setBarLowThres(double blth)
void setEndHighThres(double ehth)
void setEndNoiseSwitch(double eswitch)
void setEndPMTGain(double eg)
void setEndLowThres(double elth)
void setBarHighThres(double bhth)
const double EndNoiseSwitch()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
const double BarLowThres()
const double BarGain1(unsigned int id)
const double BarConstant()
virtual StatusCode initialize()
const double EndAttenLength(unsigned int id)
const double BarPMTGain()
const double EndGain(unsigned int id)
const double EndNoiseSmear(unsigned int id)
void handle(const Incident &)
TofSimSvc(const std::string &name, ISvcLocator *svcloc)
const double EndConstant()
const double BarAttenLength(unsigned int id)
const double EndPMTGain()
const double EndHighThres()
virtual StatusCode finalize()
const double EndLowThres()
const double BarHighThres()
const double BarGain2(unsigned int id)