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"
32 #include <unordered_map>
35 using Acts::Transform3;
36 using Acts::Translation3;
38 using namespace Acts::UnitLiterals;
41 std::unique_ptr<const Acts::Logger>
logger)
43 m_logger(std::move(
logger))
47 const Acts::LayerVector
49 ACTS_VERBOSE(
"Building negative layers");
50 Acts::LayerVector nVector;
55 const Acts::LayerVector
57 ACTS_VERBOSE(
"HGTD has no central layers");
62 const Acts::LayerVector
64 ACTS_VERBOSE(
"Building positive layers");
65 Acts::LayerVector pVector;
71 Acts::LayerVector &layersOutput,
int type)
const
74 ACTS_VERBOSE(
"Build layers: " << (
type < 0 ?
"NEGATIVE" :
"POSITIVE")
77 std::vector<std::shared_ptr<const ActsDetectorElement>> elements =
79 std::map<int, std::vector<const Acts::Surface *>>
82 for (
const auto &element : elements) {
93 initialLayers[currentLayer].push_back(&element->surface());
96 ACTS_VERBOSE(
"Found " << initialLayers.size() <<
" "
97 << (
type < 0 ?
"NEGATIVE" :
"POSITIVE")
98 <<
" ENDCAP inital layers");
107 std::vector<Acts::ProtoLayer> protoLayers;
108 protoLayers.reserve(initialLayers.size());
110 for (
const auto &[
key, surfaces] : initialLayers) {
111 auto &pl = protoLayers.emplace_back(gctx, surfaces);
118 std::sort(protoLayers.begin(), protoLayers.end(),
119 [
type](
const Acts::ProtoLayer &
a,
const Acts::ProtoLayer &
b) {
120 double midA = (a.min(Acts::BinningValue::binZ) + a.max(Acts::BinningValue::binZ)) / 2.0;
121 double midB = (b.min(Acts::BinningValue::binZ) + b.max(Acts::BinningValue::binZ)) / 2.0;
129 std::vector<std::shared_ptr<const Surface>> ownedSurfaces;
130 for (
const auto &pl : protoLayers) {
132 std::unique_ptr<Acts::ApproachDescriptor> approachDescriptor =
nullptr;
133 std::shared_ptr<const Acts::ProtoSurfaceMaterial> materialProxy =
nullptr;
138 double layerZInner = layerZ - layerHalfZ;
139 double layerZOuter = layerZ + layerHalfZ;
141 if (std::abs(layerZInner) > std::abs(layerZOuter))
144 std::vector<std::shared_ptr<const Acts::Surface>> aSurfaces;
146 Acts::Transform3 transformNominal(Translation3(0., 0., layerZ));
147 Acts::Transform3 transformInner(Translation3(0., 0., layerZInner));
148 Acts::Transform3 transformOuter(Translation3(0., 0., layerZOuter));
150 std::shared_ptr<Acts::DiscSurface> innerBoundary =
151 Acts::Surface::makeShared<Acts::DiscSurface>(
153 aSurfaces.push_back(innerBoundary);
155 std::shared_ptr<Acts::DiscSurface> nominalSurface =
156 Acts::Surface::makeShared<Acts::DiscSurface>(
158 aSurfaces.push_back(nominalSurface);
160 std::shared_ptr<Acts::DiscSurface> outerBoundary =
161 Acts::Surface::makeShared<Acts::DiscSurface>(
163 aSurfaces.push_back(outerBoundary);
165 size_t matBinsPhi = m_cfg.endcapMaterialBins.first;
166 size_t matBinsR = m_cfg.endcapMaterialBins.second;
175 std::make_shared<const Acts::ProtoSurfaceMaterial>(materialBinUtil);
177 ACTS_VERBOSE(
"[L] Layer is marked to carry support material on Surface ( "
178 "inner=0 / center=1 / outer=2 ) : "
180 ACTS_VERBOSE(
"with binning: [" << matBinsPhi <<
", " << matBinsR <<
"]");
182 ACTS_VERBOSE(
"Created ApproachSurfaces for disc layer at:");
183 ACTS_VERBOSE(
" - inner: Z=" << layerZInner);
184 ACTS_VERBOSE(
" - central: Z=" << layerZ);
185 ACTS_VERBOSE(
" - outer: Z=" << layerZOuter);
188 innerBoundary->assignSurfaceMaterial(materialProxy);
190 std::set<int> phiModuleByRing;
192 for (
const auto &srf : pl.surfaces()) {
194 srf->associatedDetectorElement());
197 phiModuleByRing.insert(m_cfg.idHelper->phi_module(
id));
204 ACTS_VERBOSE(
"Identifier reports: " << nModPhi <<
" is lowest for " << nModR
207 size_t nBinsPhi = nModPhi;
208 size_t nBinsR = nModR;
211 ACTS_VERBOSE(
"Creating r x phi binned layer with " << nBinsR <<
" x "
212 << nBinsPhi <<
" bins");
216 std::make_unique<Acts::GenericApproachDescriptor>(aSurfaces);
219 ownedSurfaces.clear();
220 ownedSurfaces.reserve(pl.surfaces().size());
222 std::back_inserter(ownedSurfaces),
223 [](
const auto &
s) { return s->getSharedPtr(); });
225 auto layer = m_cfg.layerCreator->discLayer(gctx, ownedSurfaces, nBinsR,
226 nBinsPhi, pl, transformNominal,
227 std::move(approachDescriptor));
229 layersOutput.push_back( std::move(
layer) );
233 std::vector<std::shared_ptr<const ActsDetectorElement>>
235 ACTS_VERBOSE(
"Retrieving detector elements from detector manager");
237 ACTS_ERROR(
"Manager is null");
238 throw std::runtime_error{
"Detector manager is null"};
241 ACTS_VERBOSE(
"Detector manager has "
243 hgtdDetMng->getDetectorElementEnd())
246 std::vector<std::shared_ptr<const ActsDetectorElement>> elements;
248 InDetDD::HGTD_DetectorElementCollection::const_iterator iter;
249 for (iter = hgtdDetMng->getDetectorElementBegin();
250 iter != hgtdDetMng->getDetectorElementEnd(); ++iter) {
254 if (not detElement) {
255 ACTS_ERROR(
"Detector element was nullptr");
256 throw std::runtime_error{
"Corrupt detector element collection"};
259 std::make_shared<const ActsDetectorElement>(*detElement, (*iter)->identify()));
261 ACTS_VERBOSE(
"Retrieved " << elements.size() <<
" elements");