13#include "GaudiKernel/DataSvc.h"
14#include "GaudiKernel/IDataProviderSvc.h"
15#include "GaudiKernel/IIncidentListener.h"
16#include "GaudiKernel/IIncidentSvc.h"
17#include "GaudiKernel/Incident.h"
18#include "GaudiKernel/MsgStream.h"
19#include "GaudiKernel/Service.h"
20#include "GaudiKernel/SmartDataPtr.h"
21#include "GaudiKernel/StatusCode.h"
23#include "CalibData/Tof/TofSimData.h"
30 : base_class( name, svcloc ) {
31 declareProperty(
"Run", m_run = 1 );
45 m_hasbeeninitialized =
false;
47 MsgStream log(
msgSvc(), name() );
48 log << MSG::INFO << name() <<
": Start of run initialisation" << endmsg;
50 StatusCode sc = Service::initialize();
51 if ( sc.isFailure() )
return sc;
54 sc = service(
"IncidentSvc", incsvc );
56 if ( sc.isSuccess() ) { incsvc->addListener(
this,
"NewRun", priority ); }
60 log << MSG::INFO <<
"setProperties()" << endmsg;
61 scc = service(
"CalibDataSvc", m_pSimDataSvc,
true );
62 if ( !scc.isSuccess() )
64 log << MSG::ERROR <<
"Could not get IDataProviderSvc interface of SimXmlCnvSvc" << endmsg;
68 { log << MSG::DEBUG <<
"Retrieved IDataProviderSvc interface of SimXmlCnvSvc" << endmsg; }
76 MsgStream log(
msgSvc(), name() );
77 log << MSG::INFO << name() <<
": End of Run" << endmsg;
78 return StatusCode::SUCCESS;
82 MsgStream log(
msgSvc(), name() );
83 log << MSG::INFO << name() <<
": Destructor function of TofSimSvc" << endmsg;
85 for ( vector<TofConst*>::iterator it1 = fTofConst.begin(); it1 != fTofConst.end(); it1++ )
88 for ( vector<BTofSim*>::iterator it2 = fBTofSim.begin(); it2 != fBTofSim.end(); it2++ )
91 for ( vector<ETofSim*>::iterator it3 = fETofSim.begin(); it3 != fETofSim.end(); it3++ )
98StatusCode TofSimSvc::FillfromDatabase() {
100 MsgStream log(
msgSvc(), name() );
101 std::string fullPath =
"/Calib/TofSim";
102 log << MSG::INFO <<
" Tof simulation fullPath = " << fullPath << endmsg;
103 SmartDataPtr<CalibData::TofSimData>
test( m_pSimDataSvc, fullPath );
106 log << MSG::FATAL <<
"TofSimSvc could not find TofSimData in TDS!!" << endmsg;
107 return StatusCode::FAILURE;
110 for ( vector<TofConst*>::iterator it1 = fTofConst.begin(); it1 != fTofConst.end(); it1++ )
113 for ( vector<BTofSim*>::iterator it2 = fBTofSim.begin(); it2 != fBTofSim.end(); it2++ )
116 for ( vector<ETofSim*>::iterator it3 = fETofSim.begin(); it3 != fETofSim.end(); it3++ )
120 TofConst* tofConst =
new TofConst;
130 fTofConst.push_back( tofConst );
132 for (
unsigned int id = 0;
id < 176;
id++ )
135 BTofSim* btof =
new BTofSim;
139 fBTofSim.push_back( btof );
142 for (
unsigned int id = 0;
id < 96;
id++ )
144 ETofSim* etof =
new ETofSim;
148 fETofSim.push_back( etof );
151 return StatusCode::SUCCESS;
155 std::cout <<
"Now We can get the TOF Simulation Service" << std::endl;
160 MsgStream log(
msgSvc(), name() );
161 log << MSG::DEBUG <<
"handle: " << inc.type() << endmsg;
163 if ( inc.type() ==
"NewRun" )
165 log << MSG::DEBUG <<
"New Run" << endmsg;
166 StatusCode sc = FillfromDatabase();
167 if ( sc.isSuccess() ) { m_hasbeeninitialized =
true; }
191 if (
id < 176 ) {
return fBTofSim[id]->getGain1(); }
194 std::cout <<
"TofSimSvc::BarGain1: bad id=" <<
id << std::endl;
200 if (
id < 176 ) {
return fBTofSim[id]->getGain2(); }
203 std::cout <<
"TofSimSvc::BarGain2: bad id=" <<
id << std::endl;
209 if (
id < 96 ) {
return fETofSim[id]->getGain(); }
212 std::cout <<
"TofSimSvc::EndGain: bad id=" <<
id << std::endl;
218 if (
id < 176 ) {
return fBTofSim[id]->getAttenLength(); }
221 std::cout <<
"TofSimSvc::BarAttenLength: bad id=" <<
id << std::endl;
227 if (
id < 96 ) {
return fETofSim[id]->getAttenLength(); }
230 std::cout <<
"TofSimSvc::EndAttenLength: bad id=" <<
id << std::endl;
236 if (
id < 96 ) {
return fETofSim[id]->getNoiseSmear(); }
239 std::cout <<
"TofSimSvc::EndNoiseSmear: bad id=" <<
id << std::endl;
DECLARE_COMPONENT(BesBdkRc)
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 &)
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)