ATLAS Offline Software
G4AtlasAlg.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 G4ATLASALG_G4AtlasAlg_H
6 #define G4ATLASALG_G4AtlasAlg_H
7 
8 // Base class header
10 
11 // STL headers
12 #include <map>
13 #include <string>
14 
15 // Gaudi headers
16 #include "GaudiKernel/ServiceHandle.h"
17 #include "GaudiKernel/ToolHandle.h"
18 
19 // Athena headers
34 
35 // ISF includes
40 
52 class G4AtlasAlg : public AthAlgorithm
53 {
54 
55 public:
56 
58  G4AtlasAlg(const std::string& name, ISvcLocator* pSvcLocator);
59 
61  virtual ~G4AtlasAlg() { };
62 
64  bool isClonable() const override { return true; }
65 
73 
75  StatusCode finalize() override;
76 
78  StatusCode execute() override;
79 
81  void initializeG4();
82 
85  void initializeOnce();
86 
89  void finalizeOnce();
90 
91 private:
92 
94  void commandLog(int returnCode, const std::string& commandString) const;
95 
98  void releaseGeoModel();
99 
102  Gaudi::Property<bool> m_killAbortedEvents{this, "KillAbortedEvents", false, ""};
103  Gaudi::Property<bool> m_flagAbortedEvents{this, "FlagAbortedEvents", false, ""};
104  SG::ReadHandleKey<McEventCollection> m_inputTruthCollectionKey{this, "InputTruthCollection", "BeamTruthEvent", "Input hard scatter collection"};
105  SG::WriteHandleKey<McEventCollection> m_outputTruthCollectionKey{this, "OutputTruthCollection", "TruthEvent", "Output hard scatter truth collection"};
106  SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "EventInfo", "EventInfo", "EventInfo key"};
107 
109  ServiceHandle<ISF::ITruthSvc> m_truthRecordSvc{this, "TruthRecordService", "ISF_TruthRecordSvc", ""};
111  ServiceHandle<ISF::IGeoIDSvc> m_geoIDSvc{this, "GeoIDSvc", "ISF_GeoIDSvc", ""};
112 
114  std::map<std::string,std::string> m_verbosities;
116 
119  Gaudi::Property<std::string> m_libList{this, "Dll", "", ""};
120  Gaudi::Property<std::string> m_physList{this, "Physics", "", ""};
121  Gaudi::Property<std::string> m_fieldMap{this, "FieldMap", "", ""};
122  Gaudi::Property<std::string> m_rndmGen{this, "RandomGenerator", "athena", ""};
123  Gaudi::Property<bool> m_releaseGeoModel{this, "ReleaseGeoModel", true, ""};
124  Gaudi::Property<bool> m_recordFlux{this, "RecordFlux", false, ""};
125  Gaudi::Property<bool> m_quietMode{this, "QuietMode", false, ""};
127  Gaudi::Property<std::vector<std::string> > m_g4commands{this, "G4Commands", {}, "Commands to send to the G4UI"};
129  Gaudi::Property<bool> m_useMT{this,"MultiThreading", false, "Multi-threading specific settings"};
130  Gaudi::Property<bool> m_activateParallelGeometries{this, "ActivateParallelWorlds", false, "Toggle on/off the G4 parallel geometry system"};
131  BooleanProperty m_useShadowEvent{this, "UseShadowEvent", false, "New approach to selecting particles for simulation" };
133  ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "AtRndmGenSvc", "AthRNGSvc", ""}; // TODO rename property
135  Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Geant4", ""};
137  ServiceHandle<IUserLimitsSvc> m_userLimitsSvc{this, "UserLimitsSvc", "UserLimitsSvc", ""};
139  ServiceHandle<G4UA::IUserActionSvc> m_userActionSvc{this, "UserActionSvc", "G4UA::UserActionSvc", ""};
141  ServiceHandle<IDetectorGeometrySvc> m_detGeoSvc{this, "DetGeoSvc", "DetectorGeometrySvc", ""};
142 
144  ServiceHandle<Simulation::IZeroLifetimePatcher> m_qspatcher{this, "QuasiStablePatcher", "", "Quasi-Stable Particle Simulation Patcher"};
145 
146  ToolHandle<ISF::IGenEventFilter> m_truthPreselectionTool{this, "TruthPreselectionTool", "", "Tool for filtering out quasi-stable particle daughters"};
147 
149  ServiceHandle<ISF::IInputConverter> m_inputConverter{this, "InputConverter", "ISF_InputConverter", ""};
151  ServiceHandle<IPhysicsListSvc> m_physListSvc{this, "PhysicsListSvc", "PhysicsListSvc", ""};
153  PublicToolHandle<ISensitiveDetectorMasterTool> m_senDetTool{this, "SenDetMasterTool", "SensitiveDetectorMasterTool", ""};
155  PublicToolHandle<IFastSimulationMasterTool> m_fastSimTool{this, "FastSimMasterTool", "FastSimulationMasterTool", ""};
157  PublicToolHandleArray<G4UA::IUserActionTool> m_actionTools{this, "UserActionTools", {}, "User action tools to be added to the G4 Action service."};
158  // FastCaloSim in Geant4 configuration
159  Gaudi::Property<std::string> m_simplifiedGeoPath{this, "SimplifiedGeoPath", "", "Path to the simplified geometry file used to transport particles"};
160 
161 };
162 
163 #endif// G4ATLASALG_G4AtlasAlg_H
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
G4AtlasAlg::m_flagAbortedEvents
Gaudi::Property< bool > m_flagAbortedEvents
Definition: G4AtlasAlg.h:103
G4AtlasAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: G4AtlasAlg.h:106
IUserActionSvc.h
G4AtlasAlg::m_geoIDSvc
ServiceHandle< ISF::IGeoIDSvc > m_geoIDSvc
Geo ID Service.
Definition: G4AtlasAlg.h:111
G4AtlasAlg::isClonable
bool isClonable() const override
this Alg is Clonable (for AthenaMT)
Definition: G4AtlasAlg.h:64
G4AtlasAlg::finalize
StatusCode finalize() override
Finalize the algorithm and invoke G4 run termination.
Definition: G4AtlasAlg.cxx:285
initialize
void initialize()
Definition: run_EoverP.cxx:894
G4AtlasAlg::m_senDetTool
PublicToolHandle< ISensitiveDetectorMasterTool > m_senDetTool
Sensitive Detector Master Tool.
Definition: G4AtlasAlg.h:153
ISensitiveDetectorMasterTool.h
G4AtlasAlg::m_fieldMap
Gaudi::Property< std::string > m_fieldMap
Definition: G4AtlasAlg.h:121
IInputConverter.h
G4AtlasAlg::m_recordFlux
Gaudi::Property< bool > m_recordFlux
Definition: G4AtlasAlg.h:124
G4AtlasAlg::m_detGeoSvc
ServiceHandle< IDetectorGeometrySvc > m_detGeoSvc
Detector Geometry Service (builds G4 Geometry)
Definition: G4AtlasAlg.h:141
G4AtlasAlg::m_releaseGeoModel
Gaudi::Property< bool > m_releaseGeoModel
Definition: G4AtlasAlg.h:123
SG::ReadHandleKey< McEventCollection >
G4AtlasAlg::m_physListSvc
ServiceHandle< IPhysicsListSvc > m_physListSvc
Physics List Tool.
Definition: G4AtlasAlg.h:151
G4AtlasAlg::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition: G4AtlasAlg.h:135
G4AtlasAlg::commandLog
void commandLog(int returnCode, const std::string &commandString) const
This command prints a message about a G4Command depending on its returnCode.
Definition: G4AtlasAlg.cxx:483
IFastSimulationMasterTool.h
G4AtlasAlg::m_userLimitsSvc
ServiceHandle< IUserLimitsSvc > m_userLimitsSvc
Definition: G4AtlasAlg.h:137
IUserLimitsSvc.h
AthAlgorithm.h
G4AtlasAlg::m_truthPreselectionTool
ToolHandle< ISF::IGenEventFilter > m_truthPreselectionTool
Definition: G4AtlasAlg.h:146
G4AtlasAlg::m_inputTruthCollectionKey
SG::ReadHandleKey< McEventCollection > m_inputTruthCollectionKey
input hard scatter collection
Definition: G4AtlasAlg.h:104
G4AtlasAlg::m_inputConverter
ServiceHandle< ISF::IInputConverter > m_inputConverter
Service to convert ISF_Particles into a G4Event.
Definition: G4AtlasAlg.h:149
SG::WriteHandleKey< McEventCollection >
McEventCollection.h
G4AtlasAlg::m_fastSimTool
PublicToolHandle< IFastSimulationMasterTool > m_fastSimTool
Fast Simulation Master Tool.
Definition: G4AtlasAlg.h:155
G4AtlasAlg::finalizeOnce
void finalizeOnce()
G4 finalization called only by the first alg instance.
Definition: G4AtlasAlg.cxx:303
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
G4AtlasAlg::ATLAS_NOT_THREAD_SAFE
StatusCode initialize ATLAS_NOT_THREAD_SAFE() override
Initialize the algorithm.
G4AtlasAlg::execute
StatusCode execute() override
Simulate one Athena event.
Definition: G4AtlasAlg.cxx:312
IDetectorGeometrySvc.h
G4AtlasAlg::m_useShadowEvent
BooleanProperty m_useShadowEvent
Definition: G4AtlasAlg.h:131
G4AtlasAlg::initializeG4
void initializeG4()
Poorly named possibly unused method which sets some verbosities.
Definition: G4AtlasAlg.cxx:252
IGeoIDSvc.h
G4AtlasAlg
Primary Athena algorithm for ATLAS simulation.
Definition: G4AtlasAlg.h:53
AthAlgorithm
Definition: AthAlgorithm.h:47
G4AtlasAlg::m_g4commands
Gaudi::Property< std::vector< std::string > > m_g4commands
Commands to send to the G4 UI.
Definition: G4AtlasAlg.h:127
G4AtlasAlg::m_rndmGen
Gaudi::Property< std::string > m_rndmGen
Definition: G4AtlasAlg.h:122
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IZeroLifetimePatcher.h
G4AtlasAlg::releaseGeoModel
void releaseGeoModel()
Releases the GeoModel geometry from memory once it has been used to build the G4 geometry and is no-l...
Definition: G4AtlasAlg.cxx:465
G4AtlasAlg::m_physList
Gaudi::Property< std::string > m_physList
Definition: G4AtlasAlg.h:120
EventInfo.h
G4AtlasAlg::m_useMT
Gaudi::Property< bool > m_useMT
Activate multi-threading configuration.
Definition: G4AtlasAlg.h:129
G4AtlasAlg::m_truthRecordSvc
ServiceHandle< ISF::ITruthSvc > m_truthRecordSvc
Central Truth Service.
Definition: G4AtlasAlg.h:109
IUserActionTool.h
G4AtlasAlg::m_actionTools
PublicToolHandleArray< G4UA::IUserActionTool > m_actionTools
Definition: G4AtlasAlg.h:157
G4AtlasAlg::G4AtlasAlg
G4AtlasAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard algorithm constructor.
Definition: G4AtlasAlg.cxx:57
G4AtlasAlg::m_simplifiedGeoPath
Gaudi::Property< std::string > m_simplifiedGeoPath
Definition: G4AtlasAlg.h:159
G4AtlasAlg::m_quietMode
Gaudi::Property< bool > m_quietMode
Definition: G4AtlasAlg.h:125
G4AtlasAlg::m_verbosities
std::map< std::string, std::string > m_verbosities
Verbosity settings for Geant4.
Definition: G4AtlasAlg.h:114
G4AtlasAlg::~G4AtlasAlg
virtual ~G4AtlasAlg()
Virtual destructor.
Definition: G4AtlasAlg.h:61
IPhysicsListSvc.h
G4AtlasAlg::m_userActionSvc
ServiceHandle< G4UA::IUserActionSvc > m_userActionSvc
User Action Service.
Definition: G4AtlasAlg.h:139
G4AtlasAlg::m_qspatcher
ServiceHandle< Simulation::IZeroLifetimePatcher > m_qspatcher
Quasi-Stable Particle Simulation Patcher.
Definition: G4AtlasAlg.h:144
G4AtlasAlg::m_killAbortedEvents
Gaudi::Property< bool > m_killAbortedEvents
Definition: G4AtlasAlg.h:102
ITruthSvc.h
G4AtlasAlg::m_rndmGenSvc
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
Random number service.
Definition: G4AtlasAlg.h:133
G4AtlasAlg::m_libList
Gaudi::Property< std::string > m_libList
Definition: G4AtlasAlg.h:119
checker_macros.h
Define macros for attributes used to control the static checker.
G4AtlasAlg::m_outputTruthCollectionKey
SG::WriteHandleKey< McEventCollection > m_outputTruthCollectionKey
output hard scatter truth collection
Definition: G4AtlasAlg.h:105
IGenEventFilter.h
G4AtlasAlg::m_activateParallelGeometries
Gaudi::Property< bool > m_activateParallelGeometries
Definition: G4AtlasAlg.h:130
IAthRNGSvc.h
ServiceHandle< ISF::ITruthSvc >
G4AtlasAlg::initializeOnce
void initializeOnce()
G4 initialization called only by the first alg instance.
Definition: G4AtlasAlg.cxx:133