ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
Geo2G4
src
GDMLDetectorTool.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
// Base class
6
#include "
G4AtlasTools/DetectorGeometryBase.h
"
7
#include "
GDMLDetectorTool.h
"
8
9
#include "G4GDMLParser.hh"
10
#include "G4NistManager.hh"
11
#include "G4LogicalVolume.hh"
12
#include "G4PVPlacement.hh"
13
14
// Geant4 includes used in functions
15
16
GDMLDetectorTool::GDMLDetectorTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent)
17
:
DetectorGeometryBase
(
type
,name,parent),
m_blGetTopTransform
(true)
18
{
19
m_topTransform
.setIdentity();
20
ATH_MSG_DEBUG
(
"GDMLDetectorTool constructor for "
<< name );
21
}
22
23
StatusCode
GDMLDetectorTool::initialize
()
24
{
25
ATH_MSG_DEBUG
( name() <<
" GDMLDetectorTool::initialize(): Starting"
);
26
27
if
(
m_detectorName
.empty())
28
{
29
m_detectorName
= this->name();
30
// re-initialize m_detectorName in order to take the real detector name rather than the path to it
31
size_t
ipos=
m_detectorName
.value().find_last_of(
'.'
);
32
size_t
length
=
m_detectorName
.value().size();
33
if
(ipos<
length
)
34
{
35
ATH_MSG_DEBUG
(
"m_detectorName: "
<<
m_detectorName
.value() <<
" needs to be reset."
);
36
m_detectorName
=
m_detectorName
.value().substr(ipos+1,
length
-ipos-1);
37
ATH_MSG_DEBUG
(
"m_detectorName default value reset to "
<<
m_detectorName
.value());
38
}
39
}
40
ATH_MSG_DEBUG
( name() <<
"GDMLDetectorTool::initialize() : Detector name = "
<<
m_detectorName
.value()<<
" File name: "
<<
m_GDMLFileName
);
41
if
(
m_geoDetectorName
.empty())
42
{
43
m_geoDetectorName
=
m_detectorName
.value();
44
}
45
if
(
m_GDMLFileName
.empty())
46
{
47
m_GDMLFileName
=
m_detectorName
.value()+
".gdml"
;
48
}
49
ATH_MSG_DEBUG
( name() <<
"GDMLDetectorTool::initialize() : Geo Detector name = "
<<
m_geoDetectorName
<<
" File name: "
<<
m_GDMLFileName
);
50
51
ATH_MSG_DEBUG
( name() <<
" GDMLDetectorTool::initialize(): Finished"
);
52
return
StatusCode::SUCCESS;
53
}
54
55
56
void
GDMLDetectorTool::BuildGeometry
()
57
{
58
ATH_MSG_VERBOSE
( name() <<
" GDMLDetectorTool::BuildGeometry(): Starting"
);
59
60
G4GDMLParser parser;
61
parser.Read(
m_GDMLFileName
.value().c_str(),
false
);
62
m_envelope
.theEnvelope=parser.GetWorldVolume()->GetLogicalVolume();
63
64
ATH_MSG_VERBOSE
( name() <<
" GDMLDetectorTool::BuildGeometry(): Finished"
);
65
}
66
67
bool
GDMLDetectorTool::IsTopTransform
()
68
{
69
return
m_blGetTopTransform
;
70
}
71
72
void
GDMLDetectorTool::SetInitialTransformation
()
73
{
74
ATH_MSG_VERBOSE
( name() <<
" GDMLDetectorTool::SetInitialTransformation(): Starting"
);
75
if
(!
m_envelope
.theRotation)
76
{
77
ATH_MSG_VERBOSE
( name() <<
" GDMLDetectorTool::SetInitialTransformation(): Creating new G4RotationMatrix"
);
78
m_envelope
.theRotation=
new
G4RotationMatrix;
79
}
80
*(
m_envelope
.theRotation)=
m_topTransform
.getRotation().inverse();
81
m_envelope
.thePosition=
m_topTransform
.getTranslation();
82
ATH_MSG_VERBOSE
( name() <<
" GDMLDetectorTool::SetInitialTransformation(): Finished"
);
83
}
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DetectorGeometryBase.h
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
GDMLDetectorTool.h
DetectorGeometryBase::DetectorGeometryBase
DetectorGeometryBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition
DetectorGeometryBase.cxx:13
DetectorGeometryBase::m_envelope
Envelope m_envelope
Definition
DetectorGeometryBase.h:70
DetectorGeometryBase::m_detectorName
Gaudi::Property< std::string > m_detectorName
Definition
DetectorGeometryBase.h:71
GDMLDetectorTool::m_blGetTopTransform
bool m_blGetTopTransform
Definition
GDMLDetectorTool.h:52
GDMLDetectorTool::m_GDMLFileName
Gaudi::Property< std::string > m_GDMLFileName
Definition
GDMLDetectorTool.h:47
GDMLDetectorTool::IsTopTransform
bool IsTopTransform()
Definition
GDMLDetectorTool.cxx:67
GDMLDetectorTool::m_topTransform
G4Transform3D m_topTransform
Definition
GDMLDetectorTool.h:53
GDMLDetectorTool::GDMLDetectorTool
GDMLDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
GDMLDetectorTool.cxx:16
GDMLDetectorTool::BuildGeometry
virtual void BuildGeometry() override final
virtual methods being implemented here
Definition
GDMLDetectorTool.cxx:56
GDMLDetectorTool::SetInitialTransformation
void SetInitialTransformation()
Definition
GDMLDetectorTool.cxx:72
GDMLDetectorTool::m_geoDetectorName
Gaudi::Property< std::string > m_geoDetectorName
Definition
GDMLDetectorTool.h:48
GDMLDetectorTool::initialize
virtual StatusCode initialize() override final
Athena method.
Definition
GDMLDetectorTool.cxx:23
type
Generated on
for ATLAS Offline Software by
1.17.0