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
46StatusCode ActsWriteTrackingGeometryTransforms::execute(const EventContext& ctx) {
47
48 ATH_MSG_DEBUG("In ActsWriteTrackingGeometryTransforms::execute");
49
50
51
52 auto trackingGeometry = m_trackingGeometryTool->trackingGeometry();
53 ATH_MSG_DEBUG("Retrieved tracking Geometry");
54 const ActsTrk::GeometryContext& gctx = m_trackingGeometryTool->getGeometryContext(ctx);
55 ATH_MSG_DEBUG("Retrieved geometry context");
56
57 std::stringstream ss;
58
59
60 std::ofstream os(m_outputName, std::ios_base::app);
61
62 trackingGeometry->visitSurfaces([&] (const Acts::Surface* srf) {
63 const Acts::SurfacePlacementBase *detElem = srf->surfacePlacement();
64 const auto *gmde = static_cast<const ActsDetectorElement *>(detElem);
65
66
67 if(dynamic_cast<const InDetDD::TRT_BaseElement*>(gmde->upstreamDetectorElement()) != nullptr) {
68 return;
69 }
70
71 if(dynamic_cast<const InDetDD::HGTD_DetectorElement*>(gmde->upstreamDetectorElement()) != nullptr) {
72 return;
73 }
74
75 const auto sil_de = dynamic_cast<const InDetDD::SiDetectorElement*>(gmde->upstreamDetectorElement());
76 if(sil_de == nullptr) {
77 throw std::runtime_error{"Not TRT, Not HGTD and not Si either"}; // this shouldn't happen
78 }
79
80 gid geoID = srf->geometryId();
81
82 os << geoID.volume() << ";";
83 os << geoID.boundary() << ";";
84 os << geoID.layer() << ";";
85 os << geoID.sensitive() << ";";
86
87 os << ctx.eventID().event_number() << ";";
88
89 int bec,ld,etam,phim, side;
90
91 Identifier ath_geoid = gmde->identify();
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 } else if(sil_de->isSCT()) {
101 bec = m_SCT_ID->barrel_ec(ath_geoid);
102 ld = m_SCT_ID->layer_disk(ath_geoid);
103 etam = m_SCT_ID->eta_module(ath_geoid);
104 phim = m_SCT_ID->phi_module(ath_geoid);
105 side = m_SCT_ID->side(ath_geoid);
106 os << 1;
107 } else {
108 throw std::runtime_error{"The Detector Element is neither Pixel nor SCT"}; // this shouldn't happen
109 }
110 // Write the type of silicon first (0=PIX, 1=SCT)
111 os << ";";
112
113 // Then write the athena geoid and the unpacked version
114 os<<ath_geoid<<","<<bec<<","<<ld<<","<<etam<<","<<phim<<","<<side<<";";
115
116 ATH_MSG_DEBUG(geoID<<" "<<ath_geoid<<" "<<bec<<" "<<ld<<" "<<etam<<" "<<phim<<" "<<side);
117
118 const ActsTrk::GeometryContext& void_gctx = m_trackingGeometryTool->getNominalGeometryContext();
120 // iterate over components of transform
121 const auto* p = srf->localToGlobalTransform(gctx.context()).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(void_gctx.context()).x();
130 double cy = srf->center(void_gctx.context()).y();
131 double cz = srf->center(void_gctx.context()).z();
132 os<<cx<<","<<cy<<","<<cz;
133 }
134
135 os << "\n";
136 });
137
138
139 return StatusCode::SUCCESS;
140}
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
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.