ATLAS Offline Software
Loading...
Searching...
No Matches
G4AtlasAlg.cxx File Reference
#include "G4AtlasAlg.h"
#include "G4AtlasFluxRecorder.h"
#include "G4AtlasTools/G4AtlasActionInitialization.h"
#include "AthenaKernel/RNGWrapper.h"
#include "CxxUtils/checker_macros.h"
#include "G4AtlasAlg/G4AtlasMTRunManager.h"
#include "G4AtlasAlg/G4AtlasRunManager.h"
#include "G4AtlasAlg/G4AtlasUserWorkerThreadInitialization.h"
#include "G4AtlasAlg/G4AtlasWorkerRunManager.h"
#include <G4Event.hh>
#include "G4EventManager.hh"
#include "G4GDMLParser.hh"
#include "G4Navigator.hh"
#include "G4ParallelWorldPhysics.hh"
#include "G4PropagatorInField.hh"
#include "G4RunManagerKernel.hh"
#include "G4ScoringManager.hh"
#include "G4StackManager.hh"
#include "G4StateManager.hh"
#include "G4TrackingManager.hh"
#include "G4TransportationManager.hh"
#include "G4UImanager.hh"
#include "G4VModularPhysicsList.hh"
#include "G4VUserPhysicsList.hh"
#include "CLHEP/Random/RandomEngine.h"
#include "GaudiKernel/IThreadInitTool.h"
#include "GeneratorObjects/HepMcParticleLink.h"
#include "GeoModelInterfaces/IGeoModelSvc.h"
#include "HitManagement/HitCollectionMap.h"
#include "MCTruth/AtlasG4EventUserInfo.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 G4AtlasAlg::initialize ATLAS_NOT_THREAD_SAFE ()
 Install fatal handler with default options.

Variables

static std::once_flag initializeOnceFlag
static std::once_flag finalizeOnceFlag
static std::once_flag releaseGeoModelOnceFlag

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

StatusCode G4AtlasAlg::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 71 of file G4AtlasAlg.cxx.

72{
73 ATH_MSG_DEBUG("Start of initialize()");
74
75 // Read the simplified geometry for FastCaloSim track transportation if requested
76 if(!m_simplifiedGeoPath.empty()) {
77 std::string geoFile = PathResolverFindCalibFile(m_simplifiedGeoPath);
78
79 if (geoFile.empty()) {
80 ATH_MSG_FATAL("Could not find simplified geometry file: " << m_simplifiedGeoPath);
81 return StatusCode::FAILURE;
82 }
83
84 G4GDMLParser parser;
85 parser.Read(geoFile, false);
86 }
87
88 // Create the scoring manager if requested
89 if (m_recordFlux) G4ScoringManager::GetScoringManager();
90
91 ATH_CHECK( m_userActionSvc.retrieve() );
92 // One-time initialization
93 try {
94 std::call_once(initializeOnceFlag, &G4AtlasAlg::initializeOnce, this);
95 }
96 catch(const std::exception& e) {
97 ATH_MSG_ERROR("Failure in G4AtlasAlg::initializeOnce: " << e.what());
98 return StatusCode::FAILURE;
99 }
100
101 ATH_CHECK( m_rndmGenSvc.retrieve() );
102 ATH_CHECK(m_actionTools.retrieve());
103
104 ATH_CHECK(m_senDetTool.retrieve());
105 ATH_CHECK(m_fastSimTool.retrieve());
106
107 // Truth
108 ATH_CHECK( m_truthRecordSvc.retrieve() );
109 ATH_MSG_INFO( "- Using ISF TruthRecordSvc : " << m_truthRecordSvc.typeAndName() );
110 ATH_CHECK( m_geoIDSvc.retrieve() );
111 ATH_MSG_INFO( "- Using ISF GeoIDSvc : " << m_geoIDSvc.typeAndName() );
112
113 TruthStrategyManager& sManager = TruthStrategyManager::GetStrategyManager_nc();
114 sManager.SetISFTruthSvc( &(*m_truthRecordSvc) );
115 sManager.SetISFGeoIDSvc( &(*m_geoIDSvc) );
116
117 // I/O
118 ATH_CHECK( m_inputTruthCollectionKey.initialize());
119 ATH_CHECK( m_outputTruthCollectionKey.initialize());
120 ATH_CHECK( m_eventInfoKey.initialize() );
121
122 ATH_CHECK(m_inputConverter.retrieve());
123 if ( not m_truthPreselectionTool.empty() ) {
124 ATH_CHECK(m_truthPreselectionTool.retrieve());
125 }
126
127 if ( not m_qspatcher.empty() ) {
128 ATH_CHECK( m_qspatcher.retrieve() );
129 }
130
131 ATH_MSG_DEBUG("End of initialize()");
132 return StatusCode::SUCCESS;
133}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static std::once_flag initializeOnceFlag
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void initializeOnce()
G4 initialization called only by the first alg instance.
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

◆ finalizeOnceFlag

std::once_flag finalizeOnceFlag
static

Definition at line 55 of file G4AtlasAlg.cxx.

◆ initializeOnceFlag

std::once_flag initializeOnceFlag
static

Definition at line 54 of file G4AtlasAlg.cxx.

◆ releaseGeoModelOnceFlag

std::once_flag releaseGeoModelOnceFlag
static

Definition at line 56 of file G4AtlasAlg.cxx.