Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:18

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 "Acts/Detector/MultiWireStructureBuilder.hpp"
0010 
0011 #include "Acts/Detector/DetectorComponents.hpp"
0012 #include "Acts/Detector/DetectorVolumeBuilder.hpp"
0013 #include "Acts/Detector/LayerStructureBuilder.hpp"
0014 #include "Acts/Detector/ProtoBinning.hpp"
0015 #include "Acts/Detector/VolumeStructureBuilder.hpp"
0016 #include "Acts/Detector/detail/IndexedSurfacesGenerator.hpp"
0017 #include "Acts/Detector/detail/ReferenceGenerators.hpp"
0018 #include "Acts/Detector/interface/IExternalStructureBuilder.hpp"
0019 #include "Acts/Detector/interface/IInternalStructureBuilder.hpp"
0020 #include "Acts/Geometry/GeometryContext.hpp"
0021 #include "Acts/Geometry/VolumeBounds.hpp"
0022 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
0023 #include "Acts/Navigation/InternalNavigation.hpp"
0024 #include "Acts/Utilities/GridAxisGenerators.hpp"
0025 #include "Acts/Utilities/Logger.hpp"
0026 
0027 #include <algorithm>
0028 #include <functional>
0029 #include <iostream>
0030 #include <string>
0031 #include <vector>
0032 
0033 class MultiWireInternalStructureBuilder
0034     : public Acts::Experimental::IInternalStructureBuilder {
0035  public:
0036   struct Config {
0037     /// The internal surfaces
0038     std::vector<std::shared_ptr<Acts::Surface>> iSurfaces;
0039 
0040     /// Definition of Binning
0041     std::vector<Acts::Experimental::ProtoBinning> binning;
0042 
0043     /// Extra information, mainly for screen output
0044     std::string auxiliary = "";
0045 
0046     /// The transform into the local binning schema
0047     Acts::Transform3 transform = Acts::Transform3::Identity();
0048   };
0049 
0050   // Constructor
0051 
0052   MultiWireInternalStructureBuilder(
0053       const Config& cfg,
0054       std::unique_ptr<const Acts::Logger> mlogger = Acts::getDefaultLogger(
0055           "MUltiWireInternalBuilder", Acts::Logging::INFO))
0056       : Acts::Experimental::IInternalStructureBuilder(),
0057         m_cfg(cfg),
0058         m_logger(std::move(mlogger)) {}
0059 
0060   Acts::Experimental::InternalStructure construct(
0061       const Acts::GeometryContext& gctx) const final {
0062     if (!m_cfg.auxiliary.empty()) {
0063       ACTS_DEBUG(m_cfg.auxiliary);
0064     }
0065 
0066     Acts::Experimental::ExternalNavigationDelegate internalVolumeUpdater =
0067         Acts::Experimental::tryNoVolumes();
0068     // Create the indexed surfaces
0069     auto internalSurfaces = m_cfg.iSurfaces;
0070     Acts::Experimental::detail::IndexedSurfacesGenerator<
0071         decltype(internalSurfaces),
0072         Acts::Experimental::MultiLayerSurfacesNavigation>
0073         isg{internalSurfaces,
0074             {},
0075             {m_cfg.binning[0u].axisDir, m_cfg.binning[1u].axisDir},
0076             {m_cfg.binning[0u].expansion, m_cfg.binning[1u].expansion},
0077             m_cfg.transform};
0078     Acts::Experimental::detail::CenterReferenceGenerator rGenerator;
0079     Acts::GridAxisGenerators::EqBoundEqBound aGenerator{
0080         {m_cfg.binning[0u].edges.front(), m_cfg.binning[0u].edges.back()},
0081         m_cfg.binning[0u].edges.size() - 1,
0082         {m_cfg.binning[1u].edges.front(), m_cfg.binning[1u].edges.back()},
0083         m_cfg.binning[1u].edges.size() - 1};
0084 
0085     auto sfCandidatesUpdater = isg(gctx, aGenerator, rGenerator);
0086 
0087     return {internalSurfaces,
0088             {},
0089             std::move(sfCandidatesUpdater),
0090             std::move(internalVolumeUpdater)};
0091   }
0092 
0093  private:
0094   /// Configuration object
0095   Config m_cfg;
0096 
0097   /// Private access method to the logger
0098   const Acts::Logger& logger() const { return *m_logger; }
0099 
0100   /// logging instance
0101   std::unique_ptr<const Acts::Logger> m_logger;
0102 };
0103 
0104 Acts::Experimental::MultiWireStructureBuilder::MultiWireStructureBuilder(
0105     const Acts::Experimental::MultiWireStructureBuilder::Config& config,
0106     std::unique_ptr<const Acts::Logger> logger)
0107     : mCfg(config), mLogger(std::move(logger)) {
0108   // check if the surfaces are set
0109   if (mCfg.mlSurfaces.empty()) {
0110     throw std::invalid_argument(
0111         "MultiWireStructureBuilder: No surfaces are given");
0112   } else if (mCfg.mlBinning.size() != 2u) {
0113     throw ::std::invalid_argument(
0114         "MultiWireStructureBuilder: Invalid binning provided");
0115   }
0116 }
0117 
0118 Acts::Experimental::DetectorComponent
0119 Acts::Experimental::MultiWireStructureBuilder::construct(
0120     const Acts::GeometryContext& gctx) {
0121   // Configure the external structure builder for the internal structure
0122   Acts::Experimental::VolumeStructureBuilder::Config vsConfig;
0123   vsConfig.boundsType = Acts::VolumeBounds::eTrapezoid;
0124   vsConfig.transform = mCfg.transform;
0125   vsConfig.boundValues = mCfg.mlBounds;
0126   vsConfig.auxiliary = "Construct External Structure";
0127 
0128   // Configure the internal structure builder for the internal structure
0129   MultiWireInternalStructureBuilder::Config iConfig;
0130   iConfig.iSurfaces = mCfg.mlSurfaces;
0131   iConfig.binning = mCfg.mlBinning;
0132   iConfig.transform = mCfg.transform.inverse();
0133   iConfig.auxiliary = "Construct Internal Structure";
0134 
0135   Acts::Experimental::DetectorVolumeBuilder::Config dvConfig;
0136   dvConfig.auxiliary = "Construct Detector Volume";
0137   dvConfig.name = mCfg.name;
0138   dvConfig.internalsBuilder =
0139       std::make_shared<MultiWireInternalStructureBuilder>(
0140           iConfig,
0141           Acts::getDefaultLogger("MultiWire Internal Structure Builder",
0142                                  Acts::Logging::VERBOSE));
0143   dvConfig.externalsBuilder =
0144       std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
0145           vsConfig, Acts::getDefaultLogger("VolumeStructureBuilder",
0146                                            Acts::Logging::VERBOSE));
0147   auto dvBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
0148       dvConfig,
0149       Acts::getDefaultLogger("DetectorVolumeBuilder", Acts::Logging::VERBOSE));
0150 
0151   auto dvComponent = dvBuilder->construct(gctx);
0152 
0153   return dvComponent;
0154 }