319 ACTS_VERBOSE(
"Build layers: " << (
type < 0 ?
"NEGATIVE" :
"POSITIVE")
321 std::vector<std::shared_ptr<const ActsDetectorElement>> elements =
323 std::map<std::tuple<int, int, int>, std::vector<const Acts::Surface *>>
326 for (
const auto &element : elements) {
334 if(
id.layer_disk() >= 3)
continue;
337 if(
id.layer_disk() <= 2)
continue;
342 std::tuple<int, int, int>
key{
id.bec(),
id.layer_disk(),
id.eta_module()};
344 initialLayers[
key].push_back(&element->surface());
347 ACTS_VERBOSE(
"Found " << initialLayers.size() <<
" "
348 << (
type < 0 ?
"NEGATIVE" :
"POSITIVE")
349 <<
" ENDCAP inital layers");
351 std::vector<Acts::ProtoLayer> protoLayers;
352 protoLayers.reserve(initialLayers.size());
354 for (
const auto &[
key, surfaces] : initialLayers) {
355 auto &pl = protoLayers.emplace_back(gctx, surfaces);
361 std::sort(protoLayers.begin(), protoLayers.end(),
362 [
type](
const Acts::ProtoLayer &
a,
const Acts::ProtoLayer &
b) {
363 double midA = (a.min(Acts::BinningValue::binZ) + a.max(Acts::BinningValue::binZ)) / 2.0;
364 double midB = (b.min(Acts::BinningValue::binZ) + b.max(Acts::BinningValue::binZ)) / 2.0;
372 auto plPrintZ = [](
const auto &pl) -> std::string {
373 std::stringstream
ss;
380 for (
const auto &pl : protoLayers) {
382 ACTS_VERBOSE(
" -> at < zMin | zMid | zMax >: " << plPrintZ(pl));
389 std::vector<Acts::ProtoLayer> mergedProtoLayers;
392 mergedProtoLayers.push_back(protoLayers.front());
393 std::vector<const Acts::Surface *> surfaces;
394 for (
size_t i = 1;
i < protoLayers.size();
i++) {
395 auto &pl = protoLayers[
i];
396 auto &pl_prev = mergedProtoLayers.back();
398 ACTS_VERBOSE(
"Compare: " << plPrintZ(pl_prev) <<
" and " << plPrintZ(pl));
401 ACTS_VERBOSE(
" -> overlap? " << (overlap ?
"yes" :
"no"));
403 ACTS_VERBOSE(
" ===> merging");
405 surfaces.reserve(pl.surfaces().size() + pl_prev.surfaces().size());
406 surfaces.insert(surfaces.end(), pl.surfaces().begin(),
407 pl.surfaces().end());
408 surfaces.insert(surfaces.end(), pl_prev.surfaces().begin(),
409 pl_prev.surfaces().end());
410 mergedProtoLayers.pop_back();
412 mergedProtoLayers.emplace_back(gctx, std::move(surfaces));
416 mergedProtoLayers.push_back(std::move(pl));
420 ACTS_VERBOSE(
"" << mergedProtoLayers.size() <<
" "
421 << (
type < 0 ?
"NEGATIVE" :
"POSITIVE")
422 <<
" ENDCAP layers remain after merging");
424 mergedProtoLayers = protoLayers;
428 for (
size_t i = 0;
i < mergedProtoLayers.size();
i++) {
430 std::stringstream
ss;
432 <<
"_disk_" << std::setfill(
'0') << std::setw(2) <<
i <<
".obj";
434 std::ofstream ofs{
ss.str()};
435 Acts::ObjVisualization3D vis{};
436 Acts::ViewConfig vc = Acts::s_viewSensitive;
437 vc.quarterSegments = 200;
438 for (
const auto &surface : mergedProtoLayers[
i].surfaces()) {
439 Acts::GeometryView3D::drawSurface(vis, *surface, gctx,
440 Acts::Transform3::Identity(), vc);
447 std::vector<std::shared_ptr<const Surface>> ownedSurfaces;
448 for (
const auto &pl : mergedProtoLayers) {
450 std::unique_ptr<Acts::ApproachDescriptor> approachDescriptor =
nullptr;
451 std::shared_ptr<const Acts::ProtoSurfaceMaterial> materialProxy =
nullptr;
457 double layerZInner = layerZ - layerHalfZ;
458 double layerZOuter = layerZ + layerHalfZ;
460 if (std::abs(layerZInner) > std::abs(layerZOuter))
463 std::vector<std::shared_ptr<const Acts::Surface>> aSurfaces;
465 Acts::Transform3 transformNominal(Translation3(0., 0., layerZ));
466 Acts::Transform3 transformInner(Translation3(0., 0., layerZInner));
467 Acts::Transform3 transformOuter(Translation3(0., 0., layerZOuter));
469 std::shared_ptr<Acts::DiscSurface> innerBoundary =
470 Acts::Surface::makeShared<Acts::DiscSurface>(
472 aSurfaces.push_back(innerBoundary);
474 std::shared_ptr<Acts::DiscSurface> nominalSurface =
475 Acts::Surface::makeShared<Acts::DiscSurface>(
477 aSurfaces.push_back(nominalSurface);
479 std::shared_ptr<Acts::DiscSurface> outerBoundary =
480 Acts::Surface::makeShared<Acts::DiscSurface>(
482 aSurfaces.push_back(outerBoundary);
484 if(layerThickness > 2_mm) {
485 ACTS_VERBOSE(
"Wide disc layer ("<< layerThickness <<
") => adding cylinder like approach surfaces");
486 Acts::Transform3
trf{Translation3{0, 0, layerZ}};
488 Acts::Surface::makeShared<Acts::CylinderSurface>(
490 aSurfaces.push_back(cylinderInner);
493 Acts::Surface::makeShared<Acts::CylinderSurface>(
495 aSurfaces.push_back(cylinderOuter);
509 std::make_shared<const Acts::ProtoSurfaceMaterial>(materialBinUtil);
511 ACTS_VERBOSE(
"[L] Layer is marked to carry support material on Surface ( "
512 "inner=0 / center=1 / outer=2 ) : "
514 ACTS_VERBOSE(
"with binning: [" << matBinsPhi <<
", " << matBinsR <<
"]");
516 ACTS_VERBOSE(
"Created ApproachSurfaces for disc layer at:");
517 ACTS_VERBOSE(
" - inner: Z=" << layerZInner);
518 ACTS_VERBOSE(
" - central: Z=" << layerZ);
519 ACTS_VERBOSE(
" - outer: Z=" << layerZOuter);
522 innerBoundary->assignSurfaceMaterial(materialProxy);
530 std::map<int, std::set<int>> phiModuleByRing;
533 for (
const auto &srf : pl.surfaces()) {
535 srf->associatedDetectorElement());
543 ring_number =
id.layer_disk();
545 phiModuleByRing[ring_number].insert(
id.phi_module());
549 for(
const auto& [ring, phiModules] : phiModuleByRing) {
550 nModPhi =
std::min(nModPhi, phiModules.size());
553 size_t nModR = phiModuleByRing.size();
555 ACTS_VERBOSE(
"Identifier reports: " << nModPhi <<
" is lowest for " << nModR
558 size_t nBinsPhi = nModPhi;
559 size_t nBinsR = nModR;
574 ACTS_VERBOSE(
"Creating r x phi binned layer with " << nBinsR <<
" x "
575 << nBinsPhi <<
" bins");
579 std::make_unique<Acts::GenericApproachDescriptor>(aSurfaces);
582 ownedSurfaces.clear();
583 ownedSurfaces.reserve(pl.surfaces().size());
585 std::back_inserter(ownedSurfaces),
586 [](
const auto &
s) { return s->getSharedPtr(); });
589 nBinsPhi, pl, transformNominal,
590 std::move(approachDescriptor));
592 layersOutput.push_back(
layer);