ATLAS Offline Software
Loading...
Searching...
No Matches
ActsWriteTrackingGeometryTransforms.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
41 std::ofstream os(m_outputName); // truncate
42
43 return StatusCode::SUCCESS;
44}
45
47
48 ATH_MSG_DEBUG("In ActsWriteTrackingGeometryTransforms::execute");
49
50
51 const EventContext& ctx = Gaudi::Hive::currentContext();
52
53 auto trackingGeometry = m_trackingGeometryTool->trackingGeometry();
54 ATH_MSG_DEBUG("Retrieved tracking Geometry");
55 const ActsTrk::GeometryContext& gctx = m_trackingGeometryTool->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 Acts::DetectorElementBase *detElem = srf->associatedDetectorElement();
65 const auto *gmde = static_cast<const ActsDetectorElement *>(detElem);
66
67 Identifier ath_geoid = gmde->identify();
68
69 if(dynamic_cast<const InDetDD::TRT_BaseElement*>(gmde->upstreamDetectorElement()) != nullptr) {
70 return;
71 }
72
73 if(dynamic_cast<const InDetDD::HGTD_DetectorElement*>(gmde->upstreamDetectorElement()) != nullptr) {
74 return;
75 }
76
77 const auto sil_de = dynamic_cast<const InDetDD::SiDetectorElement*>(gmde->upstreamDetectorElement());
78 if(sil_de == nullptr) {
79 throw std::runtime_error{"Not TRT, Not HGTD and not Si either"}; // this shouldn't happen
80 }
81
82 gid geoID = srf->geometryId();
83
84 os << geoID.volume() << ";";
85 os << geoID.boundary() << ";";
86 os << geoID.layer() << ";";
87 os << geoID.sensitive() << ";";
88
89 os << ctx.eventID().event_number() << ";";
90
91 int bec,ld,etam,phim, side;
92
93 if(sil_de->isPixel()) {
94 bec = m_pixelID->barrel_ec(ath_geoid);
95 ld = m_pixelID->layer_disk(ath_geoid);
96 etam = m_pixelID->eta_module(ath_geoid);
97 phim = m_pixelID->phi_module(ath_geoid);
98 side = 0;
99 os << 0;
100 }
101 else if(sil_de->isSCT()) {
102
103 bec = m_SCT_ID->barrel_ec(ath_geoid);
104 ld = m_SCT_ID->layer_disk(ath_geoid);
105 etam = m_SCT_ID->eta_module(ath_geoid);
106 phim = m_SCT_ID->phi_module(ath_geoid);
107 side = m_SCT_ID->side(ath_geoid);
108 os << 1;
109 }
110 else {
111 throw std::runtime_error{"The Detector Element is neither Pixel nor SCT"}; // this shouldn't happen
112 }
113 // Write the type of silicon first (0=PIX, 1=SCT)
114 os << ";";
115
116 // Then write the athena geoid and the unpacked version
117 os<<ath_geoid<<","<<bec<<","<<ld<<","<<etam<<","<<phim<<","<<side<<";";
118
119 ATH_MSG_DEBUG(geoID<<" "<<ath_geoid<<" "<<bec<<" "<<ld<<" "<<etam<<" "<<phim<<" "<<side);
120
121 const ActsTrk::GeometryContext& void_gctx = m_trackingGeometryTool->getNominalGeometryContext();
123 // iterate over components of transform
124 const auto* p = srf->transform(gctx.context()).data();
125 for(size_t i=0;i<16;i++) {
126 if(i>0) {
127 os << ",";
128 }
129 os << *(p+i);
130 }
131 } else { // only write center of the detector element
132 double cx = srf->center(void_gctx.context()).x();
133 double cy = srf->center(void_gctx.context()).y();
134 double cz = srf->center(void_gctx.context()).z();
135 os<<cx<<","<<cy<<","<<cz;
136 }
137
138 os << "\n";
139 });
140
141
142 return StatusCode::SUCCESS;
143}
Acts::GeometryIdentifier gid
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static Double_t ss
Acts::GeometryContext context() const
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
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.