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
19
20// DetectorDescription
23
24// ISF includes
27#include "ISF_Event/SimSvcID.h"
28
29namespace 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
defines and typedefs for IOVSvc
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.