ATLAS Offline Software
Loading...
Searching...
No Matches
G4AtlasAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local includes
6#include "G4AtlasAlg.h"
9
12
13// Can we safely include all of these?
18
19// Geant4 includes
20#include <G4Event.hh>
21
22#include "G4EventManager.hh"
23#include "G4GDMLParser.hh"
24#include "G4Navigator.hh"
25#include "G4ParallelWorldPhysics.hh"
26#include "G4PropagatorInField.hh"
27#include "G4RunManagerKernel.hh"
28#include "G4ScoringManager.hh"
29#include "G4StackManager.hh"
30#include "G4StateManager.hh"
31#include "G4TrackingManager.hh"
32#include "G4TransportationManager.hh"
33#include "G4UImanager.hh"
34#include "G4VModularPhysicsList.hh"
35#include "G4VUserPhysicsList.hh"
36
37// CLHEP includes
38#include "CLHEP/Random/RandomEngine.h"
39
40// Athena includes
41#include "GaudiKernel/IThreadInitTool.h"
49
50// standard library
51#include <memory>
52#include <mutex>
53static std::once_flag initializeOnceFlag;
54static std::once_flag finalizeOnceFlag;
55static std::once_flag releaseGeoModelOnceFlag;
56
58
59
60G4AtlasAlg::G4AtlasAlg(const std::string& name, ISvcLocator* pSvcLocator)
61 : AthAlgorithm(name, pSvcLocator)
62{
63 // Verbosities
64 declareProperty("Verbosities", m_verbosities);
65}
66
67
68// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
69
70StatusCode G4AtlasAlg::initialize ATLAS_NOT_THREAD_SAFE ()
71{
72 ATH_MSG_DEBUG("Start of initialize()");
73
74 // Read the simplified geometry for FastCaloSim track transportation if requested
75 if(!m_simplifiedGeoPath.empty()) {
76 std::string geoFile = PathResolverFindCalibFile(m_simplifiedGeoPath);
77
78 if (geoFile.empty()) {
79 ATH_MSG_FATAL("Could not find simplified geometry file: " << m_simplifiedGeoPath);
80 return StatusCode::FAILURE;
81 }
82
83 G4GDMLParser parser;
84 parser.Read(geoFile, false);
85 }
86
87 // Create the scoring manager if requested
88 if (m_recordFlux) G4ScoringManager::GetScoringManager();
89
90 ATH_CHECK( m_userActionSvc.retrieve() );
91 // One-time initialization
92 try {
93 std::call_once(initializeOnceFlag, &G4AtlasAlg::initializeOnce, this);
94 }
95 catch(const std::exception& e) {
96 ATH_MSG_ERROR("Failure in G4AtlasAlg::initializeOnce: " << e.what());
97 return StatusCode::FAILURE;
98 }
99
100 ATH_CHECK( m_rndmGenSvc.retrieve() );
101 ATH_CHECK(m_actionTools.retrieve());
102
103 ATH_CHECK(m_senDetTool.retrieve());
104 ATH_CHECK(m_fastSimTool.retrieve());
105
106 // Truth
107 ATH_CHECK( m_truthRecordSvc.retrieve() );
108 ATH_MSG_INFO( "- Using ISF TruthRecordSvc : " << m_truthRecordSvc.typeAndName() );
109
110 // I/O
111 ATH_CHECK( m_inputTruthCollectionKey.initialize());
112 ATH_CHECK( m_outputTruthCollectionKey.initialize());
113 ATH_CHECK( m_eventInfoKey.initialize() );
114
115 ATH_CHECK(m_inputConverter.retrieve());
116 if ( not m_truthPreselectionTool.empty() ) {
117 ATH_CHECK(m_truthPreselectionTool.retrieve());
118 }
119
120 if ( not m_qspatcher.empty() ) {
121 ATH_CHECK( m_qspatcher.retrieve() );
122 }
123
124 ATH_MSG_DEBUG("End of initialize()");
125 return StatusCode::SUCCESS;
126}
127
128// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
130{
131 // Needed to ensure Geant4 knows it's in MT mode as we use a custom run manager
132 // Nominally the custom managers should do this, but was needed before for Celeritas integration
133 // We put it back in here for now in case
134 // TODO: Review if still needed!
135 G4Threading::SetMultithreadedApplication(m_useMT);
136 ATH_MSG_INFO("Multi-threading is " << (G4Threading::IsMultithreadedApplication() ? "enabled" : "disabled")
137 << "WorkerThread" << G4Threading::IsWorkerThread());
138
139 // Assign physics list
140 if(m_physListSvc.retrieve().isFailure()) {
141 throw std::runtime_error("Could not initialize ATLAS PhysicsListSvc!");
142 }
143 for (const auto& action_tool : m_actionTools) {
144 if (m_userActionSvc->addActionTool(action_tool).isFailure()) {
145 throw std::runtime_error("Failed to add action tool "+action_tool.name());
146 }
147 }
148
149 ATH_MSG_INFO( "retrieving the Detector Construction tool" );
150 if(m_detConstruction.retrieve().isFailure()) {
151 throw std::runtime_error("Could not initialize ATLAS DetectorConstruction!");
152 }
153
154 // Create the (master) run manager
155 if(m_useMT) {
156#ifdef G4MULTITHREADED
157 auto* runMgr ATLAS_THREAD_SAFE = // protected by std::call_once above
158 G4AtlasMTRunManager::GetG4AtlasMTRunManager();
159 ATH_MSG_INFO("Configuring G4AtlasMTRunManager with " << cardinality() << " threads");
160
161 runMgr->SetNumberOfThreads(cardinality());
162 m_physListSvc->SetPhysicsList();
163 runMgr->SetDetConstructionTool( m_detConstruction.get() );
164 runMgr->SetPhysListSvc( m_physListSvc.typeAndName() );
165 runMgr->SetQuietMode( m_quietMode );
166 // Worker Thread initialization used to create worker run manager on demand.
167 std::unique_ptr<G4AtlasUserWorkerThreadInitialization> workerInit =
168 std::make_unique<G4AtlasUserWorkerThreadInitialization>();
169 workerInit->SetQuietMode( m_quietMode );
170 runMgr->SetUserInitialization( workerInit.release() );
171 std::unique_ptr<G4AtlasActionInitialization> actionInitialization =
172 std::make_unique<G4AtlasActionInitialization>(m_userActionSvc.get());
173 runMgr->SetUserInitialization(actionInitialization.release());
174#else
175 throw std::runtime_error("Trying to use multi-threading in non-MT build!");
176#endif
177 }
178 // Single-threaded run manager
179 else {
180 auto* runMgr ATLAS_THREAD_SAFE = // safe because single-threaded
181 G4AtlasRunManager::GetG4AtlasRunManager();
182 m_physListSvc->SetPhysicsList();
183 runMgr->SetRecordFlux( m_recordFlux, std::make_unique<G4AtlasFluxRecorder>() );
184 runMgr->SetLogLevel( int(msg().level()) ); // Synch log levels
185 runMgr->SetDetConstructionTool( m_detConstruction.get() );
186 runMgr->SetPhysListSvc(m_physListSvc.typeAndName() );
187 runMgr->SetQuietMode( m_quietMode );
188 std::unique_ptr<G4AtlasActionInitialization> actionInitialization =
189 std::make_unique<G4AtlasActionInitialization>(m_userActionSvc.get());
190 runMgr->SetUserInitialization(actionInitialization.release());
191 }
192
193 // G4 user interface commands
194 G4UImanager *ui = G4UImanager::GetUIpointer();
195
196 // Load custom libraries
197 if (!m_libList.empty()) {
198 ATH_MSG_INFO("G4AtlasAlg specific libraries requested ");
199 std::string temp="/load "+m_libList;
200 ui->ApplyCommand(temp);
201 }
202 // Load custom physics
203 if (!m_physList.empty()) {
204 ATH_MSG_INFO("requesting a specific physics list "<< m_physList);
205 std::string temp="/Physics/GetPhysicsList "+m_physList;
206 ui->ApplyCommand(temp);
207 }
208 // Load custom magnetic field
209 if (!m_fieldMap.empty()) {
210 ATH_MSG_INFO("requesting a specific field map "<< m_fieldMap);
211 ATH_MSG_INFO("the field is initialized straight away");
212 std::string temp="/MagneticField/Select "+m_fieldMap;
213 ui->ApplyCommand(temp);
214 ui->ApplyCommand("/MagneticField/Initialize");
215 }
216
217 // Send UI commands
218 ATH_MSG_DEBUG("G4 Command: Trying at the end of initializeOnce()");
219 for (const auto& g4command : m_g4commands) {
220 int returnCode = ui->ApplyCommand( g4command );
221 commandLog(returnCode, g4command);
222 }
223
224 // Code from G4AtlasSvc
225 auto* rm = G4RunManager::GetRunManager();
226 if(!rm) {
227 throw std::runtime_error("Run manager retrieval has failed");
228 }
229 rm->Initialize(); // Initialization differs slightly in multi-threading.
230 // TODO: add more details about why this is here.
231 if(!m_useMT && rm->ConfirmBeamOnCondition()) {
232 rm->RunInitialization();
233 }
234
235 ATH_MSG_INFO("Initializing " << m_physicsInitializationTools.size() << " physics initialization tools");
236 for(auto& physicsTool : m_physicsInitializationTools) {
237 if (physicsTool->initializePhysics().isFailure()) {
238 throw std::runtime_error("Failed to initialize physics with tool " + physicsTool.name());
239 }
240 }
241
242 if(m_userLimitsSvc.retrieve().isFailure()) {
243 throw std::runtime_error("Could not initialize ATLAS UserLimitsSvc!");
244 }
245
247 G4VModularPhysicsList* thePhysicsList=dynamic_cast<G4VModularPhysicsList*>(m_physListSvc->GetPhysicsList());
248 if (!thePhysicsList) {
249 throw std::runtime_error("Failed dynamic_cast!! this is not a G4VModularPhysicsList!");
250 }
251#if G4VERSION_NUMBER >= 1010
252 std::vector<std::string>& parallelWorldNames=m_detConstruction->GetParallelWorldNames();
253 for (auto& it: parallelWorldNames) {
254 thePhysicsList->RegisterPhysics(new G4ParallelWorldPhysics(it,true));
255 }
256#endif
257 }
258
259 return;
260}
261
263{
264 if (m_verbosities.size()>0) {
265 G4TransportationManager *tm = G4TransportationManager::GetTransportationManager();
266 G4RunManagerKernel *rmk = G4RunManagerKernel::GetRunManagerKernel();
267 G4EventManager *em = G4EventManager::GetEventManager();
268
269 auto itr = m_verbosities.end();
270 if ((itr = m_verbosities.find("Navigator")) != m_verbosities.end()) {
271 tm->GetNavigatorForTracking()->SetVerboseLevel( atof(itr->second.data()) );
272 }
273 if ((itr = m_verbosities.find("Propagator")) != m_verbosities.end()) {
274 tm->GetPropagatorInField()->SetVerboseLevel( atof(itr->second.data()) );
275 }
276 if ((itr = m_verbosities.find("Tracking")) != m_verbosities.end()) {
277 rmk->GetTrackingManager()->SetVerboseLevel( atof(itr->second.data()) );
278 }
279 if ((itr = m_verbosities.find("Stepping")) != m_verbosities.end()) {
280 rmk->GetTrackingManager()->GetSteppingManager()->
281 SetVerboseLevel( atof(itr->second.data()) );
282 }
283 if ((itr = m_verbosities.find("Stacking")) != m_verbosities.end()) {
284 rmk->GetStackManager()->SetVerboseLevel( atof(itr->second.data()) );
285 }
286 if ((itr = m_verbosities.find("Event")) != m_verbosities.end()) {
287 em->SetVerboseLevel( atof(itr->second.data()) );
288 }
289 } // End of the setting of verbosities
290
291}
292
293// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
294
296{
297 ATH_MSG_DEBUG(std::endl<<std::endl<<std::endl);
298 ATH_MSG_DEBUG("++++++++++++ G4AtlasAlg finalized ++++++++++++" <<std::endl<<std::endl);
299
300 // One time finalization
301 try {
302 std::call_once(finalizeOnceFlag, &G4AtlasAlg::finalizeOnce, this);
303 }
304 catch(const std::exception& e) {
305 ATH_MSG_ERROR("Failure in G4AtlasAlg::finalizeOnce: " << e.what());
306 return StatusCode::FAILURE;
307 }
308
309 return StatusCode::SUCCESS;
310}
311
312// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
314{
315 ATH_MSG_DEBUG("\t terminating the current G4 run");
316 auto runMgr = G4RunManager::GetRunManager();
317 runMgr->RunTermination();
318 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
319}
320
321// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
322
323StatusCode G4AtlasAlg::execute(const EventContext& ctx)
324{
325 static std::atomic<unsigned int> n_Event=0;
326 ATH_MSG_DEBUG("++++++++++++ G4AtlasAlg execute ++++++++++++");
327
328 n_Event += 1;
329
330 if (n_Event<=10 || (n_Event%100) == 0) {
331 ATH_MSG_ALWAYS("G4AtlasAlg: Event num. " << n_Event << " start processing");
332 }
333
334 // Release GeoModel Geometry if necessary
335 if (m_releaseGeoModel) {
336 try {
338 }
339 catch(const std::exception& e) {
340 ATH_MSG_ERROR("Failure in G4AtlasAlg::releaseGeoModel: " << e.what());
341 return StatusCode::FAILURE;
342 }
343 }
344
345 // Set the RNG to use for this event. We need to reset it for MT jobs
346 // because of the mismatch between Gaudi slot-local and G4 thread-local RNG.
347 ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this, m_randomStreamName);
348 rngWrapper->setSeed( m_randomStreamName, ctx);
349 G4Random::setTheEngine(rngWrapper->getEngine(ctx));
350
351 ATH_MSG_DEBUG("Calling SimulateG4Event");
352
353 auto eventInfo = std::make_unique<AtlasG4EventUserInfo>(ctx);
354 // get a shared pointer to the hit collection map because we will need it after the G4Event is destroyed
355 std::shared_ptr<HitCollectionMap> hitCollections = eventInfo->GetHitCollectionMap();
356
357 ATH_CHECK(m_senDetTool->BeginOfAthenaEvent(*hitCollections));
358 ATH_CHECK(m_userActionSvc->BeginOfAthenaEvent(*hitCollections));
359 ATH_CHECK(m_fastSimTool->BeginOfAthenaEvent(*hitCollections));
360
362 if (!inputTruthCollection.isValid()) {
363 ATH_MSG_FATAL("Unable to read input GenEvent collection " << inputTruthCollection.name() << " in store " << inputTruthCollection.store());
364 return StatusCode::FAILURE;
365 }
366 ATH_MSG_DEBUG("Found input GenEvent collection " << inputTruthCollection.name() << " in store " << inputTruthCollection.store());
367 // create the output Truth collection
369 std::unique_ptr<McEventCollection> shadowTruth{};
370 if (m_useShadowEvent) {
371 outputTruthCollection = std::make_unique<McEventCollection>();
372 // copy input Evgen collection to shadow Truth collection
373 shadowTruth = std::make_unique<McEventCollection>(*inputTruthCollection);
374 for (HepMC::GenEvent* currentGenEvent : *shadowTruth ) {
375 // Apply QS patch if required
376 if ( not m_qspatcher.empty() ) {
377 ATH_CHECK(m_qspatcher->applyWorkaround(*currentGenEvent));
378 }
379 // Copy GenEvent and remove daughters of quasi-stable particles to be simulated
380 std::unique_ptr<HepMC::GenEvent> outputEvent = m_truthPreselectionTool->filterGenEvent(*currentGenEvent);
381 outputTruthCollection->push_back(outputEvent.release());
382 }
383 }
384 else {
385 // copy input Evgen collection to output Truth collection
386 outputTruthCollection = std::make_unique<McEventCollection>(*inputTruthCollection);
387 // empty shadow Truth collection
388 shadowTruth = std::make_unique<McEventCollection>();
389 // Apply QS patch if required
390 if ( not m_qspatcher.empty() ) {
391 for (HepMC::GenEvent* currentGenEvent : *outputTruthCollection ) {
392 ATH_CHECK(m_qspatcher->applyWorkaround(*currentGenEvent));
393 }
394 }
395 }
396
397 ATH_MSG_DEBUG("Recorded output GenEvent collection " << outputTruthCollection.name() << " in store " << outputTruthCollection.store());
398
399 const int largestGeneratedParticleBC = (outputTruthCollection->empty()) ? HepMC::UNDEFINED_ID
400 : HepMC::maxGeneratedParticleBarcode(outputTruthCollection->at(0)); // TODO make this more robust
401 const int largestGeneratedVertexBC = (outputTruthCollection->empty()) ? HepMC::UNDEFINED_ID
402 : HepMC::maxGeneratedVertexBarcode(outputTruthCollection->at(0)); // TODO make this more robust
403 // tell TruthService we're starting a new event
404 ATH_CHECK( m_truthRecordSvc->initializeTruthCollection(largestGeneratedParticleBC, largestGeneratedVertexBC) );
405
406 bool abort = false;
407
408 {
409
410 auto inputEvent = std::make_unique<G4Event>(ctx.eventID().event_number());
411 inputEvent->SetUserInformation(eventInfo.release());
412
413 ATH_CHECK(m_inputConverter->convertHepMCToG4Event(
414 *outputTruthCollection, *inputEvent, *shadowTruth));
415 // Worker run manager
416 // Custom class has custom method call: ProcessEvent.
417 // So, grab custom singleton class directly, rather than base.
418 // Maybe that should be changed! Then we can use a base pointer.
419 if (m_useMT) {
420#ifdef G4MULTITHREADED
421 auto* workerRM = G4AtlasWorkerRunManager::GetG4AtlasWorkerRunManager();
422 abort = workerRM->ProcessEvent(inputEvent.release());
423#else
424 ATH_MSG_ERROR("Trying to use multi-threading in non-MT build!");
425 return StatusCode::FAILURE;
426#endif
427 } else {
428 auto* workerRM ATLAS_THREAD_SAFE = // single-threaded case
429 G4AtlasRunManager::GetG4AtlasRunManager();
430 abort = workerRM->ProcessEvent(inputEvent.release());
431 }
432
433 if (abort) {
434 ATH_MSG_WARNING("Event was aborted !! ");
435 ATH_MSG_WARNING("Simulation will now go on to the next event ");
437 ATH_MSG_WARNING("setFilterPassed is now False");
438 setFilterPassed(false, ctx);
439 }
442 if (!eventInfo.isValid()) {
444 "Failed to retrieve xAOD::EventInfo while trying to update the "
445 "error state!");
446 return StatusCode::FAILURE;
447 } else {
448 eventInfo->updateErrorState(xAOD::EventInfo::Core,
450 ATH_MSG_WARNING("Set error state in xAOD::EventInfo!");
451 }
452 }
453 }
454
455 ATH_CHECK(m_senDetTool->EndOfAthenaEvent(*hitCollections));
456 ATH_CHECK(m_userActionSvc->EndOfAthenaEvent(*hitCollections));
457 ATH_CHECK(m_fastSimTool->EndOfAthenaEvent(*hitCollections));
458
459 ATH_CHECK(m_truthRecordSvc->releaseEvent());
460 }
461 // Remove QS patch if required
462 if(!m_qspatcher.empty()) {
463 for (HepMC::GenEvent* currentGenEvent : *outputTruthCollection ) {
464 ATH_CHECK(m_qspatcher->removeWorkaround(*currentGenEvent));
465 }
466 }
467
468 return StatusCode::SUCCESS;
469}
470
471// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
472
474{
475 SmartIF<IGeoModelSvc> geoModel{Gaudi::svcLocator()->service("GeoModelSvc")};
476 if (!geoModel) {
477 ATH_MSG_WARNING( " ----> Unable to retrieve GeoModelSvc" );
478 }
479 else {
480 if (geoModel->clear().isFailure()) {
481 ATH_MSG_WARNING( " ----> GeoModelSvc::clear() failed" );
482 }
483 else {
484 ATH_MSG_INFO( " ----> GeoModelSvc::clear() succeeded " );
485 }
486 }
487 m_releaseGeoModel=false; // Don't do that again...
488 return;
489}
490
491void G4AtlasAlg::commandLog(int returnCode, const std::string& commandString) const
492{
493 switch(returnCode) {
494 case 0: { ATH_MSG_DEBUG("G4 Command: " << commandString << " - Command Succeeded"); } break;
495 case 100: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Command Not Found!"); } break;
496 case 200: {
497 auto* stateManager = G4StateManager::GetStateManager();
498 ATH_MSG_DEBUG("G4 Command: " << commandString << " - Illegal Application State (" <<
499 stateManager->GetStateString(stateManager->GetCurrentState()) << ")!");
500 } break;
501 case 300: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Range!"); } break;
502 case 400: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Unreadable!"); } break;
503 case 500: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Candidates!"); } break;
504 case 600: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Alias Not Found!"); } break;
505 default: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Unknown Status!"); } break;
506 }
507
508}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_ALWAYS(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
StatusCode G4AtlasAlg::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
static std::once_flag initializeOnceFlag
static std::once_flag releaseGeoModelOnceFlag
static std::once_flag finalizeOnceFlag
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:154
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:108
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< ISF::IInputConverter > m_inputConverter
Service to convert ISF_Particles into a G4Event.
Definition G4AtlasAlg.h:148
Gaudi::Property< std::string > m_fieldMap
Definition G4AtlasAlg.h:119
ServiceHandle< ISF::ITruthSvc > m_truthRecordSvc
Central Truth Service.
Definition G4AtlasAlg.h:109
ServiceHandle< Simulation::IZeroLifetimePatcher > m_qspatcher
Quasi-Stable Particle Simulation Patcher.
Definition G4AtlasAlg.h:143
void commandLog(int returnCode, const std::string &commandString) const
This command prints a message about a G4Command depending on its returnCode.
std::map< std::string, std::string > m_verbosities
Verbosity settings for Geant4.
Definition G4AtlasAlg.h:112
Gaudi::Property< std::string > m_physList
Definition G4AtlasAlg.h:118
Gaudi::Property< bool > m_quietMode
Definition G4AtlasAlg.h:123
PublicToolHandle< ISensitiveDetectorMasterTool > m_senDetTool
Sensitive Detector Master Tool.
Definition G4AtlasAlg.h:152
Gaudi::Property< bool > m_useMT
Activate multi-threading configuration.
Definition G4AtlasAlg.h:127
G4AtlasAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard algorithm constructor.
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
Random number service.
Definition G4AtlasAlg.h:131
StatusCode execute(const EventContext &ctx) override
Simulate one Athena event.
StatusCode finalize() override
Finalize the algorithm and invoke G4 run termination.
BooleanProperty m_useShadowEvent
Definition G4AtlasAlg.h:129
ToolHandle< ISF::IGenEventFilter > m_truthPreselectionTool
Definition G4AtlasAlg.h:145
PublicToolHandleArray< IPhysicsInitializationTool > m_physicsInitializationTools
Definition G4AtlasAlg.h:140
Gaudi::Property< std::vector< std::string > > m_g4commands
Commands to send to the G4 UI.
Definition G4AtlasAlg.h:125
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition G4AtlasAlg.h:133
PublicToolHandle< IFastSimulationMasterTool > m_fastSimTool
Fast Simulation Master Tool.
Definition G4AtlasAlg.h:154
Gaudi::Property< bool > m_killAbortedEvents
Definition G4AtlasAlg.h:102
PublicToolHandleArray< G4UA::IUserActionTool > m_actionTools
Definition G4AtlasAlg.h:156
SG::ReadHandleKey< McEventCollection > m_inputTruthCollectionKey
input hard scatter collection
Definition G4AtlasAlg.h:104
PublicToolHandle< IDetectorConstructionTool > m_detConstruction
Definition G4AtlasAlg.h:139
Gaudi::Property< bool > m_activateParallelGeometries
Definition G4AtlasAlg.h:128
ServiceHandle< G4UA::IUserActionSvc > m_userActionSvc
User Action Service.
Definition G4AtlasAlg.h:137
ServiceHandle< IUserLimitsSvc > m_userLimitsSvc
Definition G4AtlasAlg.h:135
Gaudi::Property< std::string > m_libList
Definition G4AtlasAlg.h:117
void initializeG4()
Poorly named possibly unused method which sets some verbosities.
Gaudi::Property< bool > m_recordFlux
Definition G4AtlasAlg.h:122
SG::WriteHandleKey< McEventCollection > m_outputTruthCollectionKey
output hard scatter truth collection
Definition G4AtlasAlg.h:105
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition G4AtlasAlg.h:106
ServiceHandle< IPhysicsListSvc > m_physListSvc
Physics List Tool.
Definition G4AtlasAlg.h:150
Gaudi::Property< bool > m_releaseGeoModel
Definition G4AtlasAlg.h:121
Gaudi::Property< bool > m_flagAbortedEvents
Definition G4AtlasAlg.h:103
void initializeOnce()
G4 initialization called only by the first alg instance.
void finalizeOnce()
G4 finalization called only by the first alg instance.
void releaseGeoModel()
Releases the GeoModel geometry from memory once it has been used to build the G4 geometry and is no-l...
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
@ Core
Core flags describing the event.
@ Error
The sub-detector issued an error.
int maxGeneratedVertexBarcode(const HepMC::GenEvent *genEvent)
Get the maximal absolute value of barcode of vertex present in the event. Returns a negative number.
constexpr int UNDEFINED_ID
int maxGeneratedParticleBarcode(const HepMC::GenEvent *genEvent)
Get the maximal value of barcode of particle present in the event.
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39