Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-16 07:59:47

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/GenericDetector/LayerBuilder.hpp"
0010 
0011 namespace ActsExamples::Generic {
0012 
0013 const Acts::LayerVector LayerBuilder::centralLayers(
0014     const Acts::GeometryContext& gctx) const {
0015   // create the vector
0016   Acts::LayerVector cLayers;
0017   cLayers.reserve(m_cfg.centralProtoLayers.size());
0018   // the layer counter
0019   std::size_t icl = 0;
0020   for (auto& cpl : m_cfg.centralProtoLayers) {
0021     // create the layer actually
0022     Acts::MutableLayerPtr cLayer = m_cfg.layerCreator->cylinderLayer(
0023         gctx, cpl.surfaces, cpl.bins0, cpl.bins1, cpl.protoLayer);
0024 
0025     // the layer is built let's see if it needs material
0026     if (!m_cfg.centralLayerMaterial.empty()) {
0027       std::shared_ptr<const Acts::ISurfaceMaterial> layerMaterialPtr =
0028           m_cfg.centralLayerMaterial.at(icl);
0029       // central material
0030       if (m_cfg.centralLayerMaterialConcentration.at(icl) == 0.) {
0031         // the layer surface is the material surface
0032         cLayer->surfaceRepresentation().assignSurfaceMaterial(layerMaterialPtr);
0033         ACTS_VERBOSE("- and material at central layer surface.");
0034       } else {
0035         // approach surface material
0036         // get the approach descriptor - at this stage we know that the
0037         // approachDescriptor exists
0038         auto approachSurfaces =
0039             cLayer->approachDescriptor()->containedSurfaces();
0040         if (m_cfg.centralLayerMaterialConcentration.at(icl) > 0) {
0041           auto mutableOuterSurface =
0042               const_cast<Acts::Surface*>(approachSurfaces.at(1));
0043           mutableOuterSurface->assignSurfaceMaterial(layerMaterialPtr);
0044           ACTS_VERBOSE("- and material at outer approach surface");
0045         } else {
0046           auto mutableInnerSurface =
0047               const_cast<Acts::Surface*>(approachSurfaces.at(0));
0048           mutableInnerSurface->assignSurfaceMaterial(layerMaterialPtr);
0049           ACTS_VERBOSE("- and material at inner approach surface");
0050         }
0051       }
0052     }
0053     // push it into the layer vector
0054     cLayers.push_back(cLayer);
0055     ++icl;
0056   }
0057   return cLayers;
0058 }
0059 
0060 const Acts::LayerVector LayerBuilder::negativeLayers(
0061     const Acts::GeometryContext& gctx) const {
0062   return constructEndcapLayers(gctx, -1);
0063 }
0064 
0065 const Acts::LayerVector LayerBuilder::positiveLayers(
0066     const Acts::GeometryContext& gctx) const {
0067   return constructEndcapLayers(gctx, 1);
0068 }
0069 
0070 LayerBuilder::LayerBuilder(const Config& cfg,
0071                            std::unique_ptr<const Acts::Logger> log)
0072     : Acts::ILayerBuilder(), m_cfg(cfg), m_logger(std::move(log)) {}
0073 
0074 const Acts::LayerVector LayerBuilder::constructEndcapLayers(
0075     const Acts::GeometryContext& gctx, int side) const {
0076   // The from negative or positive proto layers
0077   const auto& protoLayers =
0078       (side < 0) ? m_cfg.negativeProtoLayers : m_cfg.positiveProtoLayers;
0079 
0080   // create the vector
0081   Acts::LayerVector eLayers;
0082   eLayers.reserve(protoLayers.size());
0083 
0084   // the layer counter
0085   std::size_t ipnl = 0;
0086   // loop over the proto layers and create the actual layers
0087   for (auto& ple : protoLayers) {
0088     /// the layer is created
0089     Acts::MutableLayerPtr eLayer = m_cfg.layerCreator->discLayer(
0090         gctx, ple.surfaces, ple.bins0, ple.bins1, ple.protoLayer);
0091 
0092     // the layer is built let's see if it needs material
0093     if (!m_cfg.posnegLayerMaterial.empty()) {
0094       std::shared_ptr<const Acts::ISurfaceMaterial> layerMaterialPtr =
0095           m_cfg.posnegLayerMaterial[ipnl];
0096       // central material
0097       if (m_cfg.posnegLayerMaterialConcentration.at(ipnl) == 0.) {
0098         // assign the surface material - the layer surface is the material
0099         // surface
0100         eLayer->surfaceRepresentation().assignSurfaceMaterial(layerMaterialPtr);
0101         ACTS_VERBOSE("- and material at central layer surface.");
0102       } else {
0103         // approach surface material
0104         // get the approach descriptor - at this stage we know that the
0105         // approachDescriptor exists
0106         auto approachSurfaces =
0107             eLayer->approachDescriptor()->containedSurfaces();
0108         if (m_cfg.posnegLayerMaterialConcentration.at(ipnl) > 0.) {
0109           int sf = side < 0 ? 0 : 1;
0110           auto mutableInnerSurface =
0111               const_cast<Acts::Surface*>(approachSurfaces.at(sf));
0112           mutableInnerSurface->assignSurfaceMaterial(layerMaterialPtr);
0113           ACTS_VERBOSE("- and material at outer approach surfaces.");
0114         } else {
0115           int sf = side < 0 ? 1 : 0;
0116           auto mutableOuterSurface =
0117               const_cast<Acts::Surface*>(approachSurfaces.at(sf));
0118           mutableOuterSurface->assignSurfaceMaterial(layerMaterialPtr);
0119           ACTS_VERBOSE("- and material at inner approach surfaces.");
0120         }
0121       }
0122     }
0123     // push it into the layer vector
0124     eLayers.push_back(eLayer);
0125     ++ipnl;
0126   }
0127   return eLayers;
0128 }
0129 
0130 }  // namespace ActsExamples::Generic