ATLAS Offline Software
Loading...
Searching...
No Matches
HgtdBlueprintNodeBuilder.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// This absolutely needs to go first to ensure Eigen plugin is loaded
7//
8#include <GeoModelKernel/GeoTube.h>
9#include <GeoModelKernel/GeoVPhysVol.h>
10
11#include <Acts/Definitions/Direction.hpp>
12#include <Acts/Definitions/Units.hpp>
13#include <Acts/Geometry/Blueprint.hpp>
14#include <Acts/Geometry/BlueprintNode.hpp>
15#include <Acts/Geometry/ContainerBlueprintNode.hpp>
16#include <Acts/Geometry/CylinderVolumeBounds.hpp>
17#include <Acts/Geometry/Extent.hpp>
18#include <Acts/Geometry/GeometryIdentifierBlueprintNode.hpp>
19#include <Acts/Geometry/LayerBlueprintNode.hpp>
20#include <Acts/Geometry/MaterialDesignatorBlueprintNode.hpp>
21#include <Acts/Geometry/PadBlueprintNode.hpp>
22#include <Acts/Geometry/ProtoLayer.hpp>
23#include <Acts/Geometry/TrackingVolume.hpp>
24#include <Acts/Geometry/VolumeAttachmentStrategy.hpp>
25#include <Acts/Navigation/SurfaceArrayNavigationPolicy.hpp>
26#include <Acts/Navigation/TryAllNavigationPolicy.hpp>
27#include <Acts/Surfaces/SurfaceArray.hpp>
28#include <Acts/Utilities/AxisDefinitions.hpp>
29#include <cstddef>
30#include <ranges>
31#include <string>
32
33#include "Acts/Geometry/StaticBlueprintNode.hpp"
34#include "Acts/Geometry/VolumeResizeStrategy.hpp"
35#include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
39#include "ActsInterop/Logger.h"
44
45using namespace Acts;
46using namespace Acts::Experimental;
47using namespace Acts::UnitLiterals;
48
49namespace {
51using namespace ActsTrk::detail::GeoVolIds;
52using enum Acts::CylinderVolumeBounds::Face;
53using enum Acts::AxisDirection;
54using enum Acts::AxisBoundaryType;
55using enum Acts::SurfaceArrayNavigationPolicy::LayerType;
56using AttachmentStrategy = Acts::VolumeAttachmentStrategy;
57using ResizeStrategy = Acts::VolumeResizeStrategy;
58} // namespace
59
60namespace ActsTrk {
62 ATH_MSG_DEBUG("Initializing HgtdBlueprintNodeBuilder");
63
64 ATH_CHECK(detStore()->retrieve(m_hgtdMgr, "HGTD"));
65
66 m_elementStore = std::make_shared<ActsElementVector>();
67
68 return StatusCode::SUCCESS;
69}
70
71std::shared_ptr<Acts::Experimental::BlueprintNode>
73 const Acts::GeometryContext& gctx,
74 std::shared_ptr<Acts::Experimental::BlueprintNode>&& child) {
75
76 ExtentEnvelope envelope = ExtentEnvelope{{
77 .z = {20_mm, 20_mm},
78 .r = {0_mm, 20_mm},
79 }};
80 auto itkHgtdPad = std::make_shared<Acts::Experimental::PadBlueprintNode>(
81 "itkHgtdPad", envelope);
82
83 auto itkHgtdNode =
84 std::make_shared<Acts::Experimental::CylinderContainerBlueprintNode>(
85 "itkHgtd", AxisZ);
86
87 if (child) {
88 itkHgtdNode->addChild(std::move(child));
89 }
90 buildHgtdBlueprintNode(gctx, *itkHgtdNode);
91
92 itkHgtdPad->addChild(itkHgtdNode);
93 return itkHgtdPad;
94}
95
97 const Acts::GeometryContext& /*gctx*/,
98 Acts::Experimental::BlueprintNode& node) {
99 if (not m_hgtdMgr) {
100 ATH_MSG_ERROR("HGTD manager not available");
101 throw std::runtime_error("HGTD manager not available");
102 }
103
104 ATH_MSG_DEBUG("Detector manager has "
105 << m_hgtdMgr->getDetectorElementCollection()->size()
106 << " elements");
107
108 std::vector<std::shared_ptr<ActsDetectorElement>> elements;
109
110 for (const auto* element : *m_hgtdMgr->getDetectorElementCollection()) {
111 const InDetDD::HGTD_DetectorElement* hgtdDetElement =
112 dynamic_cast<const InDetDD::HGTD_DetectorElement*>(element);
113 if (hgtdDetElement == nullptr) {
114 ATH_MSG_ERROR("Detector element was nullptr");
115 throw std::runtime_error{"Corrupt detector element collection"};
116 }
117 elements.push_back(std::make_shared<ActsDetectorElement>(
118 *hgtdDetElement, hgtdDetElement->identify()));
119 }
120 ATH_MSG_VERBOSE("Retrieved " << elements.size() << " elements");
121
122 m_elementStore->vector().insert(m_elementStore->vector().end(),
123 elements.begin(), elements.end());
124
125 for (int bec : {-2, 2}) {
126 const std::string s = bec > 0 ? "p" : "n";
127
128 std::map<int, std::vector<std::shared_ptr<Acts::Surface>>> layers{};
129
130 for (auto& element : elements) {
131 IdentityHelper id = element->identityHelper();
132
133 ATH_MSG_VERBOSE("Reading element with bec "
134 << id.bec() << ", layer/disk " << id.layer_disk()
135 << ", eta_module " << id.eta_module() << ", phi_module "
136 << id.phi_module());
137
138 if (id.bec() * bec <= 0) {
139 continue;
140 }
141
142 layers[id.layer_disk()].push_back(element->surface().getSharedPtr());
143 }
144
145 ATH_MSG_DEBUG("Found " << layers.size() << " layers in HGTD " << s << "EC");
146 for (auto& [key, surfaces] : layers) {
147 ATH_MSG_DEBUG("Layer " << key << " has " << surfaces.size()
148 << " surfaces");
149 }
150
151 node.withGeometryIdentifier([&layers, bec, s, this](auto& geoId) {
152 std::string ecName = "HGTD_" + s + "EC";
153 geoId.setAllVolumeIdsTo((bec > 0 ? s_hgtdPosVolumeId : s_hgtdNegVolumeId))
154 .incrementLayerIds(1);
155
156 geoId.addCylinderContainer(ecName, AxisR, [&](auto& hgtd) {
157 hgtd.setAttachmentStrategy(AttachmentStrategy::Gap);
158 hgtd.setResizeStrategy(ResizeStrategy::Gap);
159
160 hgtd.addCylinderContainer(
161 ecName + "_Container", AxisZ, [&](auto& hgtdContainer) {
162 hgtdContainer.setAttachmentStrategy(AttachmentStrategy::Gap);
163 hgtdContainer.setResizeStrategy(ResizeStrategy::Gap);
164
165 for (auto& [key, surfaces] : layers) {
166 std::string layerName = ecName + "_" + std::to_string(key);
167
168 ATH_MSG_DEBUG("Adding layer " << layerName << " with "
169 << surfaces.size()
170 << " surfaces");
171
172 addHgtdLayers(hgtdContainer, bec, key, layerName, surfaces);
173 }
174 });
175 });
176 });
177 }
178}
179
181 Acts::Experimental::BlueprintNode& parent, int bec, int index,
182 const std::string& name,
183 std::vector<std::shared_ptr<Acts::Surface>>& surfaces) {
184 using enum Acts::SurfaceArrayNavigationPolicy::LayerType;
185 using enum Acts::CylinderVolumeBounds::Face;
186 using enum Acts::AxisDirection;
187 using enum Acts::AxisBoundaryType;
188
189 parent.addMaterial(name + "_Material", [&](auto& mat) {
190 if (index == 3) {
191 mat.configureFace(bec > 0 ? NegativeDisc : PositiveDisc,
192 {AxisR, Bound, 20}, {AxisPhi, Closed, 40});
193 } else {
194 mat.configureFace(NegativeDisc, {AxisR, Bound, 20},
195 {AxisPhi, Closed, 40});
196 mat.configureFace(PositiveDisc, {AxisR, Bound, 20},
197 {AxisPhi, Closed, 40});
198 }
199
200 mat.addLayer(name, [&surfaces](auto& layer) {
201 layer.setNavigationPolicyFactory(
202 Acts::NavigationPolicyFactory{}
203 .add<Acts::SurfaceArrayNavigationPolicy>(
204 Acts::SurfaceArrayNavigationPolicy::Config{.layerType = Disc,
205 .bins = {20, 20}})
206 .add<Acts::TryAllNavigationPolicy>(
207 Acts::TryAllNavigationPolicy::Config{.sensitives = false})
208 .asUniquePtr());
209 layer.setSurfaces(surfaces);
210 layer.setEnvelope(Acts::ExtentEnvelope{{
211 .z = {0.1_mm, 0.1_mm},
212 .r = {2_mm, 2_mm},
213 }});
214 });
215 });
216}
217
218} // namespace ActsTrk
Helper to hold elements for deletion.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Acts::VolumeResizeStrategy ResizeStrategy
Acts::VolumeAttachmentStrategy AttachmentStrategy
void buildHgtdBlueprintNode(const Acts::GeometryContext &gctx, Acts::Experimental::BlueprintNode &node)
Build the HGTD Blueprint Node.
void addHgtdLayers(Acts::Experimental::BlueprintNode &parent, int bec, int layer, const std::string &name, std::vector< std::shared_ptr< Acts::Surface > > &surfaces)
const HGTD_DetectorManager * m_hgtdMgr
std::shared_ptr< ActsElementVector > m_elementStore
std::shared_ptr< Acts::Experimental::BlueprintNode > buildBlueprintNode(const Acts::GeometryContext &gctx, std::shared_ptr< Acts::Experimental::BlueprintNode > &&child) override
Build the HGTD Blueprint Node.
Class to hold geometrical description of an HGTD detector element.
virtual Identifier identify() const override final
identifier of this detector element (inline)
Definition node.h:24
Define the volume parts of the GeometryIdentifier for each ATLAS subsystem centrally.
constexpr std::size_t s_hgtdNegVolumeId
constexpr std::size_t s_hgtdPosVolumeId
HGTD volume IDs.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition index.py:1