ATLAS Offline Software
Loading...
Searching...
No Matches
ISF::BaseSimulationG4Svc Class Referenceabstract

Base class for an ISimulatorSvc which requires a Geant4 UserInfo object. More...

#include <BaseSimulationG4Svc.h>

Inheritance diagram for ISF::BaseSimulationG4Svc:
Collaboration diagram for ISF::BaseSimulationG4Svc:

Public Member Functions

virtual ~BaseSimulationG4Svc ()=default
 Destructor.
virtual StatusCode simulate (ISFParticle &, McEventCollection *, std::shared_ptr< HitCollectionMap >)=0
 Simulation call for individual particles.
virtual StatusCode setupEvent (HitCollectionMap &)=0
 Setup Event chain - in case of a begin-of event action is needed.
virtual StatusCode releaseEvent (HitCollectionMap &)=0
 Release Event chain - in case of an end-of event action is needed.
virtual StatusCode simulateVector (const ISFParticleVector &particles, McEventCollection *mcEventCollection, std::shared_ptr< HitCollectionMap > hitCollections, McEventCollection *)
 Simulation call for vectors of particles.
virtual StatusCode simulate (ISFParticle &, McEventCollection *) override
 Simulation call for individual particles.
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 simulateVector (const ISFParticleVector &, McEventCollection *, McEventCollection *) override
 Simulation call for vectors of particles.
 BaseSimulationSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Standard BaseSimulationSvc constructor.
virtual StatusCode sysInitialize () override
 Gaudi sysInitialize() methods.
const std::string & simSvcDescriptor () override
 Return the simulation service descriptor.
virtual StatusCode setParticleBroker (IParticleBroker *broker) override
 Inform the SimulationSvc about the ParticleBroker svc.
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 Attributes

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

Detailed Description

Base class for an ISimulatorSvc which requires a Geant4 UserInfo object.

Definition at line 33 of file BaseSimulationG4Svc.h.

Constructor & Destructor Documentation

◆ ~BaseSimulationG4Svc()

virtual ISF::BaseSimulationG4Svc::~BaseSimulationG4Svc ( )
virtualdefault

Destructor.

Member Function Documentation

◆ BaseSimulationSvc()

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

Standard BaseSimulationSvc constructor.

Definition at line 45 of file BaseSimulationSvc.h.

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

◆ chronoStart()

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

wrapper call to start chrono with given tag

Definition at line 105 of file BaseSimulationSvc.h.

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

◆ chronoStop()

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

wrapper call to stop chrono with given tag

Definition at line 111 of file BaseSimulationSvc.h.

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

◆ detStore() [1/2]

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

Definition at line 126 of file BaseSimulationSvc.h.

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

◆ detStore() [2/2]

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

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

Definition at line 125 of file BaseSimulationSvc.h.

125{return m_detStore;};

◆ evtStore() [1/2]

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

Definition at line 120 of file BaseSimulationSvc.h.

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

◆ evtStore() [2/2]

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

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

Definition at line 119 of file BaseSimulationSvc.h.

119{return m_evtStore;};

◆ recordCollection()

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

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

Definition at line 151 of file BaseSimulationSvc.h.

151 {
152 // create if necessary
153 coll = coll ? coll : new T;
154 // record
155 if (evtStore()->record( coll, collName).isFailure()){
156 ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot record collection " << collName << ". Abort." );
157 return StatusCode::FAILURE;
158 } else
159 ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully recorded collection " << collName);
160 return StatusCode::SUCCESS;
161 }
#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() [1/2]

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

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

Reimplemented from ISF::BaseSimulationSvc.

Reimplemented in iGeant4::Geant4SimSvc.

Definition at line 85 of file BaseSimulationG4Svc.h.

85{ return StatusCode::FAILURE; }

◆ releaseEvent() [2/2]

virtual StatusCode ISF::BaseSimulationG4Svc::releaseEvent ( HitCollectionMap & )
pure virtual

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

Implemented in iGeant4::Geant4SimSvc.

◆ retrieveCollection()

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

templated retrieve collection method, boolean steers that force break

Definition at line 165 of file BaseSimulationSvc.h.

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

◆ retrieveTool()

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

templated Tool retrieval - gives unique handling & look and feel

Definition at line 129 of file BaseSimulationSvc.h.

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

◆ retrieveTools()

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

templated Tool retrieval - gives unique handling & look and feel

Definition at line 140 of file BaseSimulationSvc.h.

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

◆ setParticleBroker()

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

Inform the SimulationSvc about the ParticleBroker svc.

Definition at line 78 of file BaseSimulationSvc.h.

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

◆ setupEvent() [1/2]

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

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

Reimplemented from ISF::BaseSimulationSvc.

Reimplemented in iGeant4::Geant4SimSvc.

Definition at line 82 of file BaseSimulationG4Svc.h.

82{ return StatusCode::FAILURE; }

◆ setupEvent() [2/2]

virtual StatusCode ISF::BaseSimulationG4Svc::setupEvent ( HitCollectionMap & )
pure virtual

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

Implemented in iGeant4::Geant4SimSvc.

◆ simSvcDescriptor()

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

Return the simulation service descriptor.

Definition at line 67 of file BaseSimulationSvc.h.

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

◆ simulate() [1/2]

virtual StatusCode ISF::BaseSimulationG4Svc::simulate ( ISFParticle & ,
McEventCollection *  )
inlineoverridevirtual

Simulation call for individual particles.

Reimplemented from ISF::BaseSimulationSvc.

Definition at line 77 of file BaseSimulationG4Svc.h.

77 {
78 return StatusCode::FAILURE;
79 }

◆ simulate() [2/2]

virtual StatusCode ISF::BaseSimulationG4Svc::simulate ( ISFParticle & ,
McEventCollection * ,
std::shared_ptr< HitCollectionMap >  )
pure virtual

Simulation call for individual particles.

Implemented in iGeant4::Geant4SimSvc.

◆ simulateVector() [1/2]

virtual StatusCode ISF::BaseSimulationG4Svc::simulateVector ( const ISFParticleVector & ,
McEventCollection * ,
McEventCollection *  )
inlineoverridevirtual

Simulation call for vectors of particles.

Reimplemented from ISF::BaseSimulationSvc.

Definition at line 88 of file BaseSimulationG4Svc.h.

90 {
91 return StatusCode::FAILURE;
92 }

◆ simulateVector() [2/2]

virtual StatusCode ISF::BaseSimulationG4Svc::simulateVector ( const ISFParticleVector & particles,
McEventCollection * mcEventCollection,
std::shared_ptr< HitCollectionMap > hitCollections,
McEventCollection *  )
inlinevirtual

Simulation call for vectors of particles.

Reimplemented in iGeant4::Geant4SimSvc.

Definition at line 52 of file BaseSimulationG4Svc.h.

55 {
56 // this implementation is a wrapper in case the simulator does
57 // implement particle-vector input
58 StatusCode sc = StatusCode::SUCCESS;
59 // simulate each particle individually
60 for (ISF::ISFParticle* part : particles) {
62 << "Starting simulation of particle: " << part);
63 if (this->simulate(*part, mcEventCollection, hitCollections).isFailure()) {
64 ATH_MSG_WARNING("Simulation of particle failed!"
65 << endmsg
66 << " -> simulator: " << this->simSvcDescriptor()
67 << " -> particle : " << *part);
68 sc = StatusCode::FAILURE;
69 }
70 }
71 return sc;
72 }
#define endmsg
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static Double_t sc
virtual StatusCode simulate(ISFParticle &, McEventCollection *, std::shared_ptr< HitCollectionMap >)=0
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 ( )
inlineoverridevirtualinherited

Gaudi sysInitialize() methods.

Definition at line 52 of file BaseSimulationSvc.h.

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

Member Data Documentation

◆ m_chrono

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

The timing service for general usage.

Definition at line 203 of file BaseSimulationSvc.h.

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

◆ m_detStore

ServiceHandle<StoreGateSvc> ISF::BaseSimulationSvc::m_detStore
privateinherited
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 189 of file BaseSimulationSvc.h.

189 {this, "DetStore", "StoreGateSvc/DetectorStore",
190 "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
privateinherited
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 185 of file BaseSimulationSvc.h.

185 {this, "EvtStore", "StoreGateSvc/StoreGateSvc",
186 "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 {}
protectedinherited

The particle service used to push particles into the simulation.

Definition at line 206 of file BaseSimulationSvc.h.

206{};

◆ m_screenOutputPrefix

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

Screen output refinement.

Definition at line 199 of file BaseSimulationSvc.h.

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

◆ m_simDescr

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

The simulator service descriptor.

Definition at line 195 of file BaseSimulationSvc.h.

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

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