ATLAS Offline Software
Loading...
Searching...
No Matches
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
18
19// DetectorDescription
22
23// ISF includes
26#include "ISF_Event/SimSvcID.h"
27
28namespace ISF {
29
35 class BaseSimulatorTool : public extends<AthAlgTool, ISimulatorTool> {
36 public:
37
38 //** Constructor with parameters */
39 BaseSimulatorTool(const std::string& type, const std::string& name, const IInterface* parent)
40 : base_class(type, name, parent)
41 {
42 }
43
45 virtual ~BaseSimulatorTool() {}
46
48 virtual StatusCode sysInitialize() override
49 {
51 ATH_CHECK( m_chrono.retrieve() );
52 return StatusCode::SUCCESS;
53 }
54
56 virtual StatusCode initialize() override
57 {
58 return StatusCode::SUCCESS;
59 }
60
62 virtual StatusCode setupEvent(const EventContext&) override
63 { return StatusCode::FAILURE; }
64
66 virtual StatusCode setupEventST() override
67 { return setupEvent(Gaudi::Hive::currentContext()); }
68
70 virtual StatusCode simulate(const EventContext& , ISFParticle& , ISFParticleContainer&, McEventCollection*) override
71 { return StatusCode::FAILURE; }
72
74 virtual StatusCode simulateVector(const EventContext& ctx, const ISFParticleVector& particles, ISFParticleContainer& secondaries, McEventCollection* mcEventCollection, McEventCollection *) override
75 {
76 // this implementation is a wrapper in case the simulator does
77 // implement particle-vector input
78
79 // simulate each particle individually
80 for (auto* cisp : particles) {
81 ATH_MSG_VERBOSE( "Starting simulation of particle: " << (*cisp) );
82 ATH_CHECK(this->simulate(ctx, *cisp, secondaries, mcEventCollection));
83 }
84 return StatusCode::SUCCESS;
85
86 }
87
89 virtual StatusCode releaseEvent(const EventContext&) override
90 { return StatusCode::FAILURE; }
91
93 virtual StatusCode releaseEventST() override
94 { return releaseEvent(Gaudi::Hive::currentContext()); }
95
97 const ChronoEntity* chronoStart(const IChronoSvc::ChronoTag& tag ) {
98 if (m_chrono) return m_chrono->chronoStart( tag);
99 return nullptr;
100 }
101
103 const ChronoEntity* chronoStop(const IChronoSvc::ChronoTag& tag ) {
104 if (m_chrono) return m_chrono->chronoStop( tag);
105 return nullptr;
106 }
107
108 private:
111
112 protected:
114 ServiceHandle<IChronoStatSvc> m_chrono{this, "ChronoStatService", "ChronoStatSvc"};
115
116 };
117
118}
119
120
121#endif //> !ISF_INTERFACES_BASESIMULATORTOOL_H
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
virtual StatusCode sysInitialize() override
virtual StatusCode releaseEvent(const EventContext &) override
Release Event chain - in case of an end-of event action is needed.
virtual StatusCode setupEventST() override
Setup Event chain - in case of a begin-of event action is needed (called by ISimulationSvc)
virtual StatusCode releaseEventST() override
Release Event chain - in case of an end-of event action is needed (called by ISimulationSvc)
virtual StatusCode simulate(const EventContext &, ISFParticle &, ISFParticleContainer &, McEventCollection *) override
virtual StatusCode initialize() override
const ChronoEntity * chronoStop(const IChronoSvc::ChronoTag &tag)
wrapper call to stop chrono with given tag
virtual StatusCode setupEvent(const EventContext &) override
Setup Event chain - in case of a begin-of event action is needed.
ServiceHandle< IChronoStatSvc > m_chrono
The timing service for general usage.
virtual ~BaseSimulatorTool()
Destructor.
BaseSimulatorTool(const std::string &type, const std::string &name, const IInterface *parent)
BaseSimulatorTool()
Default constructor.
virtual StatusCode simulateVector(const EventContext &ctx, const ISFParticleVector &particles, ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, McEventCollection *) override
Simulation call for vectors of particles.
const ChronoEntity * chronoStart(const IChronoSvc::ChronoTag &tag)
wrapper call to start chrono with given tag
virtual StatusCode sysInitialize() override
Gaudi sysInitialize() methods.
The generic ISF particle definition,.
Definition ISFParticle.h:42
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
ISFParticleOrderedQueue.
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.