ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsGeometry
src
ActsWriteTrackingGeometryTransforms.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
// PACKAGE
6
#include "
ActsGeometry/ActsDetectorElement.h
"
7
#include "
ActsWriteTrackingGeometryTransforms.h
"
8
#include "
ActsGeometryInterfaces/ITrackingGeometrySvc.h
"
9
#include "
ActsGeometryInterfaces/GeometryContext.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
#include "
HGTD_ReadoutGeometry/HGTD_DetectorElement.h
"
24
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
25
#include "
TRT_ReadoutGeometry/TRT_BaseElement.h
"
26
27
// STL
28
#include <string>
29
30
using
gid
= Acts::GeometryIdentifier;
31
32
33
StatusCode
ActsWriteTrackingGeometryTransforms::initialize
() {
34
35
// Grab PixelID helper
36
ATH_CHECK
(
detStore
()->retrieve(
m_pixelID
,
"PixelID"
) );
37
ATH_CHECK
(
detStore
()->retrieve(
m_SCT_ID
,
"SCT_ID"
) );
38
39
ATH_CHECK
(
m_trackingGeometrySvc
.retrieve());
40
ATH_CHECK
(
m_ctxProvider
.initialize());
41
42
std::ofstream os(
m_outputName
);
// truncate
43
44
return
StatusCode::SUCCESS;
45
}
46
47
StatusCode
ActsWriteTrackingGeometryTransforms::execute
(
const
EventContext& ctx) {
48
49
ATH_MSG_DEBUG
(
"In ActsWriteTrackingGeometryTransforms::execute"
);
50
51
52
53
auto
trackingGeometry =
m_trackingGeometrySvc
->trackingGeometry();
54
ATH_MSG_DEBUG
(
"Retrieved tracking Geometry"
);
55
const
Acts::GeometryContext tgContext =
m_ctxProvider
.getGeometryContext(ctx);
56
ATH_MSG_DEBUG
(
"Retrieved geometry context"
);
57
58
std::stringstream
ss
;
59
60
61
std::ofstream os(
m_outputName
, std::ios_base::app);
62
63
trackingGeometry->visitSurfaces([&] (
const
Acts::Surface* srf) {
64
const
auto
*gmde =
getActsDetectorElement
(srf);
65
if
(!gmde) {
66
return
;
67
}
68
if
(
dynamic_cast<
const
InDetDD::TRT_BaseElement
*
>
(gmde->upstreamDetectorElement()) !=
nullptr
) {
69
return
;
70
}
71
72
if
(
dynamic_cast<
const
InDetDD::HGTD_DetectorElement
*
>
(gmde->upstreamDetectorElement()) !=
nullptr
) {
73
return
;
74
}
75
76
const
auto
sil_de =
dynamic_cast<
const
InDetDD::SiDetectorElement
*
>
(gmde->upstreamDetectorElement());
77
if
(sil_de ==
nullptr
) {
78
throw
std::runtime_error{
"Not TRT, Not HGTD and not Si either"
};
// this shouldn't happen
79
}
80
81
gid
geoID = srf->geometryId();
82
83
os << geoID.volume() <<
";"
;
84
os << geoID.boundary() <<
";"
;
85
os << geoID.layer() <<
";"
;
86
os << geoID.sensitive() <<
";"
;
87
88
os << ctx.eventID().event_number() <<
";"
;
89
90
int
bec,ld,etam,phim, side;
91
92
Identifier
ath_geoid = gmde->identify();
93
94
if
(sil_de->isPixel()) {
95
bec =
m_pixelID
->barrel_ec(ath_geoid);
96
ld =
m_pixelID
->layer_disk(ath_geoid);
97
etam =
m_pixelID
->eta_module(ath_geoid);
98
phim =
m_pixelID
->phi_module(ath_geoid);
99
side = 0;
100
os << 0;
101
}
else
if
(sil_de->isSCT()) {
102
bec =
m_SCT_ID
->barrel_ec(ath_geoid);
103
ld =
m_SCT_ID
->layer_disk(ath_geoid);
104
etam =
m_SCT_ID
->eta_module(ath_geoid);
105
phim =
m_SCT_ID
->phi_module(ath_geoid);
106
side =
m_SCT_ID
->side(ath_geoid);
107
os << 1;
108
}
else
{
109
throw
std::runtime_error{
"The Detector Element is neither Pixel nor SCT"
};
// this shouldn't happen
110
}
111
// Write the type of silicon first (0=PIX, 1=SCT)
112
os <<
";"
;
113
114
// Then write the athena geoid and the unpacked version
115
os<<ath_geoid<<
","
<<bec<<
","
<<ld<<
","
<<etam<<
","
<<phim<<
","
<<side<<
";"
;
116
117
ATH_MSG_DEBUG
(geoID<<
" "
<<ath_geoid<<
" "
<<bec<<
" "
<<ld<<
" "
<<etam<<
" "
<<phim<<
" "
<<side);
118
119
if
(
m_writeFullTransform
) {
120
// iterate over components of transform
121
const
auto
* p = srf->localToGlobalTransform(tgContext).data();
122
for
(
size_t
i=0;i<16;i++) {
123
if
(i>0) {
124
os <<
","
;
125
}
126
os << *(p+i);
127
}
128
}
else
{
// only write center of the detector element
129
double
cx = srf->center(tgContext).x();
130
double
cy = srf->center(tgContext).y();
131
double
cz = srf->center(tgContext).z();
132
os<<cx<<
","
<<cy<<
","
<<cz;
133
}
134
135
os <<
"\n"
;
136
});
137
138
139
return
StatusCode::SUCCESS;
140
}
ActsDetectorElement.h
getActsDetectorElement
const ActsDetectorElement * getActsDetectorElement(const Acts::Surface &surf)
Attempts to retrieve the ActsDetectorElement associated to the passed ActsSurface.
Definition
ActsDetectorElement.cxx:53
gid
Acts::GeometryIdentifier gid
Definition
ActsWriteTrackingGeometryTransforms.cxx:30
ActsWriteTrackingGeometryTransforms.h
ITrackingGeometrySvc.h
AthAlgorithm.h
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:29
GeometryContext.h
HGTD_DetectorElement.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
RNGWrapper.h
SiDetectorElement.h
TRT_BaseElement.h
Logger.h
ActsWriteTrackingGeometryTransforms::m_outputName
Gaudi::Property< std::string > m_outputName
Definition
ActsWriteTrackingGeometryTransforms.h:47
ActsWriteTrackingGeometryTransforms::m_SCT_ID
const SCT_ID * m_SCT_ID
Definition
ActsWriteTrackingGeometryTransforms.h:40
ActsWriteTrackingGeometryTransforms::m_ctxProvider
ActsTrk::ContextUtility m_ctxProvider
Context provider for geometry, magnetic field and calibration contexts.
Definition
ActsWriteTrackingGeometryTransforms.h:45
ActsWriteTrackingGeometryTransforms::initialize
virtual StatusCode initialize() override
Definition
ActsWriteTrackingGeometryTransforms.cxx:33
ActsWriteTrackingGeometryTransforms::m_pixelID
const PixelID * m_pixelID
Definition
ActsWriteTrackingGeometryTransforms.h:39
ActsWriteTrackingGeometryTransforms::m_trackingGeometrySvc
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
Definition
ActsWriteTrackingGeometryTransforms.h:42
ActsWriteTrackingGeometryTransforms::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
ActsWriteTrackingGeometryTransforms.cxx:47
ActsWriteTrackingGeometryTransforms::m_writeFullTransform
Gaudi::Property< bool > m_writeFullTransform
Definition
ActsWriteTrackingGeometryTransforms.h:48
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
InDetDD::HGTD_DetectorElement
Class to hold geometrical description of an HGTD detector element.
Definition
HGTD_DetectorElement.h:40
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
InDetDD::TRT_BaseElement
Virtual base class of TRT readout elements.
Definition
TRT_BaseElement.h:56
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0