ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11
12// ATHENA
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"
26
27// STL
28#include <string>
29
30using gid = Acts::GeometryIdentifier;
31
32
34
35 // Grab PixelID helper
36 ATH_CHECK (detStore()->retrieve(m_pixelID, "PixelID") );
37 ATH_CHECK (detStore()->retrieve(m_SCT_ID,"SCT_ID") );
38
40 ATH_CHECK(m_ctxProvider.initialize());
41
42 std::ofstream os(m_outputName); // truncate
43
44 return StatusCode::SUCCESS;
45}
46
47StatusCode 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
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}
const ActsDetectorElement * getActsDetectorElement(const Acts::Surface &surf)
Attempts to retrieve the ActsDetectorElement associated to the passed ActsSurface.
Acts::GeometryIdentifier gid
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static Double_t ss
ActsTrk::ContextUtility m_ctxProvider
Context provider for geometry, magnetic field and calibration contexts.
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
const ServiceHandle< StoreGateSvc > & detStore() const
Class to hold geometrical description of an HGTD detector element.
Class to hold geometrical description of a silicon detector element.
Virtual base class of TRT readout elements.