Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:41

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Detector/LayerStructureBuilder.hpp"
0013 #include "Acts/Detector/ProtoBinning.hpp"
0014 #include "Acts/Geometry/Extent.hpp"
0015 #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp"
0016 #include "Acts/Plugins/DD4hep/DD4hepDetectorSurfaceFactory.hpp"
0017 #include "Acts/Utilities/BinningData.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 
0020 #include <memory>
0021 #include <optional>
0022 #include <string>
0023 #include <tuple>
0024 
0025 namespace dd4hep {
0026 class DetElement;
0027 }
0028 
0029 namespace Acts::Experimental {
0030 
0031 /// @brief This class allows to generate layer structure builders for dd4hep sub detectors
0032 /// It performs an intermediate step by taking dd4hep::DetElemnent objects that
0033 /// describe a detector structure and prepares the translation of the detector
0034 /// element and eventual passive surfaces.
0035 ///
0036 /// It would also build passive support structures if configured to do so.
0037 ///
0038 class DD4hepLayerStructure {
0039  public:
0040   /// Constructor with DD4hepDetectorSurfaceFactory
0041   ///
0042   /// @param surfaceFactory the surfac factory which converts dd4hep::DetElement objects
0043   /// into their Acts coutnerparts
0044   /// @param logger is the screen output logger
0045   ///
0046   /// @note this needs to be provided
0047   DD4hepLayerStructure(
0048       std::shared_ptr<DD4hepDetectorSurfaceFactory> surfaceFactory,
0049       std::unique_ptr<const Logger> logger =
0050           getDefaultLogger("DD4hepLayerStructure", Acts::Logging::INFO));
0051 
0052   DD4hepLayerStructure() = delete;
0053 
0054   /// @brief Nested options struct
0055   ///
0056   /// If a binning description or a support cylinder
0057   /// description is chosen through options, it overwrites the corresponding
0058   /// description coming from DD4hep.
0059   struct Options {
0060     /// The name of the object
0061     std::string name = "";
0062     /// An out put log level
0063     Logging::Level logLevel = Logging::INFO;
0064     // The extent structure - optionally
0065     std::optional<Extent> extent = std::nullopt;
0066     /// The extent constraints - optionally
0067     std::vector<BinningValue> extentConstraints = {};
0068     /// Approximation for the polyhedron binning nSegments
0069     unsigned int nSegments = 1u;
0070     /// Patch the binning with the extent if possible
0071     bool patchBinningWithExtent = true;
0072     /// Conversion options
0073     DD4hepDetectorSurfaceFactory::Options conversionOptions;
0074   };
0075 
0076   /// @brief This method generates a LayerStructure builder, which extends the
0077   /// IInternalStructureBuilder and can be used in the conjunction with a
0078   /// IExternalStructureBuilder to create `DetectorVolume` objects.
0079   ///
0080   /// It takes the detector element from DD4hep and some optional parameters
0081   ///
0082   /// @param dd4hepStore [in, out] the detector store for the built elements
0083   /// @param gctx the geometry context
0084   /// @param dd4hepElement the dd4hep detector element
0085   /// @param options containing the optional descriptions
0086   ///
0087   /// @return a LayerStructureBuilder, and an optional extent
0088   std::tuple<std::shared_ptr<LayerStructureBuilder>, std::optional<Extent>>
0089   builder(DD4hepDetectorElement::Store& dd4hepStore,
0090           const GeometryContext& gctx, const dd4hep::DetElement& dd4hepElement,
0091           const Options& options) const;
0092 
0093  private:
0094   /// The workorse: the surface factory
0095   std::shared_ptr<DD4hepDetectorSurfaceFactory> m_surfaceFactory = nullptr;
0096 
0097   /// Logging instance
0098   std::unique_ptr<const Logger> m_logger;
0099 
0100   /// Private access to the logger
0101   const Logger& logger() const { return *m_logger; }
0102 };
0103 
0104 }  // namespace Acts::Experimental