ATLAS Offline Software
Loading...
Searching...
No Matches
G4LegacyTransportTool.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_GEANT4TOOLS_G4LEGACYTRANSPORTTOOL_H
6#define ISF_GEANT4TOOLS_G4LEGACYTRANSPORTTOOL_H
7
8
9
10// Gaudi headers
11#include "GaudiKernel/ToolHandle.h"
12#include "GaudiKernel/ServiceHandle.h"
13
14// DetectorDescription
16
17// Athena headers
28
29// ISF includes
34// STL headers
35#include <memory>
36#include <string>
37#include <unordered_map>
38
39class G4Event;
40class G4Timer;
42
43namespace ISF {
44 class ISFParticle;
45}
46
48
49namespace iGeant4
50{
51
59
62
63 public:
65 G4LegacyTransportTool(const std::string&, const std::string&,
66 const IInterface*);
67
69 virtual ~G4LegacyTransportTool() = default;
70
72 virtual StatusCode initialize() override final;
73
76 void initializeOnce ATLAS_NOT_THREAD_SAFE();
77
79 virtual StatusCode finalize() override final;
80
83 void finalizeOnce();
84
85 using ISF::BaseSimulatorG4Tool::releaseEvent;
86 using ISF::BaseSimulatorG4Tool::setupEvent;
87 using ISF::BaseSimulatorG4Tool::simulate;
88 using ISF::BaseSimulatorG4Tool::simulateVector;
89
90 virtual StatusCode simulate(const EventContext& ctx, ISF::ISFParticle& isp,
91 ISF::ISFParticleContainer& secondaries,
92 McEventCollection* mcEventCollection,
93 std::shared_ptr<HitCollectionMap>) override;
94
95 virtual StatusCode simulateVector(
96 const EventContext& ctx, const ISF::ISFParticleVector& particles,
97 ISF::ISFParticleContainer& secondaries,
98 McEventCollection* mcEventCollection, std::shared_ptr<HitCollectionMap> hitCollections,
99 McEventCollection* shadowTruth = nullptr) override;
100
101 virtual StatusCode setupEvent(const EventContext&,
102 HitCollectionMap&) override;
103
104 virtual StatusCode releaseEvent(const EventContext&,
105 HitCollectionMap&) override;
106
107 virtual ISF::SimulationFlavor simFlavor() const override {
108 return ISF::Geant4;
109 };
110
111 private:
114 void commandLog(int returnCode, const std::string& commandString) const;
115
116 HepMC::GenEvent* genEvent(McEventCollection* mcEventCollection) const;
117
120
121 // timing checks
122 Gaudi::Property<bool> m_doTiming{this, "PrintTimingInfo", true, ""};
123 // float m_runTime;
126 unsigned int m_nrOfEntries{0};
127
128 G4Timer* m_runTimer{nullptr};
129 G4Timer* m_eventTimer{nullptr};
130
131 // store secondary particles that have been pushed back
132 struct Slot {
133 std::unordered_map<ISF::ISFParticle const*, ISF::ISFParticleContainer>
135 typedef std::mutex mutex_t;
136 typedef std::lock_guard<mutex_t> lock_t;
138 };
140 Gaudi::Property<std::string> m_mcEventCollectionName{
141 this, "McEventCollection", "TruthEvent", ""};
142
143 PublicToolHandle<ISF::IG4RunManagerHelper> m_g4RunManagerHelper{
144 this, "G4RunManagerHelper",
145 "iGeant4::G4RunManagerHelper/G4RunManagerHelper", ""};
147
148 Gaudi::Property<std::string> m_libList{this, "Dll", "", ""};
149 Gaudi::Property<std::string> m_physList{this, "Physics", "", ""};
150 Gaudi::Property<std::string> m_fieldMap{this, "FieldMap", "", ""};
151 Gaudi::Property<bool> m_releaseGeoModel{this, "ReleaseGeoModel", true, ""};
152 Gaudi::Property<bool> m_recordFlux{this, "RecordFlux", false, ""};
153 Gaudi::Property<bool> m_quietMode{this, "QuietMode", false, ""};
155 Gaudi::Property<std::vector<std::string> > m_g4commands{
156 this, "G4Commands", {}, "Commands to send to the G4UI"};
157
158 Gaudi::Property<bool> m_useMT{this, "MultiThreading", false,
159 "Multi-threading specific settings"};
160 Gaudi::Property<bool> m_activateParallelGeometries{
161 this, "ActivateParallelWorlds", false,
162 "Toggle on/off the G4 parallel geometry system"};
163 // Random number service
164 ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "RandomNumberService",
165 "AthRNGSvc", ""};
166
167 Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName",
168 "Geant4", ""};
169
171 "UserLimitsSvc", ""};
172
174 ""};
175 PublicToolHandle<IDetectorConstructionTool> m_detConstruction{this, "DetectorConstruction", "", "Tool handle of the DetectorConstruction"};
178 this, "InputConverter", "ISF_InputConverter", ""};
179
181 "PhysicsListSvc", ""};
182
183 PublicToolHandle<ISensitiveDetectorMasterTool> m_senDetTool{
184 this, "SenDetMasterTool", "SensitiveDetectorMasterTool", ""};
185
186 PublicToolHandle<IFastSimulationMasterTool> m_fastSimTool{
187 this, "FastSimMasterTool", "FastSimulationMasterTool", ""};
188 PublicToolHandleArray<IPhysicsInitializationTool> m_physicsInitializationTools{this, "PhysicsInitializationTools", {}, "Physics initialization happening after Geant4 initialization"};
190};
191}
192
193
194#endif // ISF_GEANT4TOOLS_G4LEGACYTRANSPORTTOOL_H
Maintain a set of objects, one per slot.
Define macros for attributes used to control the static checker.
ATLAS custom singleton run manager.
Small wrapper around hit collection map to facilitate accessing the hit collection.
The generic ISF particle definition,.
Definition ISFParticle.h:42
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
Maintain a set of objects, one per slot.
virtual ~G4LegacyTransportTool()=default
Destructor.
virtual StatusCode setupEvent(const EventContext &, HitCollectionMap &) override
Create data containers for an event.
PublicToolHandle< IDetectorConstructionTool > m_detConstruction
virtual StatusCode simulate(const EventContext &ctx, ISF::ISFParticle &isp, ISF::ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, std::shared_ptr< HitCollectionMap >) override
Simulation call for individual particles.
PublicToolHandle< ISF::IG4RunManagerHelper > m_g4RunManagerHelper
Helper Tool to provide G4RunManager.
ServiceHandle< ISF::IInputConverter > m_inputConverter
Service to convert ISF_Particles into a G4Event.
Gaudi::Property< std::vector< std::string > > m_g4commands
Commands to send to the G4 UI.
Gaudi::Property< bool > m_useMT
Activate multi-threading configuration.
PublicToolHandle< ISensitiveDetectorMasterTool > m_senDetTool
Sensitive Detector Master Tool.
PublicToolHandle< IFastSimulationMasterTool > m_fastSimTool
Fast Simulation Master Tool.
virtual StatusCode finalize() override final
AlgTool finalize method.
void finalizeOnce()
G4 finalization called only by the first tool instance.
void initializeOnce ATLAS_NOT_THREAD_SAFE()
G4 initialization called only by the first tool instance.
SG::SlotSpecificObj< Slot > m_slots ATLAS_THREAD_SAFE
G4LegacyTransportTool(const std::string &, const std::string &, const IInterface *)
Constructor.
ServiceHandle< IUserLimitsSvc > m_userLimitsSvc
ServiceHandle< G4UA::IUserActionSvc > m_userActionSvc
user action service
Gaudi::Property< bool > m_activateParallelGeometries
Gaudi::Property< std::string > m_physList
Gaudi::Property< std::string > m_libList
ServiceHandle< IPhysicsListSvc > m_physListSvc
Physics List Service.
virtual ISF::SimulationFlavor simFlavor() const override
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Gaudi::Property< bool > m_releaseGeoModel
virtual StatusCode simulateVector(const EventContext &ctx, const ISF::ISFParticleVector &particles, ISF::ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, std::shared_ptr< HitCollectionMap > hitCollections, McEventCollection *shadowTruth=nullptr) override
Simulation call for vectors of particles.
PublicToolHandleArray< IPhysicsInitializationTool > m_physicsInitializationTools
Gaudi::Property< std::string > m_mcEventCollectionName
Gaudi::Property< std::string > m_fieldMap
virtual StatusCode releaseEvent(const EventContext &, HitCollectionMap &) override
Finalise data containers for an event.
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
ISFParticleOrderedQueue.
STL namespace.
void initialize()
std::unordered_map< ISF::ISFParticle const *, ISF::ISFParticleContainer > m_secondariesMap