ATLAS Offline Software
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ISF::BaseSimulationSvc Class Reference

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

Protected Attributes

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

Private Member Functions

 BaseSimulationSvc ()
 Default constructor. More...
 

Private Attributes

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

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 41 of file BaseSimulationSvc.h.

Constructor & Destructor Documentation

◆ BaseSimulationSvc() [1/2]

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

Definition at line 45 of file BaseSimulationSvc.h.

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

◆ ~BaseSimulationSvc()

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

Destructor.

Definition at line 49 of file BaseSimulationSvc.h.

49 {};

◆ 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 105 of file BaseSimulationSvc.h.

105  {
106  if (m_chrono) return m_chrono->chronoStart( tag);
107  return nullptr;
108  }

◆ chronoStop()

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

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 ( )
inline

Definition at line 126 of file BaseSimulationSvc.h.

126 {return m_detStore;};

◆ 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 125 of file BaseSimulationSvc.h.

125 {return m_detStore;};

◆ evtStore() [1/2]

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

Definition at line 120 of file BaseSimulationSvc.h.

120 {return m_evtStore;};

◆ 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 119 of file BaseSimulationSvc.h.

119 {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 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  }

◆ releaseEvent()

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

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

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

Definition at line 74 of file BaseSimulationSvc.h.

75  { 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 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  }

◆ retrieveTool()

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

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)
inline

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)
inlineoverridevirtual

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  }

◆ setupEvent()

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

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

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

Definition at line 70 of file BaseSimulationSvc.h.

71  { return StatusCode::SUCCESS; }

◆ simSvcDescriptor()

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

Return the simulation service descriptor.

Definition at line 67 of file BaseSimulationSvc.h.

67 { return m_simDescr.value(); }

◆ 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::LegacySimSvc, ISF::DNNCaloSimSvc, and ISF::BaseSimulationG4Svc.

Definition at line 212 of file BaseSimulationSvc.h.

213  {
214  return StatusCode::SUCCESS;
215  }

◆ 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 84 of file BaseSimulationSvc.h.

84  {
85  // this implementation is a wrapper in case the simulator does
86  // implement particle-vector input
87  StatusCode sc = StatusCode::SUCCESS;
88  // simulate each particle individually
90  ATH_MSG_VERBOSE( m_screenOutputPrefix << "Starting simulation of particle: " << part );
91  if ( this->simulate(*part, mcEventCollection).isFailure()) {
92  ATH_MSG_WARNING("Simulation of particle failed!" << endmsg <<
93  " -> simulator: " << this->simSvcDescriptor() <<
94  " -> particle : " << *part );
95  sc = StatusCode::FAILURE;
96  }
97  }
98  return sc;
99  }

◆ sysInitialize()

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

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"}
protected

The timing service for general usage.

Definition at line 203 of file BaseSimulationSvc.h.

◆ 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 189 of file BaseSimulationSvc.h.

◆ 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 185 of file BaseSimulationSvc.h.

◆ m_particleBroker

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

The particle service used to push particles into the simulation.

Definition at line 206 of file BaseSimulationSvc.h.

◆ 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 199 of file BaseSimulationSvc.h.

◆ 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 195 of file BaseSimulationSvc.h.


The documentation for this class was generated from the following file:
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ISF::BaseSimulationSvc::m_simDescr
Gaudi::Property< std::string > m_simDescr
The simulator service descriptor.
Definition: BaseSimulationSvc.h:195
ISF::BaseSimulationSvc::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
The timing service for general usage.
Definition: BaseSimulationSvc.h:203
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ISF::ISFParticle
Definition: ISFParticle.h:42
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::BaseSimulationSvc::simulate
virtual StatusCode simulate(ISFParticle &isp, McEventCollection *mcEventCollection) override
Simulation call for individual particles.
Definition: BaseSimulationSvc.h:212
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ISF::BaseSimulationSvc::evtStore
const ServiceHandle< StoreGateSvc > & evtStore() const
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: BaseSimulationSvc.h:119
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ISF::BaseSimulationSvc::m_screenOutputPrefix
Gaudi::Property< std::string > m_screenOutputPrefix
Screen output refinement.
Definition: BaseSimulationSvc.h:199
ISF::BaseSimulationSvc::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Handle to StoreGate (detector store by default)
Definition: BaseSimulationSvc.h:189
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ISF::BaseSimulationSvc::simSvcDescriptor
const std::string & simSvcDescriptor() override
Return the simulation service descriptor.
Definition: BaseSimulationSvc.h:67
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ISF::BaseSimulationSvc::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
Handle to StoreGate (event store by default)
Definition: BaseSimulationSvc.h:185
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
ISF::BaseSimulationSvc::m_particleBroker
IParticleBroker * m_particleBroker
The particle service used to push particles into the simulation.
Definition: BaseSimulationSvc.h:206
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35