ATLAS Offline Software
BaseSimulatorTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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  // Service handling
44  declareProperty("ChronoStatService", m_chronoSvcName );
45  }
46 
48  virtual ~BaseSimulatorTool() {}
49 
51  virtual StatusCode sysInitialize() override
52  {
54  ATH_CHECK( serviceLocator()->service(m_chronoSvcName, m_chrono ) );
55  return StatusCode::SUCCESS;
56  }
57 
59  virtual StatusCode initialize() override
60  {
61  return StatusCode::SUCCESS;
62  }
63 
65  virtual StatusCode setupEvent(const EventContext&) override
66  { return StatusCode::FAILURE; }
67 
69  virtual StatusCode setupEventST() override
70  { return setupEvent(Gaudi::Hive::currentContext()); }
71 
74  { return StatusCode::FAILURE; }
75 
78  {
79  // this implementation is a wrapper in case the simulator does
80  // implement particle-vector input
81 
82  // simulate each particle individually
83  for (auto* cisp : particles) {
84  ATH_MSG_VERBOSE( "Starting simulation of particle: " << (*cisp) );
85  ATH_CHECK(this->simulate(*cisp, secondaries, mcEventCollection));
86  }
87  return StatusCode::SUCCESS;
88 
89  }
90 
92  virtual StatusCode releaseEvent(const EventContext&) override
93  { return StatusCode::FAILURE; }
94 
96  virtual StatusCode releaseEventST() override
97  { return releaseEvent(Gaudi::Hive::currentContext()); }
98 
100  const ChronoEntity* chronoStart(const IChronoSvc::ChronoTag& tag ) {
101  if (m_chrono) return m_chrono->chronoStart( tag);
102  return nullptr;
103  }
104 
106  const ChronoEntity* chronoStop(const IChronoSvc::ChronoTag& tag ) {
107  if (m_chrono) return m_chrono->chronoStop( tag);
108  return nullptr;
109  }
110 
111  private:
114 
115  protected:
117  std::string m_chronoSvcName{"ChronoStatSvc"};
118 
120  IChronoStatSvc* m_chrono{};
121 
122  };
123 
124 }
125 
126 
127 #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::m_chronoSvcName
std::string m_chronoSvcName
Name of the timing service - can be set by declareProperty()
Definition: BaseSimulatorTool.h:117
ISF::BaseSimulatorTool::~BaseSimulatorTool
virtual ~BaseSimulatorTool()
Destructor.
Definition: BaseSimulatorTool.h:48
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:92
ISF::ISFParticle
Definition: ISFParticle.h:42
ISF::BaseSimulatorTool::m_chrono
IChronoStatSvc * m_chrono
The timing service for general usage.
Definition: BaseSimulatorTool.h:120
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:106
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:96
ISFParticle.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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:51
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::simulateVector
virtual StatusCode simulateVector(const ISFParticleVector &particles, ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, McEventCollection *) override
Simulation call for vectors of particles.
Definition: BaseSimulatorTool.h:77
ISF::BaseSimulatorTool::chronoStart
const ChronoEntity * chronoStart(const IChronoSvc::ChronoTag &tag)
wrapper call to start chrono with given tag
Definition: BaseSimulatorTool.h:100
ISF::BaseSimulatorTool
Definition: BaseSimulatorTool.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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:69
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:65
ISF::BaseSimulatorTool::initialize
virtual StatusCode initialize() override
Definition: BaseSimulatorTool.h:59
ISF
ISFParticleOrderedQueue.
Definition: PrimaryParticleInformation.h:13
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
IOVSvcDefs.h
defines and typedefs for IOVSvc
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
ISF::BaseSimulatorTool::simulate
virtual StatusCode simulate(ISFParticle &, ISFParticleContainer &, McEventCollection *) override
Definition: BaseSimulatorTool.h:73
SimSvcID.h