ATLAS Offline Software
G4LegacyTransportTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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
27 
28 // ISF includes
33 // STL headers
34 #include <string>
35 #include <unordered_map>
36 
37 class G4Event;
38 class G4Timer;
39 class G4AtlasRunManager;
40 
41 namespace ISF {
42  class ISFParticle;
43 }
44 
46 
47 namespace iGeant4
48 {
49 
59 
60  public:
62  G4LegacyTransportTool(const std::string&,const std::string&,const IInterface*);
63 
65  virtual ~G4LegacyTransportTool () = default;
66 
68  virtual StatusCode initialize() override final;
69 
72  void initializeOnce ATLAS_NOT_THREAD_SAFE ();
73 
75  virtual StatusCode finalize() override final;
76 
79  void finalizeOnce();
80 
81  virtual StatusCode simulate( ISF::ISFParticle& isp, ISF::ISFParticleContainer& secondaries, McEventCollection* mcEventCollection ) override;
82 
83  virtual StatusCode simulateVector( const ISF::ISFParticleVector& particles, ISF::ISFParticleContainer& secondaries, McEventCollection* mcEventCollection, McEventCollection *shadowTruth=nullptr ) override;
84 
85  virtual StatusCode setupEvent(const EventContext&) override;
86 
87  virtual StatusCode releaseEvent(const EventContext&) override;
88 
89  virtual ISF::SimulationFlavor simFlavor() const override { return ISF::Geant4; };
90 
91  private:
92 
94  void commandLog(int returnCode, const std::string& commandString) const;
95 
96  HepMC::GenEvent* genEvent(McEventCollection* mcEventCollection) const;
97 
100 
101  // timing checks
102  Gaudi::Property<bool> m_doTiming{this, "PrintTimingInfo", true, ""};
103  //float m_runTime;
104  float m_accumulatedEventTime{0.};
105  float m_accumulatedEventTimeSq{0.};
106  unsigned int m_nrOfEntries{0};
107 
108  G4Timer* m_runTimer{nullptr};
109  G4Timer* m_eventTimer{nullptr};
110 
111  // store secondary particles that have been pushed back
112  struct Slot
113  {
114  std::unordered_map< ISF::ISFParticle const*, ISF::ISFParticleContainer > m_secondariesMap;
116  typedef std::lock_guard<mutex_t> lock_t;
118  };
120  Gaudi::Property<std::string> m_mcEventCollectionName{this, "McEventCollection", "TruthEvent", ""};
122  PublicToolHandle<ISF::IG4RunManagerHelper> m_g4RunManagerHelper{this, "G4RunManagerHelper", "iGeant4::G4RunManagerHelper/G4RunManagerHelper", ""};
123  G4AtlasRunManager *m_pRunMgr{};
124 
125  Gaudi::Property<std::string> m_libList{this, "Dll", "", ""};
126  Gaudi::Property<std::string> m_physList{this, "Physics", "", ""};
127  Gaudi::Property<std::string> m_fieldMap{this, "FieldMap", "", ""};
128  Gaudi::Property<bool> m_releaseGeoModel{this, "ReleaseGeoModel", true, ""};
129  Gaudi::Property<bool> m_recordFlux{this, "RecordFlux", false, ""};
131  Gaudi::Property<std::vector<std::string> > m_g4commands{this, "G4Commands", {}, "Commands to send to the G4UI"};
133  Gaudi::Property<bool> m_useMT{this,"MultiThreading", false, "Multi-threading specific settings"};
134  Gaudi::Property<bool> m_activateParallelGeometries{this, "ActivateParallelWorlds", false, "Toggle on/off the G4 parallel geometry system"};
135  // Random number service
136  ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "RandomNumberService", "AthRNGSvc", ""};
138  Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Geant4", ""};
140  ServiceHandle<IUserLimitsSvc> m_userLimitsSvc{this, "UserLimitsSvc", "UserLimitsSvc", ""};
142  ServiceHandle<G4UA::IUserActionSvc> m_userActionSvc{this, "UserActionSvc", "", ""};
144  ServiceHandle<IDetectorGeometrySvc> m_detGeoSvc{this, "DetGeoSvc", "DetectorGeometrySvc", ""};
146  ServiceHandle<ISF::IInputConverter> m_inputConverter{this, "InputConverter", "ISF_InputConverter", ""};
148  ServiceHandle<IPhysicsListSvc> m_physListSvc{this, "PhysicsListSvc", "PhysicsListSvc", ""};
150  PublicToolHandle<ISensitiveDetectorMasterTool> m_senDetTool{this, "SenDetMasterTool", "SensitiveDetectorMasterTool", ""};
152  PublicToolHandle<IFastSimulationMasterTool> m_fastSimTool{this, "FastSimMasterTool", "FastSimulationMasterTool", ""};
154 
155  };
156 
157 
158 }
159 
160 
161 #endif // ISF_GEANT4TOOLS_G4LEGACYTRANSPORTTOOL_H
ISF::ISFParticleContainer
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)
Definition: ISFParticleContainer.h:23
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
iGeant4::G4LegacyTransportTool
Definition: G4LegacyTransportTool.h:58
IUserActionSvc.h
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
AtlasRegion.h
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
initialize
void initialize()
Definition: run_EoverP.cxx:894
ISensitiveDetectorMasterTool.h
IInputConverter.h
iGeant4::G4LegacyTransportTool::~G4LegacyTransportTool
virtual ~G4LegacyTransportTool()=default
Destructor.
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
G4AtlasRunManager
ATLAS custom singleton run manager.
Definition: G4AtlasRunManager.h:30
iGeant4::G4LegacyTransportTool::Slot
Definition: G4LegacyTransportTool.h:113
IFastSimulationMasterTool.h
IUserLimitsSvc.h
iGeant4::G4LegacyTransportTool::Slot::m_secondariesMap
std::unordered_map< ISF::ISFParticle const *, ISF::ISFParticleContainer > m_secondariesMap
Definition: G4LegacyTransportTool.h:114
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
IG4RunManagerHelper.h
ISF::Geant4
@ Geant4
Definition: SimulationFlavor.h:23
ISimulationSelector.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IDetectorGeometrySvc.h
ISF::ISFParticleVector
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.
Definition: ISFParticleContainer.h:26
GenEvent_fwd.h
BaseSimulatorTool.h
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
iGeant4::G4LegacyTransportTool::Slot::mutex_t
std::mutex mutex_t
Definition: G4LegacyTransportTool.h:115
ISF::BaseSimulatorTool
Definition: BaseSimulatorTool.h:36
iGeant4::G4LegacyTransportTool::ATLAS_THREAD_SAFE
SG::SlotSpecificObj< Slot > m_slots ATLAS_THREAD_SAFE
Definition: G4LegacyTransportTool.h:119
iGeant4::G4LegacyTransportTool::Slot::m_mutex
mutex_t m_mutex
Definition: G4LegacyTransportTool.h:117
SimulationFlavor
Definition: SimulationFlavor.py:1
ISF
ISFParticleOrderedQueue.
Definition: PrimaryParticleInformation.h:13
iGeant4::G4LegacyTransportTool::Slot::lock_t
std::lock_guard< mutex_t > lock_t
Definition: G4LegacyTransportTool.h:116
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
IPhysicsListSvc.h
SlotSpecificObj.h
Maintain a set of objects, one per slot.
CI_EMPFlowData22test.returnCode
returnCode
Definition: CI_EMPFlowData22test.py:16
checker_macros.h
Define macros for attributes used to control the static checker.
IAthRNGSvc.h
ServiceHandle< IAthRNGSvc >
iGeant4
Definition: Geant4TruthIncident.h:35