ATLAS Offline Software
G4AtlasDetectorConstructionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Include files
6 
7 // local
9 
10 //-----------------------------------------------------------------------------
11 // Implementation file for class : G4AtlasDetectorConstructionTool
12 //
13 // 2014-10-03: Andrea Dell'Acqua
14 //-----------------------------------------------------------------------------
15 
16 
17 //=================================
18 // Standard constructor, initializes variables
19 //=================================
21  const std::string& nam,const IInterface* parent )
22  : base_class( type, nam , parent )
23 {
24 }
25 
26 //=================================
27 // Athena method overrides
28 //=================================
30 {
31  ATH_MSG_DEBUG( "Initializing Geometry configuration tools " );
32  for (auto it: m_configurationTools)
33  {
34  ATH_CHECK( it.retrieve() );
35  ATH_CHECK( it->preGeometryConfigure() );
36  }
37 
38  ATH_MSG_DEBUG( "Initializing World detectors in " << name() );
39  ATH_CHECK( m_detTool.retrieve() );
40 
41  ATH_MSG_DEBUG( "Initializing sensitive detectors in " << name() );
42  ATH_CHECK( m_senDetTool.retrieve() );
43 
44  ATH_MSG_DEBUG( "Setting up G4 physics regions" );
45  for (auto& it: m_regionCreators)
46  {
47  ATH_CHECK( it.retrieve() );
48  }
49 
51  {
52  ATH_MSG_DEBUG( "Setting up G4 parallel worlds" );
53  for (auto& it: m_parallelWorlds)
54  {
55  ATH_CHECK( it.retrieve() );
56  }
57  }
58 
59  ATH_MSG_DEBUG( "Setting up field managers" );
60  ATH_CHECK( m_fieldManagers.retrieve() );
61 
62  ATH_CHECK( m_G4CaloTransportTool.retrieve( DisableTool{ m_G4CaloTransportTool.empty() } ) );
63 
64  return StatusCode::SUCCESS;
65 }
66 
68 {
69  return m_parallelWorldNames;
70 }
71 
72 //=================================
73 // G4VUserDetectorConstruction method overrides
74 //=================================
76 {
77  ATH_MSG_DEBUG( "Detectors " << m_detTool.name() <<" being set as World" );
78  m_detTool->SetAsWorld();
79  m_detTool->Build();
80 
81  ATH_MSG_DEBUG( "Setting up G4 physics regions" );
82  for (auto& it: m_regionCreators)
83  {
84  it->Construct();
85  }
86 
88  {
89  ATH_MSG_DEBUG( "Setting up G4 parallel worlds" );
90  for (auto& it: m_parallelWorlds)
91  {
92  m_parallelWorldNames.push_back(it.name());
93  this->RegisterParallelWorld(it->GetParallelWorld());
94  }
95  }
96 
97  ATH_MSG_DEBUG( "Running geometry post-configuration tools" );
98  for (auto it: m_configurationTools)
99  {
100  StatusCode sc = it->postGeometryConfigure();
101  if (!sc.isSuccess())
102  {
103  ATH_MSG_FATAL( "Unable to run post-geometry configuration for " << it->name() );
104  }
105  }
106 
107  return m_detTool->GetWorldVolume();
108 }
109 
111 {
112  ATH_MSG_DEBUG( "Setting up sensitive detectors" );
113  if (m_senDetTool->initializeSDs().isFailure())
114  {
115  ATH_MSG_FATAL("Failed to initialize SDs for worker thread");
116  }
117 
118  ATH_MSG_DEBUG( "Setting up field managers" );
119  for (auto& fm : m_fieldManagers)
120  {
121  StatusCode sc = fm->initializeField();
122  if (!sc.isSuccess())
123  {
124  ATH_MSG_FATAL( "Unable to initialise field with " << fm->name() );
125  return;
126  }
127  }
128 
129  if (m_G4CaloTransportTool.isEnabled()){
130  ATH_MSG_DEBUG("Setting up G4CaloTransportTool");
131  if (m_G4CaloTransportTool->initializePropagator().isFailure())
132  {
133  ATH_MSG_FATAL("Failed to initialize G4CaloTransportTool for worker thread.");
134  return;
135  }
136  }
137 
138  return;
139 }
G4AtlasDetectorConstructionTool::Construct
virtual G4VPhysicalVolume * Construct() override final
Implements the following G4VUserDetectorConstruction methods.
Definition: G4AtlasDetectorConstructionTool.cxx:75
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
G4AtlasDetectorConstructionTool::m_fieldManagers
ToolHandleArray< IFieldManagerTool > m_fieldManagers
Definition: G4AtlasDetectorConstructionTool.h:60
G4AtlasDetectorConstructionTool::G4AtlasDetectorConstructionTool
G4AtlasDetectorConstructionTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: G4AtlasDetectorConstructionTool.cxx:20
G4AtlasDetectorConstructionTool::m_detTool
ToolHandle< IDetectorGeometryTool > m_detTool
Definition: G4AtlasDetectorConstructionTool.h:55
skel.it
it
Definition: skel.GENtoEVGEN.py:423
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
G4AtlasDetectorConstructionTool::m_senDetTool
PublicToolHandle< ISensitiveDetectorMasterTool > m_senDetTool
Definition: G4AtlasDetectorConstructionTool.h:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
G4AtlasDetectorConstructionTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
G4AtlasDetectorConstructionTool::m_parallelWorlds
ToolHandleArray< IParallelWorldTool > m_parallelWorlds
Definition: G4AtlasDetectorConstructionTool.h:57
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
G4AtlasDetectorConstructionTool::m_activateParallelWorlds
Gaudi::Property< bool > m_activateParallelWorlds
Definition: G4AtlasDetectorConstructionTool.h:62
G4AtlasDetectorConstructionTool::ConstructSDandField
virtual void ConstructSDandField() override final
Definition: G4AtlasDetectorConstructionTool.cxx:110
G4AtlasDetectorConstructionTool::m_regionCreators
ToolHandleArray< IRegionCreator > m_regionCreators
Definition: G4AtlasDetectorConstructionTool.h:56
G4AtlasDetectorConstructionTool::m_configurationTools
ToolHandleArray< IG4GeometryConfigurationTool > m_configurationTools
Definition: G4AtlasDetectorConstructionTool.h:58
G4AtlasDetectorConstructionTool::initialize
virtual StatusCode initialize() override final
Initialize method.
Definition: G4AtlasDetectorConstructionTool.cxx:29
G4AtlasDetectorConstructionTool::m_parallelWorldNames
std::vector< std::string > m_parallelWorldNames
Definition: G4AtlasDetectorConstructionTool.h:63
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
G4AtlasDetectorConstructionTool::GetParallelWorldNames
virtual std::vector< std::string > & GetParallelWorldNames() override final
Definition: G4AtlasDetectorConstructionTool.cxx:67
G4AtlasDetectorConstructionTool::m_G4CaloTransportTool
PublicToolHandle< IG4CaloTransportTool > m_G4CaloTransportTool
Definition: G4AtlasDetectorConstructionTool.h:61