ATLAS Offline Software
Loading...
Searching...
No Matches
G4RunAlg.cxx File Reference
#include "G4RunAlg.h"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4GDMLParser.hh"
#include "G4TrackingManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4GeometryManager.hh"
#include "AthenaKernel/RNGWrapper.h"
#include "GeneratorObjects/HepMcParticleLink.h"
#include "GeoModelInterfaces/IGeoModelSvc.h"
#include "G4RunManagement/AtlasG4SyncEventUserInfo.h"
#include "HitManagement/HitCollectionMap.h"
#include "MCTruthBase/TruthStrategyManager.h"
#include "PathResolver/PathResolver.h"
#include "StoreGate/ReadHandle.h"
#include "StoreGate/WriteHandle.h"
#include <memory>
#include <mutex>

Go to the source code of this file.

Functions

StatusCode G4RunAlg::initialize ATLAS_NOT_THREAD_SAFE ()
 Install fatal handler with default options.

Variables

static std::once_flag releaseGeoModelOnceFlag

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

StatusCode G4RunAlg::initialize ATLAS_NOT_THREAD_SAFE ( )
inline

Install fatal handler with default options.

This is meant to be easy to call from python via ctypes.

Definition at line 35 of file G4RunAlg.cxx.

36{
37 ATH_MSG_DEBUG("Start of G4RunAlg::initialize()");
38
39 // Read the simplified geometry for FastCaloSim track transportation if requested
40 // TODO: should be moved to Geant4 main thread (detector construction)
41 if(!m_simplifiedGeoPath.empty()) {
42 std::string geoFile = PathResolverFindCalibFile(m_simplifiedGeoPath);
43 if (geoFile.empty()) {
44 ATH_MSG_FATAL("Could not find simplified geometry file: " << m_simplifiedGeoPath);
45 return StatusCode::FAILURE;
46 }
47 G4GDMLParser parser;
48 parser.Read(geoFile, false);
49 }
50
51 // Truth services
52 ATH_CHECK(m_truthRecordSvc.retrieve());
53 ATH_MSG_INFO("- Using ISF TruthRecordSvc : " << m_truthRecordSvc.typeAndName());
54 ATH_CHECK(m_geoIDSvc.retrieve());
55 ATH_MSG_INFO("- Using ISF GeoIDSvc : " << m_geoIDSvc.typeAndName());
56
57 TruthStrategyManager& sManager = TruthStrategyManager::GetStrategyManager_nc();
58 sManager.SetISFTruthSvc(&(*m_truthRecordSvc));
59 sManager.SetISFGeoIDSvc(&(*m_geoIDSvc));
60
61 // Retrieve the G4RunTool. This will start the G4 main thread
62 ATH_CHECK(m_g4RunTool.retrieve());
63 ATH_MSG_INFO("Waiting on G4RunTool to be ready for run");
64 // We have to wait on the Geant4 main thread to finish initializing.
65 // Wait has to be done here because Gaudi tool initialization are protected by a recursive mutex
66 // which would lead to a deadlock between the Geant4 main thread and the Athena thread
67 m_g4RunTool->WaitBeginRun();
68
69 // Initialize algorithm-specific services
70 ATH_CHECK(m_rndmGenSvc.retrieve());
71 ATH_CHECK(m_userActionSvc.retrieve());
72 // These have already been initialized by G4RunTool, just populate the handles
73 ATH_CHECK(m_senDetTool.retrieve());
74 ATH_CHECK(m_fastSimTool.retrieve());
75
76 // I/O
77 ATH_CHECK(m_inputTruthCollectionKey.initialize());
78 ATH_CHECK(m_outputTruthCollectionKey.initialize());
79 ATH_CHECK(m_eventInfoKey.initialize());
80
81 ATH_CHECK(m_inputConverter.retrieve());
82 if (!m_truthPreselectionTool.empty()) {
83 ATH_CHECK(m_truthPreselectionTool.retrieve());
84 }
85
86 if (!m_qspatcher.empty()) {
87 ATH_CHECK(m_qspatcher.retrieve());
88 }
89
90 ATH_MSG_DEBUG("End of G4RunAlg::initialize()");
91 return StatusCode::SUCCESS;
92}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Singleton class for creating truth incidents.
void SetISFGeoIDSvc(ISF::IGeoIDSvc *geoIDSvc)
Define which ISF GeoIDSvc to use.
void SetISFTruthSvc(ISF::ITruthSvc *truthSvc)
Define which ISF TruthService to use.

Variable Documentation

◆ releaseGeoModelOnceFlag

std::once_flag releaseGeoModelOnceFlag
static

Definition at line 31 of file G4RunAlg.cxx.