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) {
88 if (
m_cfg.idHelper->endcap(currentId) *
type <= 0) {
92 m_cfg.elementStore->push_back(element);
93 int currentLayer {
m_cfg.idHelper->layer(currentId)};
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);
114 pl.envelope[AxisR] =
m_cfg.endcapEnvelopeR;
115 pl.envelope[AxisZ] =
m_cfg.endcapEnvelopeZ;
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;
170 Acts::BinUtility materialBinUtil(matBinsPhi, -
M_PI,
M_PI, Acts::closed,
173 Acts::BinUtility(matBinsR, pl.min(AxisR), pl.max(AxisR),
174 Acts::open, AxisR, transformNominal);
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());
198 auto id = elm->identify();
199 phiModuleByRing.insert(m_cfg.idHelper->phi_module(
id));
206 ACTS_VERBOSE(
"Identifier reports: " << nModPhi <<
" is lowest for " << nModR
209 size_t nBinsPhi = nModPhi * m_cfg.numberOfBinsFactor;
210 size_t nBinsR = nModR * m_cfg.numberOfBinsFactor;
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());
223 std::transform(pl.surfaces().begin(), pl.surfaces().end(),
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, Transform3::Identity(),
229 std::move(approachDescriptor));
231 layersOutput.push_back( std::move(layer) );