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"
30 declareProperty(
"Run",m_run=1);
44 m_hasbeeninitialized=
false;
46 MsgStream log(
msgSvc(), name());
47 log << MSG::INFO << name() <<
": Start of run initialisation" << endreq;
49 StatusCode sc = Service::initialize();
50 if ( sc.isFailure() )
return sc;
53 sc = service(
"IncidentSvc", incsvc);
56 incsvc -> addListener(
this,
"NewRun", priority);
61 log<<MSG::INFO <<
"setProperties()" << endreq;
62 scc = service(
"CalibDataSvc", m_pSimDataSvc,
true);
63 if ( !scc.isSuccess() ) {
64 log<<MSG::ERROR<<
"Could not get IDataProviderSvc interface of SimXmlCnvSvc"<<endreq;
67 log << MSG::DEBUG<<
"Retrieved IDataProviderSvc interface of SimXmlCnvSvc"<<endreq;
70 scc = setProperties();
76 MsgStream log(
msgSvc(), name());
77 log << MSG::INFO << name() <<
": End of Run" << endreq;
78 return StatusCode::SUCCESS;
82 MsgStream log(
msgSvc(), name());
83 log << MSG::INFO << name() <<
": Destructor function of TofSimSvc" << endreq;
85 for(vector<TofConst*>::iterator it1 = fTofConst.begin(); it1 != fTofConst.end(); it1++) {
delete (*it1); }
87 for(vector<BTofSim*>::iterator it2 = fBTofSim.begin(); it2 != fBTofSim.end(); it2++) {
delete (*it2); }
89 for(vector<ETofSim*>::iterator it3 = fETofSim.begin(); it3 != fETofSim.end(); it3++) {
delete (*it3); }
95StatusCode TofSimSvc::FillfromDatabase(){
97 MsgStream log(
msgSvc(), name());
98 std::string fullPath =
"/Calib/TofSim";
99 log << MSG::INFO<<
" Tof simulation fullPath = "<<fullPath<< endreq;
100 SmartDataPtr<CalibData::TofSimData>
test(m_pSimDataSvc, fullPath);
102 log << MSG::FATAL <<
"TofSimSvc could not find TofSimData in TDS!!" << endreq;
103 return StatusCode::FAILURE;
106 for(vector<TofConst*>::iterator it1 = fTofConst.begin(); it1 != fTofConst.end(); it1++) {
delete (*it1); }
108 for(vector<BTofSim*>::iterator it2 = fBTofSim.begin(); it2 != fBTofSim.end(); it2++) {
delete (*it2); }
110 for(vector<ETofSim*>::iterator it3 = fETofSim.begin(); it3 != fETofSim.end(); it3++) {
delete (*it3); }
123 fTofConst.push_back(tofConst);
125 for(
unsigned int id=0;
id<176;
id++ ) {
131 fBTofSim.push_back(btof);
134 for(
unsigned int id=0;
id<96;
id++ ) {
139 fETofSim.push_back(etof);
142 return StatusCode::SUCCESS;
146 std::cout<<
"Now We can get the TOF Simulation Service"<<std::endl;
151 MsgStream log( messageService(), name() );
152 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
154 if ( inc.type() ==
"NewRun" ){
155 log << MSG::DEBUG <<
"New Run" << endreq;
156 StatusCode sc= FillfromDatabase();
158 m_hasbeeninitialized=
true;
165 return fTofConst[0]->getBarLowThres();
169 return fTofConst[0]->getBarHighThres();
173 return fTofConst[0]->getEndLowThres();
177 return fTofConst[0]->getEndHighThres();
181 return fTofConst[0]->getBarPMTGain();
185 return fTofConst[0]->getEndPMTGain();
189 return fTofConst[0]->getBarConstant();
193 return fTofConst[0]->getEndConstant();
197 return fTofConst[0]->getEndNoiseSwitch();
202 return fBTofSim[id]->getGain1();
205 std::cout<<
"TofSimSvc::BarGain1: bad id="<<
id<<std::endl;
212 return fBTofSim[id]->getGain2();
215 std::cout<<
"TofSimSvc::BarGain2: bad id="<<
id<<std::endl;
222 return fETofSim[id]->getGain();
225 std::cout<<
"TofSimSvc::EndGain: bad id="<<
id<<std::endl;
232 return fBTofSim[id]->getAttenLength();
235 std::cout<<
"TofSimSvc::BarAttenLength: bad id="<<
id<<std::endl;
242 return fETofSim[id]->getAttenLength();
245 std::cout<<
"TofSimSvc::EndAttenLength: bad id="<<
id<<std::endl;
252 return fETofSim[id]->getNoiseSmear();
255 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()
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 &)
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)