ATLAS Offline Software
Loading...
Searching...
No Matches
ISF::BaseSimulationSvc Class Reference

Concrete base class for all simulation services. More...

#include <BaseSimulationSvc.h>

Inheritance diagram for ISF::BaseSimulationSvc:
Collaboration diagram for ISF::BaseSimulationSvc:

Public Member Functions

 BaseSimulationSvc (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~BaseSimulationSvc ()
 Destructor.
virtual StatusCode sysInitialize () override
 Gaudi sysInitialize() methods.
const std::string & simSvcDescriptor () override
 Return the simulation service descriptor.
virtual StatusCode setupEvent () override
 Setup Event chain - in case of a begin-of event action is needed.
virtual StatusCode releaseEvent () override
 Release Event chain - in case of an end-of event action is needed.
virtual StatusCode setParticleBroker (IParticleBroker *broker) override
 Inform the SimulationSvc about the ParticleBroker svc.
virtual StatusCode simulateVector (const ISFParticleVector &particles, McEventCollection *mcEventCollection, McEventCollection *) override
 Simulation call for vectors of particles.
virtual StatusCode simulate (ISFParticle &isp, McEventCollection *mcEventCollection) override
 Simulation call for individual particles.
const ChronoEntity * chronoStart (const IChronoSvc::ChronoTag &tag)
 wrapper call to start chrono with given tag
const ChronoEntity * chronoStop (const IChronoSvc::ChronoTag &tag)
 wrapper call to stop chrono with given tag
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
ServiceHandle< StoreGateSvc > & evtStore ()
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
ServiceHandle< StoreGateSvc > & detStore ()
template<class T>
StatusCode retrieveTool (ToolHandle< T > &thandle)
 templated Tool retrieval - gives unique handling & look and feel
template<class T>
StatusCode retrieveTools (ToolHandleArray< T > &thandleArray)
 templated Tool retrieval - gives unique handling & look and feel
template<class T>
StatusCode recordCollection (T *&coll, const std::string &collName) const
 templated record collection method, will create a new one if not existing
template<class T>
StatusCode retrieveCollection (T *&coll, const std::string &collName, bool forceBreak=true) const
 templated retrieve collection method, boolean steers that force break

Protected Attributes

Gaudi::Property< std::string > m_simDescr
 The simulator service descriptor.
Gaudi::Property< std::string > m_screenOutputPrefix
 Screen output refinement.
ServiceHandle< IChronoStatSvc > m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
 The timing service for general usage.
IParticleBrokerm_particleBroker {}
 The particle service used to push particles into the simulation.

Private Member Functions

 BaseSimulationSvc ()
 Default constructor.

Private Attributes

ServiceHandle< StoreGateSvcm_evtStore
 Handle to StoreGate (event store by default)
ServiceHandle< StoreGateSvcm_detStore
 Handle to StoreGate (detector store by default)

Detailed Description

Concrete base class for all simulation services.

It facilitates the use of event store and detector store, provides record and retrieve methods and initializes the ChronoStatSvc.

Author
Michael.Duehrssen -at- cern.ch, Andreas.Salzburger -at- cern.ch, Elmar.Ritsch -at- cern.ch

Definition at line 40 of file BaseSimulationSvc.h.

Constructor & Destructor Documentation

◆ BaseSimulationSvc() [1/2]

ISF::BaseSimulationSvc::BaseSimulationSvc ( const std::string & name,
ISvcLocator * pSvcLocator )
inline

Definition at line 44 of file BaseSimulationSvc.h.

44 :
45 base_class(name,pSvcLocator) {};

◆ ~BaseSimulationSvc()

virtual ISF::BaseSimulationSvc::~BaseSimulationSvc ( )
inlinevirtual

Destructor.

Definition at line 48 of file BaseSimulationSvc.h.

48{};

◆ BaseSimulationSvc() [2/2]

ISF::BaseSimulationSvc::BaseSimulationSvc ( )
private

Default constructor.

Member Function Documentation

◆ chronoStart()

const ChronoEntity * ISF::BaseSimulationSvc::chronoStart ( const IChronoSvc::ChronoTag & tag)
inline

wrapper call to start chrono with given tag

Definition at line 104 of file BaseSimulationSvc.h.

104 {
105 if (m_chrono) return m_chrono->chronoStart( tag);
106 return nullptr;
107 }
ServiceHandle< IChronoStatSvc > m_chrono
The timing service for general usage.

◆ chronoStop()

const ChronoEntity * ISF::BaseSimulationSvc::chronoStop ( const IChronoSvc::ChronoTag & tag)
inline

wrapper call to stop chrono with given tag

Definition at line 110 of file BaseSimulationSvc.h.

110 {
111 if (m_chrono) return m_chrono->chronoStop( tag);
112 return nullptr;
113 }

◆ detStore() [1/2]

ServiceHandle< StoreGateSvc > & ISF::BaseSimulationSvc::detStore ( )
inline

Definition at line 125 of file BaseSimulationSvc.h.

125{return m_detStore;};
ServiceHandle< StoreGateSvc > m_detStore
Handle to StoreGate (detector store by default)

◆ detStore() [2/2]

const ServiceHandle< StoreGateSvc > & ISF::BaseSimulationSvc::detStore ( ) const
inline

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 124 of file BaseSimulationSvc.h.

124{return m_detStore;};

◆ evtStore() [1/2]

ServiceHandle< StoreGateSvc > & ISF::BaseSimulationSvc::evtStore ( )
inline

Definition at line 119 of file BaseSimulationSvc.h.

119{return m_evtStore;};
ServiceHandle< StoreGateSvc > m_evtStore
Handle to StoreGate (event store by default)

◆ evtStore() [2/2]

const ServiceHandle< StoreGateSvc > & ISF::BaseSimulationSvc::evtStore ( ) const
inline

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 118 of file BaseSimulationSvc.h.

118{return m_evtStore;};

◆ recordCollection()

template<class T>
StatusCode ISF::BaseSimulationSvc::recordCollection ( T *& coll,
const std::string & collName ) const
inline

templated record collection method, will create a new one if not existing

Definition at line 150 of file BaseSimulationSvc.h.

150 {
151 // create if necessary
152 coll = coll ? coll : new T;
153 // record
154 if (evtStore()->record( coll, collName).isFailure()){
155 ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot record collection " << collName << ". Abort." );
156 return StatusCode::FAILURE;
157 } else
158 ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully recorded collection " << collName);
159 return StatusCode::SUCCESS;
160 }
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< std::string > m_screenOutputPrefix
Screen output refinement.
const ServiceHandle< StoreGateSvc > & evtStore() const
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
unsigned long long T

◆ releaseEvent()

virtual StatusCode ISF::BaseSimulationSvc::releaseEvent ( )
inlineoverridevirtual

Release Event chain - in case of an end-of event action is needed.

Reimplemented in iGeant4::Geant4SimSvc, ISF::BaseSimulationG4Svc, ISF::DNNCaloSimSvc, and ISF::LegacySimSvc.

Definition at line 73 of file BaseSimulationSvc.h.

74 { return StatusCode::SUCCESS; }

◆ retrieveCollection()

template<class T>
StatusCode ISF::BaseSimulationSvc::retrieveCollection ( T *& coll,
const std::string & collName,
bool forceBreak = true ) const
inline

templated retrieve collection method, boolean steers that force break

Definition at line 164 of file BaseSimulationSvc.h.

164 {
165 // check for existence in the soft case
166 if (!forceBreak && !evtStore()->contains<T>(collName)) {
167 coll = 0;
168 ATH_MSG_DEBUG(m_screenOutputPrefix << "Collection does not exists (not required). Ignore.");
169 return StatusCode::SUCCESS;
170 }
171 if ( evtStore()->retrieve(coll, collName).isFailure()){
172 ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot retireve collection " << collName << ". Abort." );
173 return StatusCode::FAILURE;
174 } else
175 ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully retrieved collection " << collName);
176 return StatusCode::SUCCESS;
177 }
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114

◆ retrieveTool()

template<class T>
StatusCode ISF::BaseSimulationSvc::retrieveTool ( ToolHandle< T > & thandle)
inline

templated Tool retrieval - gives unique handling & look and feel

Definition at line 128 of file BaseSimulationSvc.h.

128 {
129 if (!thandle.empty() && thandle.retrieve().isFailure()){
130 ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot retrieve " << thandle << ". Abort.");
131 return StatusCode::FAILURE;
132 } else
133 ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully retrieved " << thandle);
134 return StatusCode::SUCCESS;
135 }

◆ retrieveTools()

template<class T>
StatusCode ISF::BaseSimulationSvc::retrieveTools ( ToolHandleArray< T > & thandleArray)
inline

templated Tool retrieval - gives unique handling & look and feel

Definition at line 139 of file BaseSimulationSvc.h.

139 {
140 if (!thandleArray.empty() && thandleArray.retrieve().isFailure()){
141 ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot retrieve " << thandleArray << ". Abort.");
142 return StatusCode::FAILURE;
143 } else
144 ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully retrieved " << thandleArray);
145 return StatusCode::SUCCESS;
146 }

◆ setParticleBroker()

virtual StatusCode ISF::BaseSimulationSvc::setParticleBroker ( IParticleBroker * broker)
inlineoverridevirtual

Inform the SimulationSvc about the ParticleBroker svc.

Definition at line 77 of file BaseSimulationSvc.h.

77 {
78 m_particleBroker = broker;
79 return StatusCode::SUCCESS;
80 }
IParticleBroker * m_particleBroker
The particle service used to push particles into the simulation.

◆ setupEvent()

virtual StatusCode ISF::BaseSimulationSvc::setupEvent ( )
inlineoverridevirtual

Setup Event chain - in case of a begin-of event action is needed.

Reimplemented in iGeant4::Geant4SimSvc, ISF::BaseSimulationG4Svc, ISF::DNNCaloSimSvc, and ISF::LegacySimSvc.

Definition at line 69 of file BaseSimulationSvc.h.

70 { return StatusCode::SUCCESS; }

◆ simSvcDescriptor()

const std::string & ISF::BaseSimulationSvc::simSvcDescriptor ( )
inlineoverride

Return the simulation service descriptor.

Definition at line 66 of file BaseSimulationSvc.h.

66{ return m_simDescr.value(); }
Gaudi::Property< std::string > m_simDescr
The simulator service descriptor.

◆ simulate()

StatusCode ISF::BaseSimulationSvc::simulate ( ISFParticle & isp,
McEventCollection * mcEventCollection )
inlineoverridevirtual

Simulation call for individual particles.

Simulation Call — hand over to the particleProcessor if it exists.

Reimplemented in ISF::BaseSimulationG4Svc, ISF::DNNCaloSimSvc, and ISF::LegacySimSvc.

Definition at line 211 of file BaseSimulationSvc.h.

212 {
213 return StatusCode::SUCCESS;
214 }

◆ simulateVector()

virtual StatusCode ISF::BaseSimulationSvc::simulateVector ( const ISFParticleVector & particles,
McEventCollection * mcEventCollection,
McEventCollection *  )
inlineoverridevirtual

Simulation call for vectors of particles.

Reimplemented in ISF::BaseSimulationG4Svc.

Definition at line 83 of file BaseSimulationSvc.h.

83 {
84 // this implementation is a wrapper in case the simulator does
85 // implement particle-vector input
86 StatusCode sc = StatusCode::SUCCESS;
87 // simulate each particle individually
88 for (ISF::ISFParticle* part : particles) {
89 ATH_MSG_VERBOSE( m_screenOutputPrefix << "Starting simulation of particle: " << part );
90 if ( this->simulate(*part, mcEventCollection).isFailure()) {
91 ATH_MSG_WARNING("Simulation of particle failed!" << endmsg <<
92 " -> simulator: " << this->simSvcDescriptor() <<
93 " -> particle : " << *part );
94 sc = StatusCode::FAILURE;
95 }
96 }
97 return sc;
98 }
#define endmsg
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static Double_t sc
virtual StatusCode simulate(ISFParticle &isp, McEventCollection *mcEventCollection) override
Simulation call for individual particles.
const std::string & simSvcDescriptor() override
Return the simulation service descriptor.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysInitialize()

virtual StatusCode ISF::BaseSimulationSvc::sysInitialize ( )
inlineoverridevirtual

Gaudi sysInitialize() methods.

Definition at line 51 of file BaseSimulationSvc.h.

52 {
53 if ( AthService::sysInitialize().isFailure() ) {
54 ATH_MSG_FATAL( m_screenOutputPrefix << " Cannot initialize AthService! Abort.");
55 return StatusCode::FAILURE;
56 }
57 if ( m_chrono.retrieve().isFailure()){
58 ATH_MSG_FATAL( m_screenOutputPrefix << " Cannot retrieve ChronoStatSvc! Abort.");
59 return StatusCode::FAILURE;
60 }
61
62 return StatusCode::SUCCESS;
63 }

Member Data Documentation

◆ m_chrono

ServiceHandle<IChronoStatSvc> ISF::BaseSimulationSvc::m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
protected

The timing service for general usage.

Definition at line 202 of file BaseSimulationSvc.h.

202{this, "ChronoStatService", "ChronoStatSvc"};

◆ m_detStore

ServiceHandle<StoreGateSvc> ISF::BaseSimulationSvc::m_detStore
private
Initial value:
{this, "DetStore", "StoreGateSvc/DetectorStore",
"Handle to a StoreGateSvc/DetectorStore instance: it will be used to retrieve data during the course of the job"}

Handle to StoreGate (detector store by default)

Definition at line 188 of file BaseSimulationSvc.h.

188 {this, "DetStore", "StoreGateSvc/DetectorStore",
189 "Handle to a StoreGateSvc/DetectorStore instance: it will be used to retrieve data during the course of the job"};

◆ m_evtStore

ServiceHandle<StoreGateSvc> ISF::BaseSimulationSvc::m_evtStore
private
Initial value:
{this, "EvtStore", "StoreGateSvc/StoreGateSvc",
"Handle to a StoreGateSvc instance: it will be used to retrieve data during the course of the job"}

Handle to StoreGate (event store by default)

Definition at line 184 of file BaseSimulationSvc.h.

184 {this, "EvtStore", "StoreGateSvc/StoreGateSvc",
185 "Handle to a StoreGateSvc instance: it will be used to retrieve data during the course of the job"};

◆ m_particleBroker

IParticleBroker* ISF::BaseSimulationSvc::m_particleBroker {}
protected

The particle service used to push particles into the simulation.

Definition at line 205 of file BaseSimulationSvc.h.

205{};

◆ m_screenOutputPrefix

Gaudi::Property<std::string> ISF::BaseSimulationSvc::m_screenOutputPrefix
protected
Initial value:
{this, "ScreenOutputPrefix", "isf >> ",
"Prefix for log output"}

Screen output refinement.

Definition at line 198 of file BaseSimulationSvc.h.

198 {this, "ScreenOutputPrefix", "isf >> ",
199 "Prefix for log output"};

◆ m_simDescr

Gaudi::Property<std::string> ISF::BaseSimulationSvc::m_simDescr
protected
Initial value:
{this, "Identifier", {},
"A unique string to identify the simulator."}

The simulator service descriptor.

Definition at line 194 of file BaseSimulationSvc.h.

194 {this, "Identifier", {},
195 "A unique string to identify the simulator."};

The documentation for this class was generated from the following file: