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::SurfacePlacementBase *detElem = srf->surfacePlacement();
65 const auto *gmde = static_cast<const ActsDetectorElement *>(detElem);
66
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 const ActsTrk::GeometryContext& void_gctx = m_trackingGeometryTool->getNominalGeometryContext();
121 // iterate over components of transform
122 const auto* p = srf->localToGlobalTransform(gctx.context()).data();
123 for(size_t i=0;i<16;i++) {
124 if(i>0) {
125 os << ",";
126 }
127 os << *(p+i);
128 }
129 } else { // only write center of the detector element
130 double cx = srf->center(void_gctx.context()).x();
131 double cy = srf->center(void_gctx.context()).y();
132 double cz = srf->center(void_gctx.context()).z();
133 os<<cx<<","<<cy<<","<<cz;
134 }
135
136 os << "\n";
137 });
138
139
140 return StatusCode::SUCCESS;
141}
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.