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 "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 34 of file G4RunAlg.cxx.

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

Variable Documentation

◆ releaseGeoModelOnceFlag

std::once_flag releaseGeoModelOnceFlag
static

Definition at line 30 of file G4RunAlg.cxx.