ATLAS Offline Software
BaseSimulatorTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ISF_INTERFACES_BASESIMULATORTOOL_H
6 #define ISF_INTERFACES_BASESIMULATORTOOL_H 1
7 
8 // STL includes
9 #include <string>
10 
11 // Gaudi
12 #include "GaudiKernel/ServiceHandle.h"
13 #include "GaudiKernel/ToolHandle.h"
14 #include "GaudiKernel/IChronoStatSvc.h"
15 
16 // Athena
19 
20 // DetectorDescription
23 
24 // ISF includes
26 #include "ISF_Event/ISFParticle.h"
27 #include "ISF_Event/SimSvcID.h"
28 
29 namespace ISF {
30 
36  class BaseSimulatorTool : public extends<AthAlgTool, ISimulatorTool> {
37  public:
38 
39  //** Constructor with parameters */
40  BaseSimulatorTool(const std::string& type, const std::string& name, const IInterface* parent)
41  : base_class(type, name, parent)
42  {
43  }
44 
46  virtual ~BaseSimulatorTool() {}
47 
49  virtual StatusCode sysInitialize() override
50  {
52  ATH_CHECK( m_chrono.retrieve() );
53  return StatusCode::SUCCESS;
54  }
55 
57  virtual StatusCode initialize() override
58  {
59  return StatusCode::SUCCESS;
60  }
61 
63  virtual StatusCode setupEvent(const EventContext&) override
64  { return StatusCode::FAILURE; }
65 
67  virtual StatusCode setupEventST() override
68  { return setupEvent(Gaudi::Hive::currentContext()); }
69 
71  virtual StatusCode simulate(const EventContext& , ISFParticle& , ISFParticleContainer&, McEventCollection*) override
72  { return StatusCode::FAILURE; }
73 
75  virtual StatusCode simulateVector(const EventContext& ctx, const ISFParticleVector& particles, ISFParticleContainer& secondaries, McEventCollection* mcEventCollection, McEventCollection *) override
76  {
77  // this implementation is a wrapper in case the simulator does
78  // implement particle-vector input
79 
80  // simulate each particle individually
81  for (auto* cisp : particles) {
82  ATH_MSG_VERBOSE( "Starting simulation of particle: " << (*cisp) );
83  ATH_CHECK(this->simulate(ctx, *cisp, secondaries, mcEventCollection));
84  }
85  return StatusCode::SUCCESS;
86 
87  }
88 
90  virtual StatusCode releaseEvent(const EventContext&) override
91  { return StatusCode::FAILURE; }
92 
94  virtual StatusCode releaseEventST() override
95  { return releaseEvent(Gaudi::Hive::currentContext()); }
96 
98  const ChronoEntity* chronoStart(const IChronoSvc::ChronoTag& tag ) {
99  if (m_chrono) return m_chrono->chronoStart( tag);
100  return nullptr;
101  }
102 
104  const ChronoEntity* chronoStop(const IChronoSvc::ChronoTag& tag ) {
105  if (m_chrono) return m_chrono->chronoStop( tag);
106  return nullptr;
107  }
108 
109  private:
112 
113  protected:
115  ServiceHandle<IChronoStatSvc> m_chrono{this, "ChronoStatService", "ChronoStatSvc"};
116 
117  };
118 
119 }
120 
121 
122 #endif //> !ISF_INTERFACES_BASESIMULATORTOOL_H
ISF::ISFParticleContainer
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)
Definition: ISFParticleContainer.h:23
ISF::BaseSimulatorTool::~BaseSimulatorTool
virtual ~BaseSimulatorTool()
Destructor.
Definition: BaseSimulatorTool.h:46
AtlasRegion.h
ISF::BaseSimulatorTool::releaseEvent
virtual StatusCode releaseEvent(const EventContext &) override
Release Event chain - in case of an end-of event action is needed.
Definition: BaseSimulatorTool.h:90
ISF::ISFParticle
Definition: ISFParticle.h:42
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::BaseSimulatorTool::chronoStop
const ChronoEntity * chronoStop(const IChronoSvc::ChronoTag &tag)
wrapper call to stop chrono with given tag
Definition: BaseSimulatorTool.h:104
ISimulatorTool.h
ISF::BaseSimulatorTool::releaseEventST
virtual StatusCode releaseEventST() override
Release Event chain - in case of an end-of event action is needed (called by ISimulationSvc)
Definition: BaseSimulatorTool.h:94
ISFParticle.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ISF::BaseSimulatorTool::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
The timing service for general usage.
Definition: BaseSimulatorTool.h:115
AthAlgTool.h
ISF::ISFParticleVector
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.
Definition: ISFParticleContainer.h:26
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AtlasRegionHelper.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ISF::BaseSimulatorTool::sysInitialize
virtual StatusCode sysInitialize() override
Gaudi sysInitialize() methods.
Definition: BaseSimulatorTool.h:49
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
ISF::BaseSimulatorTool::BaseSimulatorTool
BaseSimulatorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: BaseSimulatorTool.h:40
ISF::BaseSimulatorTool::BaseSimulatorTool
BaseSimulatorTool()
Default constructor.
ISF::BaseSimulatorTool::chronoStart
const ChronoEntity * chronoStart(const IChronoSvc::ChronoTag &tag)
wrapper call to start chrono with given tag
Definition: BaseSimulatorTool.h:98
ISF::BaseSimulatorTool
Definition: BaseSimulatorTool.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ISF::BaseSimulatorTool::setupEventST
virtual StatusCode setupEventST() override
Setup Event chain - in case of a begin-of event action is needed (called by ISimulationSvc)
Definition: BaseSimulatorTool.h:67
AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize
virtual StatusCode sysInitialize() override
Perform system initialization for an algorithm.
ISF::BaseSimulatorTool::setupEvent
virtual StatusCode setupEvent(const EventContext &) override
Setup Event chain - in case of a begin-of event action is needed.
Definition: BaseSimulatorTool.h:63
ISF::BaseSimulatorTool::initialize
virtual StatusCode initialize() override
Definition: BaseSimulatorTool.h:57
ISF
ISFParticleOrderedQueue.
Definition: PrimaryParticleInformation.h:13
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
IOVSvcDefs.h
defines and typedefs for IOVSvc
ISF::BaseSimulatorTool::simulate
virtual StatusCode simulate(const EventContext &, ISFParticle &, ISFParticleContainer &, McEventCollection *) override
Definition: BaseSimulatorTool.h:71
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
ISF::BaseSimulatorTool::simulateVector
virtual StatusCode simulateVector(const EventContext &ctx, const ISFParticleVector &particles, ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, McEventCollection *) override
Simulation call for vectors of particles.
Definition: BaseSimulatorTool.h:75
SimSvcID.h
ServiceHandle< IChronoStatSvc >