ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
Geo2G4
src
GeoDetectorTool.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 "
GeoDetectorTool.h
"
8
#include "
Geo2G4Builder.h
"
9
#include "
VolumeBuilder.h
"
10
11
#include "G4NistManager.hh"
12
#include "G4LogicalVolume.hh"
13
#include "G4PVPlacement.hh"
14
#include "G4GDMLParser.hh"
15
16
// Geant4 includes used in functions
17
18
GeoDetectorTool::GeoDetectorTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent)
19
:
DetectorGeometryBase
(
type
,name,parent)
20
{
21
m_topTransform
.setIdentity();
22
ATH_MSG_DEBUG
(
"GeoDetectorTool constructor for "
<< name );
23
}
24
25
StatusCode
GeoDetectorTool::initialize
()
26
{
27
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::initialize(): Starting"
);
28
if
(
m_detectorName
.empty())
29
{
30
m_detectorName
= this->name();
31
// re-initialize m_detectorName in order to take the real detector name rather than the path to it
32
size_t
ipos=
m_detectorName
.value().find_last_of(
'.'
);
33
size_t
length
=
m_detectorName
.value().size();
34
if
(ipos<
length
)
35
{
36
ATH_MSG_VERBOSE
(
"m_detectorName: "
<<
m_detectorName
.value() <<
" needs to be reset."
);
37
m_detectorName
=
m_detectorName
.value().substr(ipos+1,
length
-ipos-1);
38
ATH_MSG_VERBOSE
(
"m_detectorName default value reset to "
<<
m_detectorName
.value());
39
}
40
}
41
ATH_MSG_DEBUG
( name() <<
"GeoDetectorTool::initialize() : Detector name = "
<<
m_detectorName
.value() );
42
if
(
m_geoDetectorName
.empty())
43
{
44
m_geoDetectorName
=
m_detectorName
.value();
45
}
46
ATH_MSG_DEBUG
( name() <<
"GeoDetectorTool::initialize() : Geo Detector name = "
<<
m_geoDetectorName
);
47
48
ATH_CHECK
(
m_geo2G4Svc
.retrieve());
49
m_builderName
=
m_geo2G4Svc
->GetDefaultBuilder()->GetKey();
50
m_blGetTopTransform
=
m_geo2G4Svc
->UseTopTransforms();
51
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::initialize(): Finished"
);
52
return
StatusCode::SUCCESS;
53
}
54
55
56
void
GeoDetectorTool::BuildGeometry
()
57
{
58
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::BuildGeometry(): Starting"
);
59
G4LogicalVolume* temp = this->
Convert
();
60
m_envelope
.theEnvelope=temp;
61
62
if
(this->
IsTopTransform
())
63
{
64
this->
SetInitialTransformation
();
65
}
66
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::BuildGeometry(): Finished"
);
67
}
68
69
void
GeoDetectorTool::PositionInParent
()
70
{
71
ATH_MSG_DEBUG
( name() <<
" GeoDetectorTool::PositionInParent(): Starting"
);
72
73
DetectorGeometryBase::PositionInParent
();
74
if
(!
m_dumpGDMLFile
.empty()) {
75
G4GDMLParser parser;
76
parser.Write(
m_dumpGDMLFile
.value(),
m_envelope
.thePositionedVolume);
77
}
78
}
79
80
G4LogicalVolume*
GeoDetectorTool::Convert
()
81
{
82
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::Convert(): Starting"
);
83
ATH_MSG_DEBUG
( name() <<
" GeoDetectorTool::Convert(): GeoDetectorName:builderName = "
<<
m_geoDetectorName
<<
":"
<<
m_builderName
);
84
Geo2G4Builder
Builder
(
m_geoDetectorName
);
85
VolumeBuilder
*b=
Builder
.GetVolumeBuilder(
m_builderName
);
86
b->SetParam(
m_blParamOn
);
87
G4LogicalVolume *temp=
Builder
.BuildTree();
88
if
(this->
IsTopTransform
())
89
{
90
m_topTransform
=
Builder
.GetDetectorTransform();
91
}
92
93
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::Convert(): Finished"
);
94
return
temp;
95
}
96
97
bool
GeoDetectorTool::IsTopTransform
()
98
{
99
return
m_blGetTopTransform
;
100
}
101
102
void
GeoDetectorTool::SetInitialTransformation
()
103
{
104
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::SetInitialTransformation(): Starting"
);
105
if
(!
m_envelope
.theRotation)
106
{
107
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::SetInitialTransformation(): Creating new G4RotationMatrix"
);
108
m_envelope
.theRotation=
new
G4RotationMatrix;
109
}
110
*(
m_envelope
.theRotation)=
m_topTransform
.getRotation().inverse();
111
m_envelope
.thePosition=
m_topTransform
.getTranslation();
112
ATH_MSG_VERBOSE
( name() <<
" GeoDetectorTool::SetInitialTransformation(): Finished"
);
113
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
DetectorGeometryBase.h
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
Geo2G4Builder.h
GeoDetectorTool.h
VolumeBuilder.h
Builder
Definition
CaloSwEtamod_v2.h:123
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
DetectorGeometryBase::PositionInParent
virtual void PositionInParent() override
Definition
DetectorGeometryBase.cxx:120
Geo2G4Builder
Main builder to create/position all volumes described in a GeoModel Tree.
Definition
Geo2G4Builder.h:33
GeoDetectorTool::m_topTransform
G4Transform3D m_topTransform
Definition
GeoDetectorTool.h:61
GeoDetectorTool::m_blGetTopTransform
bool m_blGetTopTransform
Definition
GeoDetectorTool.h:60
GeoDetectorTool::Convert
G4LogicalVolume * Convert()
Definition
GeoDetectorTool.cxx:80
GeoDetectorTool::GeoDetectorTool
GeoDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
GeoDetectorTool.cxx:18
GeoDetectorTool::m_builderName
std::string m_builderName
Definition
GeoDetectorTool.h:58
GeoDetectorTool::IsTopTransform
bool IsTopTransform()
Definition
GeoDetectorTool.cxx:97
GeoDetectorTool::m_geo2G4Svc
ServiceHandle< IGeo2G4Svc > m_geo2G4Svc
Definition
GeoDetectorTool.h:55
GeoDetectorTool::BuildGeometry
virtual void BuildGeometry() override final
virtual methods being implemented here
Definition
GeoDetectorTool.cxx:56
GeoDetectorTool::initialize
virtual StatusCode initialize() override final
Athena method.
Definition
GeoDetectorTool.cxx:25
GeoDetectorTool::m_geoDetectorName
Gaudi::Property< std::string > m_geoDetectorName
Definition
GeoDetectorTool.h:54
GeoDetectorTool::m_blParamOn
bool m_blParamOn
Definition
GeoDetectorTool.h:59
GeoDetectorTool::SetInitialTransformation
void SetInitialTransformation()
Definition
GeoDetectorTool.cxx:102
GeoDetectorTool::PositionInParent
virtual void PositionInParent() override final
Definition
GeoDetectorTool.cxx:69
GeoDetectorTool::m_dumpGDMLFile
Gaudi::Property< std::string > m_dumpGDMLFile
Definition
GeoDetectorTool.h:53
VolumeBuilder
Definition
Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h:20
type
Generated on
for ATLAS Offline Software by
1.17.0