ATLAS Offline Software
Public Types | 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 Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Public Member Functions

 BaseSimulationSvc (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~BaseSimulationSvc ()
 Destructor. More...
 
virtual StatusCode sysInitialize () override
 Gaudi sysInitialize() methods. More...
 
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 StoreGateSvc_tevtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
StoreGateSvc_tevtStore ()
 
const StoreGateSvc_tdetStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
StoreGateSvc_tdetStore ()
 
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

std::string m_simDescr {""}
 The simulator service descriptor. More...
 
std::string m_screenOutputPrefix {"isf >> "}
 Screen output refinement - can be changed by declareProperty() More...
 
std::string m_chronoSvcName {"ChronoStatSvc"}
 Name of the timing service - can be set by declareProperty() More...
 
IChronoStatSvc * m_chrono {}
 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

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer 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 40 of file BaseSimulationSvc.h.

Member Typedef Documentation

◆ StoreGateSvc_t

Definition at line 135 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),
46  m_evtStore( "StoreGateSvc/StoreGateSvc", name ),
47  m_detStore( "StoreGateSvc/DetectorStore", name )
48  {
49  // to be set to a unique descriptor
50  declareProperty( "Identifier",
51  m_simDescr,
52  "A unique string to identify the simulator.");
53 
54  declareProperty( "EvtStore",
55  m_evtStore = StoreGateSvc_t ("StoreGateSvc", name),
56  "Handle to a StoreGateSvc instance: it will be used to retrieve data during the course of the job" );
57  declareProperty( "DetStore",
58  m_detStore = StoreGateSvc_t ("StoreGateSvc/DetectorStore", name),
59  "Handle to a StoreGateSvc/DetectorStore instance: it will be used to retrieve data during the course of the job" );
60  // refine the screen output for debugging
61  declareProperty("ScreenOutputPrefix", m_screenOutputPrefix);
62  // Service handling
63  declareProperty("ChronoStatService", m_chronoSvcName );
64 
65  };

◆ ~BaseSimulationSvc()

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

Destructor.

Definition at line 68 of file BaseSimulationSvc.h.

68 {};

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

124  {
125  if (m_chrono) return m_chrono->chronoStart( tag);
126  return nullptr;
127  }

◆ chronoStop()

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

wrapper call to stop chrono with given tag

Definition at line 130 of file BaseSimulationSvc.h.

130  {
131  if (m_chrono) return m_chrono->chronoStop( tag);
132  return nullptr;
133  }

◆ detStore() [1/2]

StoreGateSvc_t& ISF::BaseSimulationSvc::detStore ( )
inline

Definition at line 147 of file BaseSimulationSvc.h.

147 {return m_detStore;};

◆ detStore() [2/2]

const StoreGateSvc_t& ISF::BaseSimulationSvc::detStore ( ) const
inline

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

Definition at line 146 of file BaseSimulationSvc.h.

146 {return m_detStore;};

◆ evtStore() [1/2]

StoreGateSvc_t& ISF::BaseSimulationSvc::evtStore ( )
inline

Definition at line 141 of file BaseSimulationSvc.h.

141 {return m_evtStore;};

◆ evtStore() [2/2]

const StoreGateSvc_t& ISF::BaseSimulationSvc::evtStore ( ) const
inline

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

Definition at line 140 of file BaseSimulationSvc.h.

140 {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 172 of file BaseSimulationSvc.h.

172  {
173  // create if necessary
174  coll = coll ? coll : new T;
175  // record
176  if (evtStore()->record( coll, collName).isFailure()){
177  ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot record collection " << collName << ". Abort." );
178  return StatusCode::FAILURE;
179  } else
180  ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully recorded collection " << collName);
181  return StatusCode::SUCCESS;
182  }

◆ releaseEvent()

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

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

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

Definition at line 93 of file BaseSimulationSvc.h.

94  { 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 186 of file BaseSimulationSvc.h.

186  {
187  // check for existence in the soft case
188  if (!forceBreak && !evtStore()->contains<T>(collName)) {
189  coll = 0;
190  ATH_MSG_DEBUG(m_screenOutputPrefix << "Collection does not exists (not required). Ignore.");
191  return StatusCode::SUCCESS;
192  }
193  if ( evtStore()->retrieve(coll, collName).isFailure()){
194  ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot retireve collection " << collName << ". Abort." );
195  return StatusCode::FAILURE;
196  } else
197  ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully retrieved collection " << collName);
198  return StatusCode::SUCCESS;
199  }

◆ retrieveTool()

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

templated Tool retrieval - gives unique handling & look and feel

Definition at line 150 of file BaseSimulationSvc.h.

150  {
151  if (!thandle.empty() && thandle.retrieve().isFailure()){
152  ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot retrieve " << thandle << ". Abort.");
153  return StatusCode::FAILURE;
154  } else
155  ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully retrieved " << thandle);
156  return StatusCode::SUCCESS;
157  }

◆ retrieveTools()

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

templated Tool retrieval - gives unique handling & look and feel

Definition at line 161 of file BaseSimulationSvc.h.

161  {
162  if (!thandleArray.empty() && thandleArray.retrieve().isFailure()){
163  ATH_MSG_FATAL( m_screenOutputPrefix << "Cannot retrieve " << thandleArray << ". Abort.");
164  return StatusCode::FAILURE;
165  } else
166  ATH_MSG_DEBUG(m_screenOutputPrefix << "Successfully retrieved " << thandleArray);
167  return StatusCode::SUCCESS;
168  }

◆ setParticleBroker()

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

Inform the SimulationSvc about the ParticleBroker svc.

Definition at line 97 of file BaseSimulationSvc.h.

97  {
98  m_particleBroker = broker;
99  return StatusCode::SUCCESS;
100  }

◆ setupEvent()

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

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

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

Definition at line 89 of file BaseSimulationSvc.h.

90  { return StatusCode::SUCCESS; }

◆ simSvcDescriptor()

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

Return the simulation service descriptor.

Definition at line 86 of file BaseSimulationSvc.h.

86 { return m_simDescr; }

◆ 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 iGeant4::Geant4SimSvc.

Definition at line 232 of file BaseSimulationSvc.h.

233  {
234  return StatusCode::SUCCESS;
235  }

◆ simulateVector()

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

Simulation call for vectors of particles.

Reimplemented in iGeant4::Geant4SimSvc.

Definition at line 103 of file BaseSimulationSvc.h.

103  {
104  // this implementation is a wrapper in case the simulator does
105  // implement particle-vector input
106  bool success = true;
107  // simulate each particle individually
108  for (ISF::ISFParticle* part : particles) {
109  ATH_MSG_VERBOSE( m_screenOutputPrefix << "Starting simulation of particle: " << part );
110  if ( this->simulate(*part, mcEventCollection).isFailure()) {
111  ATH_MSG_WARNING("Simulation of particle failed!" << endmsg <<
112  " -> simulator: " << this->simSvcDescriptor() <<
113  " -> particle : " << *part );
114  success = false;
115  }
116  }
117  return ( success ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
118  }

◆ sysInitialize()

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

Gaudi sysInitialize() methods.

Definition at line 71 of file BaseSimulationSvc.h.

72  {
73  if ( AthService::sysInitialize().isFailure() ) {
74  ATH_MSG_FATAL( m_screenOutputPrefix << " Cannot initialize AthService! Abort.");
75  return StatusCode::FAILURE;
76  }
77  if ( serviceLocator()->service(m_chronoSvcName, m_chrono ).isFailure()){
78  ATH_MSG_FATAL( m_screenOutputPrefix << " Cannot retrieve ChronoStatSvc! Abort.");
79  return StatusCode::FAILURE;
80  }
81 
82  return StatusCode::SUCCESS;
83  }

Member Data Documentation

◆ m_chrono

IChronoStatSvc* ISF::BaseSimulationSvc::m_chrono {}
protected

The timing service for general usage.

Definition at line 223 of file BaseSimulationSvc.h.

◆ m_chronoSvcName

std::string ISF::BaseSimulationSvc::m_chronoSvcName {"ChronoStatSvc"}
protected

Name of the timing service - can be set by declareProperty()

Definition at line 220 of file BaseSimulationSvc.h.

◆ m_detStore

StoreGateSvc_t ISF::BaseSimulationSvc::m_detStore
private

Pointer to StoreGate (detector store by default)

Definition at line 209 of file BaseSimulationSvc.h.

◆ m_evtStore

StoreGateSvc_t ISF::BaseSimulationSvc::m_evtStore
private

Pointer to StoreGate (event store by default)

Definition at line 206 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 226 of file BaseSimulationSvc.h.

◆ m_screenOutputPrefix

std::string ISF::BaseSimulationSvc::m_screenOutputPrefix {"isf >> "}
protected

Screen output refinement - can be changed by declareProperty()

Definition at line 217 of file BaseSimulationSvc.h.

◆ m_simDescr

std::string ISF::BaseSimulationSvc::m_simDescr {""}
protected

The simulator service descriptor.

Definition at line 214 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
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ISF::BaseSimulationSvc::simSvcDescriptor
std::string & simSvcDescriptor() override
Return the simulation service descriptor.
Definition: BaseSimulationSvc.h:86
ISF::BaseSimulationSvc::evtStore
const StoreGateSvc_t & evtStore() const
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: BaseSimulationSvc.h:140
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:232
ISF::BaseSimulationSvc::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: BaseSimulationSvc.h:206
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ISF::BaseSimulationSvc::m_simDescr
std::string m_simDescr
The simulator service descriptor.
Definition: BaseSimulationSvc.h:214
ISF::BaseSimulationSvc::m_screenOutputPrefix
std::string m_screenOutputPrefix
Screen output refinement - can be changed by declareProperty()
Definition: BaseSimulationSvc.h:217
ISF::BaseSimulationSvc::m_chronoSvcName
std::string m_chronoSvcName
Name of the timing service - can be set by declareProperty()
Definition: BaseSimulationSvc.h:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ISF::BaseSimulationSvc::m_chrono
IChronoStatSvc * m_chrono
The timing service for general usage.
Definition: BaseSimulationSvc.h:223
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
ISF::BaseSimulationSvc::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: BaseSimulationSvc.h:209
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
ISF::BaseSimulationSvc::m_particleBroker
IParticleBroker * m_particleBroker
The particle service used to push particles into the simulation.
Definition: BaseSimulationSvc.h:226
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ServiceHandle< StoreGateSvc >