ATLAS Offline Software
Tracking
Acts
ActsGeometry
src
ActsWriteTrackingGeometryTransforms.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// PACKAGE
6
#include "
ActsGeometry/ActsDetectorElement.h
"
7
#include "
ActsGeometry/ActsWriteTrackingGeometryTransforms.h
"
8
#include "
ActsGeometryInterfaces/IActsTrackingGeometrySvc.h
"
9
#include "
ActsGeometryInterfaces/ActsGeometryContext.h
"
10
11
12
// ATHENA
13
#include "
AthenaKernel/RNGWrapper.h
"
14
#include "
AthenaBaseComps/AthAlgorithm.h
"
15
#include "GaudiKernel/ISvcLocator.h"
16
#include "
ActsInterop/Logger.h
"
17
18
// ACTS
19
#include "Acts/Utilities/Logger.hpp"
20
#include "Acts/Geometry/TrackingGeometry.hpp"
21
#include "Acts/Surfaces/Surface.hpp"
22
#include "Acts/Geometry/GeometryIdentifier.hpp"
23
24
// STL
25
#include <string>
26
27
using
gid
= Acts::GeometryIdentifier;
28
29
ActsWriteTrackingGeometryTransforms::ActsWriteTrackingGeometryTransforms
(
const
std::string&
name
,
30
ISvcLocator* pSvcLocator)
31
:
AthAlgorithm
(
name
, pSvcLocator),m_pixelID(nullptr),m_SCT_ID(nullptr),
32
m_writeFullTransform(false)
33
{
34
}
35
36
StatusCode
ActsWriteTrackingGeometryTransforms::initialize
() {
37
38
// Grab PixelID helper
39
ATH_CHECK
(
detStore
()->
retrieve
(
m_pixelID
,
"PixelID"
) );
40
ATH_CHECK
(
detStore
()->
retrieve
(
m_SCT_ID
,
"SCT_ID"
) );
41
42
ATH_CHECK
(
m_trackingGeometryTool
.retrieve());
43
44
std::ofstream
os
(
m_outputName
);
// truncate
45
46
return
StatusCode::SUCCESS;
47
}
48
49
StatusCode
ActsWriteTrackingGeometryTransforms::execute
() {
50
51
ATH_MSG_DEBUG
(
"In ActsWriteTrackingGeometryTransforms::execute"
);
52
53
54
const
EventContext& ctx = Gaudi::Hive::currentContext();
55
56
auto
trackingGeometry =
m_trackingGeometryTool
->trackingGeometry();
57
ATH_MSG_DEBUG
(
"Retrieved tracking Geometry"
);
58
const
ActsGeometryContext
& gctx =
m_trackingGeometryTool
->getGeometryContext(ctx);
59
ATH_MSG_DEBUG
(
"Retrieved geometry context"
);
60
61
std::stringstream
ss
;
62
63
64
std::ofstream
os
(
m_outputName
, std::ios_base::app);
65
66
trackingGeometry->visitSurfaces([&] (
const
Acts::Surface* srf) {
67
const
Acts::DetectorElementBase *detElem = srf->associatedDetectorElement();
68
const
auto
*gmde =
static_cast<
const
ActsDetectorElement
*
>
(detElem);
69
70
Identifier
ath_geoid = gmde->identify();
71
72
if
(
dynamic_cast<
const
InDetDD::TRT_BaseElement
*
>
(gmde->upstreamDetectorElement()) !=
nullptr
) {
73
return
;
74
}
75
76
if
(
dynamic_cast<
const
InDetDD::HGTD_DetectorElement
*
>
(gmde->upstreamDetectorElement()) !=
nullptr
) {
77
return
;
78
}
79
80
const
auto
sil_de =
dynamic_cast<
const
InDetDD::SiDetectorElement
*
>
(gmde->upstreamDetectorElement());
81
if
(sil_de ==
nullptr
) {
82
throw
std::runtime_error{
"Not TRT, Not HGTD and not Si either"
};
// this shouldn't happen
83
}
84
85
gid
geoID = srf->geometryId();
86
87
os
<< geoID.volume() <<
";"
;
88
os
<< geoID.boundary() <<
";"
;
89
os
<< geoID.layer() <<
";"
;
90
os
<< geoID.sensitive() <<
";"
;
91
92
os
<< ctx.eventID().event_number() <<
";"
;
93
94
int
bec
,
ld
,etam,phim,
side
;
95
96
if
(sil_de->isPixel()) {
97
bec
=
m_pixelID
->
barrel_ec
(ath_geoid);
98
ld
=
m_pixelID
->
layer_disk
(ath_geoid);
99
etam =
m_pixelID
->
eta_module
(ath_geoid);
100
phim =
m_pixelID
->
phi_module
(ath_geoid);
101
side
= 0;
102
os
<< 0;
103
}
104
else
if
(sil_de->isSCT()) {
105
106
bec
=
m_SCT_ID
->
barrel_ec
(ath_geoid);
107
ld
=
m_SCT_ID
->
layer_disk
(ath_geoid);
108
etam =
m_SCT_ID
->
eta_module
(ath_geoid);
109
phim =
m_SCT_ID
->
phi_module
(ath_geoid);
110
side
=
m_SCT_ID
->
side
(ath_geoid);
111
os
<< 1;
112
}
113
else
{
114
throw
std::runtime_error{
"The Detector Element is neither Pixel nor SCT"
};
// this shouldn't happen
115
}
116
// Write the type of silicon first (0=PIX, 1=SCT)
117
os
<<
";"
;
118
119
// Then write the athena geoid and the unpacked version
120
os
<<ath_geoid<<
","
<<
bec
<<
","
<<
ld
<<
","
<<etam<<
","
<<phim<<
","
<<
side
<<
";"
;
121
122
ATH_MSG_DEBUG
(geoID<<
" "
<<ath_geoid<<
" "
<<
bec
<<
" "
<<
ld
<<
" "
<<etam<<
" "
<<phim<<
" "
<<
side
);
123
124
const
ActsGeometryContext
void_gctx;
125
if
(
m_writeFullTransform
) {
126
// iterate over components of transform
127
const
auto
*
p
= srf->transform(gctx.
context
()).data();
128
for
(
size_t
i
=0;
i
<16;
i
++) {
129
if
(
i
>0) {
130
os
<<
","
;
131
}
132
os
<< *(
p
+
i
);
133
}
134
}
else
{
// only write center of the detector element
135
double
cx
= srf->center(void_gctx.
context
()).
x
();
136
double
cy
= srf->center(void_gctx.
context
()).
y
();
137
double
cz = srf->center(void_gctx.
context
()).
z
();
138
os
<<
cx
<<
","
<<
cy
<<
","
<<cz;
139
}
140
141
os
<<
"\n"
;
142
});
143
144
145
return
StatusCode::SUCCESS;
146
}
147
148
StatusCode
ActsWriteTrackingGeometryTransforms::finalize
() {
149
return
StatusCode::SUCCESS;
150
}
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition:
PyKernel.py:110
PowhegControl_ttHplus_NLO.ss
ss
Definition:
PowhegControl_ttHplus_NLO.py:83
ActsGeometryContext.h
ParticleGun_SamplingFraction.bec
int bec
Definition:
ParticleGun_SamplingFraction.py:89
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition:
PixelID.h:619
ActsWriteTrackingGeometryTransforms::ActsWriteTrackingGeometryTransforms
ActsWriteTrackingGeometryTransforms(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
ActsWriteTrackingGeometryTransforms.cxx:29
InDetDD::HGTD_DetectorElement
Definition:
HGTD_DetectorElement.h:40
ActsWriteTrackingGeometryTransforms::m_trackingGeometryTool
ToolHandle< IActsTrackingGeometryTool > m_trackingGeometryTool
Definition:
ActsWriteTrackingGeometryTransforms.h:47
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition:
SCT_ID.h:728
ActsWriteTrackingGeometryTransforms::m_outputName
Gaudi::Property< std::string > m_outputName
Definition:
ActsWriteTrackingGeometryTransforms.h:49
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition:
SCT_ID.h:740
x
#define x
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition:
AthCommonDataStore.h:95
TRT::Hit::side
@ side
Definition:
HitInfo.h:83
AthAlgorithm.h
ActsGeometryContext::context
Acts::GeometryContext context() const
Definition:
ActsGeometryContext.h:45
PlotCalibFromCool.cx
cx
Definition:
PlotCalibFromCool.py:666
python.utils.AtlRunQueryDQUtils.p
p
Definition:
AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition:
lumiFormat.py:85
z
#define z
ActsWriteTrackingGeometryTransforms::initialize
virtual StatusCode initialize() override
Definition:
ActsWriteTrackingGeometryTransforms.cxx:36
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
IActsTrackingGeometrySvc.h
ActsWriteTrackingGeometryTransforms::execute
virtual StatusCode execute() override
Definition:
ActsWriteTrackingGeometryTransforms.cxx:49
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
ActsDetectorElement
Definition:
ActsDetectorElement.h:42
ActsWriteTrackingGeometryTransforms::m_writeFullTransform
Gaudi::Property< bool > m_writeFullTransform
Definition:
ActsWriteTrackingGeometryTransforms.h:50
ActsDetectorElement.h
gid
Acts::GeometryIdentifier gid
Definition:
ActsWriteTrackingGeometryTransforms.cxx:27
ReadFromCoolCompare.os
os
Definition:
ReadFromCoolCompare.py:231
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition:
ActsGeometryContext.h:27
AthAlgorithm
Definition:
AthAlgorithm.h:47
ActsWriteTrackingGeometryTransforms::m_pixelID
const PixelID * m_pixelID
Definition:
ActsWriteTrackingGeometryTransforms.h:44
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition:
PixelID.h:626
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition:
PixelID.h:651
ActsWriteTrackingGeometryTransforms::m_SCT_ID
const SCT_ID * m_SCT_ID
Definition:
ActsWriteTrackingGeometryTransforms.h:45
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:221
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition:
SCT_ID.h:734
InDetDD::SiDetectorElement
Definition:
SiDetectorElement.h:109
RNGWrapper.h
y
#define y
PlotCalibFromCool.cy
cy
Definition:
PlotCalibFromCool.py:667
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition:
SCT_ID.h:746
ActsWriteTrackingGeometryTransforms::finalize
virtual StatusCode finalize() override
Definition:
ActsWriteTrackingGeometryTransforms.cxx:148
SCT_ID::side
int side(const Identifier &id) const
Definition:
SCT_ID.h:752
Logger.h
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition:
PixelID.h:644
geometry_dat_to_json.ld
ld
Definition:
geometry_dat_to_json.py:32
InDetDD::TRT_BaseElement
Definition:
TRT_BaseElement.h:57
ActsWriteTrackingGeometryTransforms.h
Identifier
Definition:
IdentifierFieldParser.cxx:14
Generated on Thu Nov 7 2024 21:09:31 for ATLAS Offline Software by
1.8.18