15 #include "Acts/Definitions/Algebra.hpp"
16 #include "Acts/Definitions/Units.hpp"
17 #include "Acts/Geometry/ApproachDescriptor.hpp"
18 #include "Acts/Geometry/GenericApproachDescriptor.hpp"
19 #include "Acts/Geometry/GeometryContext.hpp"
20 #include "Acts/Geometry/LayerCreator.hpp"
21 #include "Acts/Geometry/ProtoLayer.hpp"
22 #include "Acts/Material/ProtoSurfaceMaterial.hpp"
23 #include "Acts/Surfaces/CylinderSurface.hpp"
24 #include "Acts/Surfaces/DiscSurface.hpp"
25 #include "Acts/Utilities/BinningType.hpp"
26 #include "Acts/Surfaces/AnnulusBounds.hpp"
28 #include "Acts/Visualization/GeometryView3D.hpp"
29 #include "Acts/Visualization/ObjVisualization3D.hpp"
31 #include <Acts/Utilities/AxisDefinitions.hpp>
33 #include <unordered_map>
36 using Acts::Transform3;
37 using Acts::Translation3;
39 using namespace Acts::UnitLiterals;
42 std::unique_ptr<const Acts::Logger>
logger)
44 m_logger(std::move(
logger))
48 const Acts::LayerVector
50 ACTS_VERBOSE(
"Building negative layers");
51 Acts::LayerVector nVector;
56 const Acts::LayerVector
58 ACTS_VERBOSE(
"HGTD has no central layers");
63 const Acts::LayerVector
65 ACTS_VERBOSE(
"Building positive layers");
66 Acts::LayerVector pVector;
72 Acts::LayerVector &layersOutput,
int type)
const
74 using enum Acts::AxisDirection;
76 ACTS_VERBOSE(
"Build layers: " << (
type < 0 ?
"NEGATIVE" :
"POSITIVE")
79 std::vector<std::shared_ptr<const ActsDetectorElement>> elements =
81 std::map<int, std::vector<const Acts::Surface *>>
84 for (
const auto &element : elements) {
95 initialLayers[currentLayer].push_back(&element->surface());
98 ACTS_VERBOSE(
"Found " << initialLayers.size() <<
" "
99 << (
type < 0 ?
"NEGATIVE" :
"POSITIVE")
100 <<
" ENDCAP inital layers");
109 std::vector<Acts::ProtoLayer> protoLayers;
110 protoLayers.reserve(initialLayers.size());
112 for (
const auto &[
key, surfaces] : initialLayers) {
113 auto &pl = protoLayers.emplace_back(gctx, surfaces);
120 std::sort(protoLayers.begin(), protoLayers.end(),
121 [
type](
const Acts::ProtoLayer &
a,
const Acts::ProtoLayer &
b) {
122 double midA = (a.min(AxisZ) + a.max(AxisZ)) / 2.0;
123 double midB = (b.min(AxisZ) + b.max(AxisZ)) / 2.0;
131 std::vector<std::shared_ptr<const Surface>> ownedSurfaces;
132 for (
const auto &pl : protoLayers) {
134 std::unique_ptr<Acts::ApproachDescriptor> approachDescriptor =
nullptr;
135 std::shared_ptr<const Acts::ProtoSurfaceMaterial> materialProxy =
nullptr;
137 double layerZ = pl.medium(AxisZ);
138 double layerHalfZ = 0.5 * pl.range(AxisZ);
140 double layerZInner = layerZ - layerHalfZ;
141 double layerZOuter = layerZ + layerHalfZ;
143 if (std::abs(layerZInner) > std::abs(layerZOuter))
146 std::vector<std::shared_ptr<const Acts::Surface>> aSurfaces;
148 Acts::Transform3 transformNominal(Translation3(0., 0., layerZ));
149 Acts::Transform3 transformInner(Translation3(0., 0., layerZInner));
150 Acts::Transform3 transformOuter(Translation3(0., 0., layerZOuter));
152 std::shared_ptr<Acts::DiscSurface> innerBoundary =
153 Acts::Surface::makeShared<Acts::DiscSurface>(
154 transformInner, pl.min(AxisR), pl.max(AxisR));
155 aSurfaces.push_back(innerBoundary);
157 std::shared_ptr<Acts::DiscSurface> nominalSurface =
158 Acts::Surface::makeShared<Acts::DiscSurface>(
159 transformNominal, pl.min(AxisR), pl.max(AxisR));
160 aSurfaces.push_back(nominalSurface);
162 std::shared_ptr<Acts::DiscSurface> outerBoundary =
163 Acts::Surface::makeShared<Acts::DiscSurface>(
164 transformOuter, pl.min(AxisR), pl.max(AxisR));
165 aSurfaces.push_back(outerBoundary);
167 size_t matBinsPhi = m_cfg.endcapMaterialBins.first;
168 size_t matBinsR = m_cfg.endcapMaterialBins.second;
173 Acts::BinUtility(matBinsR, pl.min(AxisR), pl.max(AxisR),
177 std::make_shared<const Acts::ProtoSurfaceMaterial>(materialBinUtil);
179 ACTS_VERBOSE(
"[L] Layer is marked to carry support material on Surface ( "
180 "inner=0 / center=1 / outer=2 ) : "
182 ACTS_VERBOSE(
"with binning: [" << matBinsPhi <<
", " << matBinsR <<
"]");
184 ACTS_VERBOSE(
"Created ApproachSurfaces for disc layer at:");
185 ACTS_VERBOSE(
" - inner: Z=" << layerZInner);
186 ACTS_VERBOSE(
" - central: Z=" << layerZ);
187 ACTS_VERBOSE(
" - outer: Z=" << layerZOuter);
190 innerBoundary->assignSurfaceMaterial(materialProxy);
192 std::set<int> phiModuleByRing;
194 for (
const auto &srf : pl.surfaces()) {
196 srf->associatedDetectorElement());
199 phiModuleByRing.insert(m_cfg.idHelper->phi_module(
id));
206 ACTS_VERBOSE(
"Identifier reports: " << nModPhi <<
" is lowest for " << nModR
209 size_t nBinsPhi = nModPhi;
210 size_t nBinsR = nModR;
213 ACTS_VERBOSE(
"Creating r x phi binned layer with " << nBinsR <<
" x "
214 << nBinsPhi <<
" bins");
218 std::make_unique<Acts::GenericApproachDescriptor>(aSurfaces);
221 ownedSurfaces.clear();
222 ownedSurfaces.reserve(pl.surfaces().size());
224 std::back_inserter(ownedSurfaces),
225 [](
const auto &
s) { return s->getSharedPtr(); });
227 auto layer = m_cfg.layerCreator->discLayer(gctx, ownedSurfaces, nBinsR,
228 nBinsPhi, pl, transformNominal,
229 std::move(approachDescriptor));
231 layersOutput.push_back( std::move(
layer) );
235 std::vector<std::shared_ptr<const ActsDetectorElement>>
237 ACTS_VERBOSE(
"Retrieving detector elements from detector manager");
239 ACTS_ERROR(
"Manager is null");
240 throw std::runtime_error{
"Detector manager is null"};
243 ACTS_VERBOSE(
"Detector manager has "
245 hgtdDetMng->getDetectorElementEnd())
248 std::vector<std::shared_ptr<const ActsDetectorElement>> elements;
250 InDetDD::HGTD_DetectorElementCollection::const_iterator iter;
251 for (iter = hgtdDetMng->getDetectorElementBegin();
252 iter != hgtdDetMng->getDetectorElementEnd(); ++iter) {
256 if (not detElement) {
257 ACTS_ERROR(
"Detector element was nullptr");
258 throw std::runtime_error{
"Corrupt detector element collection"};
261 std::make_shared<const ActsDetectorElement>(*detElement, (*iter)->identify()));
263 ACTS_VERBOSE(
"Retrieved " << elements.size() <<
" elements");