File indexing completed on 2025-12-16 09:23:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/GenericDetector/LayerBuilder.hpp"
0010
0011 #include <span>
0012
0013 namespace ActsExamples::Generic {
0014
0015 namespace {
0016 std::vector<std::shared_ptr<const Acts::Surface>> makeConstSurfaces(
0017 std::span<const std::shared_ptr<Acts::Surface>> surfaces) {
0018 std::vector<std::shared_ptr<const Acts::Surface>> constSurfaces;
0019 constSurfaces.reserve(surfaces.size());
0020 for (const auto& surface : surfaces) {
0021 constSurfaces.push_back(surface);
0022 }
0023 return constSurfaces;
0024 }
0025 }
0026
0027 const Acts::LayerVector LayerBuilder::centralLayers(
0028 const Acts::GeometryContext& gctx) const {
0029
0030 Acts::LayerVector cLayers;
0031 cLayers.reserve(m_cfg.centralProtoLayers.size());
0032
0033 std::size_t icl = 0;
0034 for (auto& cpl : m_cfg.centralProtoLayers) {
0035
0036 Acts::ProtoLayer constProtoLayer{cpl.protoLayer};
0037 Acts::MutableLayerPtr cLayer = m_cfg.layerCreator->cylinderLayer(
0038 gctx, makeConstSurfaces(cpl.surfaces), cpl.bins0, cpl.bins1,
0039 constProtoLayer);
0040
0041
0042 if (!m_cfg.centralLayerMaterial.empty()) {
0043 std::shared_ptr<const Acts::ISurfaceMaterial> layerMaterialPtr =
0044 m_cfg.centralLayerMaterial.at(icl);
0045
0046 if (m_cfg.centralLayerMaterialConcentration.at(icl) == 0.) {
0047
0048 cLayer->surfaceRepresentation().assignSurfaceMaterial(layerMaterialPtr);
0049 ACTS_VERBOSE("- and material at central layer surface.");
0050 } else {
0051
0052
0053
0054 auto approachSurfaces =
0055 cLayer->approachDescriptor()->containedSurfaces();
0056 if (m_cfg.centralLayerMaterialConcentration.at(icl) > 0) {
0057 auto mutableOuterSurface =
0058 const_cast<Acts::Surface*>(approachSurfaces.at(1));
0059 mutableOuterSurface->assignSurfaceMaterial(layerMaterialPtr);
0060 ACTS_VERBOSE("- and material at outer approach surface");
0061 } else {
0062 auto mutableInnerSurface =
0063 const_cast<Acts::Surface*>(approachSurfaces.at(0));
0064 mutableInnerSurface->assignSurfaceMaterial(layerMaterialPtr);
0065 ACTS_VERBOSE("- and material at inner approach surface");
0066 }
0067 }
0068 }
0069
0070 cLayers.push_back(cLayer);
0071 ++icl;
0072 }
0073 return cLayers;
0074 }
0075
0076 const Acts::LayerVector LayerBuilder::negativeLayers(
0077 const Acts::GeometryContext& gctx) const {
0078 return constructEndcapLayers(gctx, -1);
0079 }
0080
0081 const Acts::LayerVector LayerBuilder::positiveLayers(
0082 const Acts::GeometryContext& gctx) const {
0083 return constructEndcapLayers(gctx, 1);
0084 }
0085
0086 LayerBuilder::LayerBuilder(const Config& cfg,
0087 std::unique_ptr<const Acts::Logger> log)
0088 : Acts::ILayerBuilder(), m_cfg(cfg), m_logger(std::move(log)) {}
0089
0090 const Acts::LayerVector LayerBuilder::constructEndcapLayers(
0091 const Acts::GeometryContext& gctx, int side) const {
0092
0093 const auto& protoLayers =
0094 (side < 0) ? m_cfg.negativeProtoLayers : m_cfg.positiveProtoLayers;
0095
0096
0097 Acts::LayerVector eLayers;
0098 eLayers.reserve(protoLayers.size());
0099
0100
0101 std::size_t ipnl = 0;
0102
0103 for (auto& ple : protoLayers) {
0104
0105 Acts::ProtoLayer constProtoLayer{ple.protoLayer};
0106 Acts::MutableLayerPtr eLayer =
0107 m_cfg.layerCreator->discLayer(gctx, makeConstSurfaces(ple.surfaces),
0108 ple.bins0, ple.bins1, constProtoLayer);
0109
0110
0111 if (!m_cfg.posnegLayerMaterial.empty()) {
0112 std::shared_ptr<const Acts::ISurfaceMaterial> layerMaterialPtr =
0113 m_cfg.posnegLayerMaterial[ipnl];
0114
0115 if (m_cfg.posnegLayerMaterialConcentration.at(ipnl) == 0.) {
0116
0117
0118 eLayer->surfaceRepresentation().assignSurfaceMaterial(layerMaterialPtr);
0119 ACTS_VERBOSE("- and material at central layer surface.");
0120 } else {
0121
0122
0123
0124 auto approachSurfaces =
0125 eLayer->approachDescriptor()->containedSurfaces();
0126 if (m_cfg.posnegLayerMaterialConcentration.at(ipnl) > 0.) {
0127 int sf = side < 0 ? 0 : 1;
0128 auto mutableInnerSurface =
0129 const_cast<Acts::Surface*>(approachSurfaces.at(sf));
0130 mutableInnerSurface->assignSurfaceMaterial(layerMaterialPtr);
0131 ACTS_VERBOSE("- and material at outer approach surfaces.");
0132 } else {
0133 int sf = side < 0 ? 1 : 0;
0134 auto mutableOuterSurface =
0135 const_cast<Acts::Surface*>(approachSurfaces.at(sf));
0136 mutableOuterSurface->assignSurfaceMaterial(layerMaterialPtr);
0137 ACTS_VERBOSE("- and material at inner approach surfaces.");
0138 }
0139 }
0140 }
0141
0142 eLayers.push_back(eLayer);
0143 ++ipnl;
0144 }
0145 return eLayers;
0146 }
0147
0148 }