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
35 
36 // ISF includes
41 
53 class G4AtlasAlg : public AthAlgorithm
54 {
55 
56 public:
57 
59  G4AtlasAlg(const std::string& name, ISvcLocator* pSvcLocator);
60 
62  virtual ~G4AtlasAlg() { };
63 
65  bool isClonable() const override { return true; }
66 
74 
76  StatusCode finalize() override;
77 
79  StatusCode execute() override;
80 
82  void initializeG4();
83 
86  void initializeOnce();
87 
90  void finalizeOnce();
91 
92 private:
93 
95  void commandLog(int returnCode, const std::string& commandString) const;
96 
99  void releaseGeoModel();
100 
103  Gaudi::Property<bool> m_killAbortedEvents{this, "KillAbortedEvents", false, ""};
104  Gaudi::Property<bool> m_flagAbortedEvents{this, "FlagAbortedEvents", false, ""};
105  SG::ReadHandleKey<McEventCollection> m_inputTruthCollectionKey{this, "InputTruthCollection", "BeamTruthEvent", "Input hard scatter collection"};
106  SG::WriteHandleKey<McEventCollection> m_outputTruthCollectionKey{this, "OutputTruthCollection", "TruthEvent", "Output hard scatter truth collection"};
107  SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "EventInfo", "EventInfo", "EventInfo key"};
108 
110  ServiceHandle<ISF::ITruthSvc> m_truthRecordSvc{this, "TruthRecordService", "ISF_TruthRecordSvc", ""};
112  ServiceHandle<ISF::IGeoIDSvc> m_geoIDSvc{this, "GeoIDSvc", "ISF_GeoIDSvc", ""};
113 
115  std::map<std::string,std::string> m_verbosities;
117 
120  Gaudi::Property<std::string> m_libList{this, "Dll", "", ""};
121  Gaudi::Property<std::string> m_physList{this, "Physics", "", ""};
122  Gaudi::Property<std::string> m_fieldMap{this, "FieldMap", "", ""};
123  Gaudi::Property<std::string> m_rndmGen{this, "RandomGenerator", "athena", ""};
124  Gaudi::Property<bool> m_releaseGeoModel{this, "ReleaseGeoModel", true, ""};
125  Gaudi::Property<bool> m_recordFlux{this, "RecordFlux", false, ""};
126  Gaudi::Property<bool> m_quietMode{this, "QuietMode", false, ""};
128  Gaudi::Property<std::vector<std::string> > m_g4commands{this, "G4Commands", {}, "Commands to send to the G4UI"};
130  Gaudi::Property<bool> m_useMT{this,"MultiThreading", false, "Multi-threading specific settings"};
131  Gaudi::Property<bool> m_activateParallelGeometries{this, "ActivateParallelWorlds", false, "Toggle on/off the G4 parallel geometry system"};
132  BooleanProperty m_useShadowEvent{this, "UseShadowEvent", false, "New approach to selecting particles for simulation" };
134  ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "AtRndmGenSvc", "AthRNGSvc", ""}; // TODO rename property
136  Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Geant4", ""};
138  ServiceHandle<IUserLimitsSvc> m_userLimitsSvc{this, "UserLimitsSvc", "UserLimitsSvc", ""};
140  ServiceHandle<G4UA::IUserActionSvc> m_userActionSvc{this, "UserActionSvc", "G4UA::UserActionSvc", ""};
141 
142  PublicToolHandle<IDetectorConstructionTool> m_detConstruction{this, "DetectorConstruction", "", "Tool handle of the DetectorConstruction"};
143  PublicToolHandleArray<IPhysicsInitializationTool> m_physicsInitializationTools{this, "PhysicsInitializationTools", {}, "Physics initialization happening after Geant4 initialization"};
144 
146  ServiceHandle<Simulation::IZeroLifetimePatcher> m_qspatcher{this, "QuasiStablePatcher", "", "Quasi-Stable Particle Simulation Patcher"};
147 
148  ToolHandle<ISF::IGenEventFilter> m_truthPreselectionTool{this, "TruthPreselectionTool", "", "Tool for filtering out quasi-stable particle daughters"};
149 
151  ServiceHandle<ISF::IInputConverter> m_inputConverter{this, "InputConverter", "ISF_InputConverter", ""};
153  ServiceHandle<IPhysicsListSvc> m_physListSvc{this, "PhysicsListSvc", "PhysicsListSvc", ""};
155  PublicToolHandle<ISensitiveDetectorMasterTool> m_senDetTool{this, "SenDetMasterTool", "SensitiveDetectorMasterTool", ""};
157  PublicToolHandle<IFastSimulationMasterTool> m_fastSimTool{this, "FastSimMasterTool", "FastSimulationMasterTool", ""};
159  PublicToolHandleArray<G4UA::IUserActionTool> m_actionTools{this, "UserActionTools", {}, "User action tools to be added to the G4 Action service."};
160  // FastCaloSim in Geant4 configuration
161  Gaudi::Property<std::string> m_simplifiedGeoPath{this, "SimplifiedGeoPath", "", "Path to the simplified geometry file used to transport particles"};
162 
163 };
164 
165 #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:104
G4AtlasAlg::m_detConstruction
PublicToolHandle< IDetectorConstructionTool > m_detConstruction
Definition: G4AtlasAlg.h:142
G4AtlasAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: G4AtlasAlg.h:107
IUserActionSvc.h
G4AtlasAlg::m_geoIDSvc
ServiceHandle< ISF::IGeoIDSvc > m_geoIDSvc
Geo ID Service.
Definition: G4AtlasAlg.h:112
G4AtlasAlg::isClonable
bool isClonable() const override
this Alg is Clonable (for AthenaMT)
Definition: G4AtlasAlg.h:65
G4AtlasAlg::finalize
StatusCode finalize() override
Finalize the algorithm and invoke G4 run termination.
Definition: G4AtlasAlg.cxx:294
initialize
void initialize()
Definition: run_EoverP.cxx:894
G4AtlasAlg::m_senDetTool
PublicToolHandle< ISensitiveDetectorMasterTool > m_senDetTool
Sensitive Detector Master Tool.
Definition: G4AtlasAlg.h:155
ISensitiveDetectorMasterTool.h
G4AtlasAlg::m_fieldMap
Gaudi::Property< std::string > m_fieldMap
Definition: G4AtlasAlg.h:122
IInputConverter.h
G4AtlasAlg::m_recordFlux
Gaudi::Property< bool > m_recordFlux
Definition: G4AtlasAlg.h:125
G4AtlasAlg::m_releaseGeoModel
Gaudi::Property< bool > m_releaseGeoModel
Definition: G4AtlasAlg.h:124
SG::ReadHandleKey< McEventCollection >
G4AtlasAlg::m_physListSvc
ServiceHandle< IPhysicsListSvc > m_physListSvc
Physics List Tool.
Definition: G4AtlasAlg.h:153
G4AtlasAlg::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition: G4AtlasAlg.h:136
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:488
IFastSimulationMasterTool.h
G4AtlasAlg::m_userLimitsSvc
ServiceHandle< IUserLimitsSvc > m_userLimitsSvc
Definition: G4AtlasAlg.h:138
IUserLimitsSvc.h
AthAlgorithm.h
G4AtlasAlg::m_truthPreselectionTool
ToolHandle< ISF::IGenEventFilter > m_truthPreselectionTool
Definition: G4AtlasAlg.h:148
G4AtlasAlg::m_inputTruthCollectionKey
SG::ReadHandleKey< McEventCollection > m_inputTruthCollectionKey
input hard scatter collection
Definition: G4AtlasAlg.h:105
G4AtlasAlg::m_inputConverter
ServiceHandle< ISF::IInputConverter > m_inputConverter
Service to convert ISF_Particles into a G4Event.
Definition: G4AtlasAlg.h:151
SG::WriteHandleKey< McEventCollection >
McEventCollection.h
G4AtlasAlg::m_fastSimTool
PublicToolHandle< IFastSimulationMasterTool > m_fastSimTool
Fast Simulation Master Tool.
Definition: G4AtlasAlg.h:157
G4AtlasAlg::finalizeOnce
void finalizeOnce()
G4 finalization called only by the first alg instance.
Definition: G4AtlasAlg.cxx:312
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:321
G4AtlasAlg::m_useShadowEvent
BooleanProperty m_useShadowEvent
Definition: G4AtlasAlg.h:132
G4AtlasAlg::initializeG4
void initializeG4()
Poorly named possibly unused method which sets some verbosities.
Definition: G4AtlasAlg.cxx:261
IGeoIDSvc.h
G4AtlasAlg
Primary Athena algorithm for ATLAS simulation.
Definition: G4AtlasAlg.h:54
AthAlgorithm
Definition: AthAlgorithm.h:47
G4AtlasAlg::m_physicsInitializationTools
PublicToolHandleArray< IPhysicsInitializationTool > m_physicsInitializationTools
Definition: G4AtlasAlg.h:143
G4AtlasAlg::m_g4commands
Gaudi::Property< std::vector< std::string > > m_g4commands
Commands to send to the G4 UI.
Definition: G4AtlasAlg.h:128
G4AtlasAlg::m_rndmGen
Gaudi::Property< std::string > m_rndmGen
Definition: G4AtlasAlg.h:123
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:240
IZeroLifetimePatcher.h
IPhysicsInitialization.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:470
G4AtlasAlg::m_physList
Gaudi::Property< std::string > m_physList
Definition: G4AtlasAlg.h:121
EventInfo.h
IDetectorConstructionTool.h
G4AtlasAlg::m_useMT
Gaudi::Property< bool > m_useMT
Activate multi-threading configuration.
Definition: G4AtlasAlg.h:130
G4AtlasAlg::m_truthRecordSvc
ServiceHandle< ISF::ITruthSvc > m_truthRecordSvc
Central Truth Service.
Definition: G4AtlasAlg.h:110
IUserActionTool.h
G4AtlasAlg::m_actionTools
PublicToolHandleArray< G4UA::IUserActionTool > m_actionTools
Definition: G4AtlasAlg.h:159
G4AtlasAlg::G4AtlasAlg
G4AtlasAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard algorithm constructor.
Definition: G4AtlasAlg.cxx:62
G4AtlasAlg::m_simplifiedGeoPath
Gaudi::Property< std::string > m_simplifiedGeoPath
Definition: G4AtlasAlg.h:161
G4AtlasAlg::m_quietMode
Gaudi::Property< bool > m_quietMode
Definition: G4AtlasAlg.h:126
G4AtlasAlg::m_verbosities
std::map< std::string, std::string > m_verbosities
Verbosity settings for Geant4.
Definition: G4AtlasAlg.h:115
G4AtlasAlg::~G4AtlasAlg
virtual ~G4AtlasAlg()
Virtual destructor.
Definition: G4AtlasAlg.h:62
IPhysicsListSvc.h
G4AtlasAlg::m_userActionSvc
ServiceHandle< G4UA::IUserActionSvc > m_userActionSvc
User Action Service.
Definition: G4AtlasAlg.h:140
G4AtlasAlg::m_qspatcher
ServiceHandle< Simulation::IZeroLifetimePatcher > m_qspatcher
Quasi-Stable Particle Simulation Patcher.
Definition: G4AtlasAlg.h:146
G4AtlasAlg::m_killAbortedEvents
Gaudi::Property< bool > m_killAbortedEvents
Definition: G4AtlasAlg.h:103
ITruthSvc.h
G4AtlasAlg::m_rndmGenSvc
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
Random number service.
Definition: G4AtlasAlg.h:134
G4AtlasAlg::m_libList
Gaudi::Property< std::string > m_libList
Definition: G4AtlasAlg.h:120
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:106
IGenEventFilter.h
G4AtlasAlg::m_activateParallelGeometries
Gaudi::Property< bool > m_activateParallelGeometries
Definition: G4AtlasAlg.h:131
IAthRNGSvc.h
ServiceHandle< ISF::ITruthSvc >
G4AtlasAlg::initializeOnce
void initializeOnce()
G4 initialization called only by the first alg instance.
Definition: G4AtlasAlg.cxx:137