ATLAS Offline Software
G4AtlasAlg.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 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, ""};
126  Gaudi::Property<std::vector<std::string> > m_g4commands{this, "G4Commands", {}, "Commands to send to the G4UI"};
128  Gaudi::Property<bool> m_useMT{this,"MultiThreading", false, "Multi-threading specific settings"};
129  Gaudi::Property<bool> m_activateParallelGeometries{this, "ActivateParallelWorlds", false, "Toggle on/off the G4 parallel geometry system"};
130  BooleanProperty m_useShadowEvent{this, "UseShadowEvent", false, "New approach to selecting particles for simulation" };
132  ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "AtRndmGenSvc", "AthRNGSvc", ""}; // TODO rename property
134  Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Geant4", ""};
136  ServiceHandle<IUserLimitsSvc> m_userLimitsSvc{this, "UserLimitsSvc", "UserLimitsSvc", ""};
138  ServiceHandle<G4UA::IUserActionSvc> m_userActionSvc{this, "UserActionSvc", "G4UA::UserActionSvc", ""};
140  ServiceHandle<IDetectorGeometrySvc> m_detGeoSvc{this, "DetGeoSvc", "DetectorGeometrySvc", ""};
141 
143  ServiceHandle<Simulation::IZeroLifetimePatcher> m_qspatcher{this, "QuasiStablePatcher", "", "Quasi-Stable Particle Simulation Patcher"};
144 
145  ToolHandle<ISF::IGenEventFilter> m_truthPreselectionTool{this, "TruthPreselectionTool", "", "Tool for filtering out quasi-stable particle daughters"};
146 
148  ServiceHandle<ISF::IInputConverter> m_inputConverter{this, "InputConverter", "ISF_InputConverter", ""};
150  ServiceHandle<IPhysicsListSvc> m_physListSvc{this, "PhysicsListSvc", "PhysicsListSvc", ""};
152  PublicToolHandle<ISensitiveDetectorMasterTool> m_senDetTool{this, "SenDetMasterTool", "SensitiveDetectorMasterTool", ""};
154  PublicToolHandle<IFastSimulationMasterTool> m_fastSimTool{this, "FastSimMasterTool", "FastSimulationMasterTool", ""};
156  PublicToolHandleArray<G4UA::IUserActionTool> m_actionTools{this, "UserActionTools", {}, "User action tools to be added to the G4 Action service."};
157  // FastCaloSim in Geant4 configuration
158  Gaudi::Property<std::string> m_simplifiedGeoPath{this, "SimplifiedGeoPath", "", "Path to the simplified geometry file used to transport particles"};
159 
160 };
161 
162 #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:282
initialize
void initialize()
Definition: run_EoverP.cxx:894
G4AtlasAlg::m_senDetTool
PublicToolHandle< ISensitiveDetectorMasterTool > m_senDetTool
Sensitive Detector Master Tool.
Definition: G4AtlasAlg.h:152
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:140
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:150
G4AtlasAlg::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition: G4AtlasAlg.h:134
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:481
IFastSimulationMasterTool.h
G4AtlasAlg::m_userLimitsSvc
ServiceHandle< IUserLimitsSvc > m_userLimitsSvc
Definition: G4AtlasAlg.h:136
IUserLimitsSvc.h
AthAlgorithm.h
G4AtlasAlg::m_truthPreselectionTool
ToolHandle< ISF::IGenEventFilter > m_truthPreselectionTool
Definition: G4AtlasAlg.h:145
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:148
SG::WriteHandleKey< McEventCollection >
McEventCollection.h
G4AtlasAlg::m_fastSimTool
PublicToolHandle< IFastSimulationMasterTool > m_fastSimTool
Fast Simulation Master Tool.
Definition: G4AtlasAlg.h:154
G4AtlasAlg::finalizeOnce
void finalizeOnce()
G4 finalization called only by the first alg instance.
Definition: G4AtlasAlg.cxx:300
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:309
IDetectorGeometrySvc.h
G4AtlasAlg::m_useShadowEvent
BooleanProperty m_useShadowEvent
Definition: G4AtlasAlg.h:130
G4AtlasAlg::initializeG4
void initializeG4()
Poorly named possibly unused method which sets some verbosities.
Definition: G4AtlasAlg.cxx:249
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:126
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:195
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:462
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:128
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:156
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:158
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:138
G4AtlasAlg::m_qspatcher
ServiceHandle< Simulation::IZeroLifetimePatcher > m_qspatcher
Quasi-Stable Particle Simulation Patcher.
Definition: G4AtlasAlg.h:143
G4AtlasAlg::m_killAbortedEvents
Gaudi::Property< bool > m_killAbortedEvents
Definition: G4AtlasAlg.h:102
CI_EMPFlowData22test.returnCode
returnCode
Definition: CI_EMPFlowData22test.py:16
ITruthSvc.h
G4AtlasAlg::m_rndmGenSvc
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
Random number service.
Definition: G4AtlasAlg.h:132
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:129
IAthRNGSvc.h
ServiceHandle< ISF::ITruthSvc >
G4AtlasAlg::initializeOnce
void initializeOnce()
G4 initialization called only by the first alg instance.
Definition: G4AtlasAlg.cxx:133