Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 09:40:21

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 #pragma once
0010 
0011 #include "Acts/Detector/Blueprint.hpp"
0012 #include "Acts/Detector/Detector.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 #include "ActsPlugins/DD4hep/DD4hepDetectorElement.hpp"
0016 
0017 #include <memory>
0018 #include <string>
0019 #include <tuple>
0020 
0021 namespace dd4hep {
0022 class DetElement;
0023 }
0024 
0025 namespace Acts {
0026 class IMaterialDecorator;
0027 }
0028 
0029 namespace ActsPlugins {
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 DD4hepDetectorStructure {
0039  public:
0040   /// @brief  Nested options struct for the building
0041   struct Options {
0042     /// The log level of the tools
0043     Acts::Logging::Level logLevel = Acts::Logging::INFO;
0044     /// If this string is not empty, the detector is not built, but only
0045     /// a building graph is generated as `.dot` file with the given name
0046     std::string emulateToGraph = "";
0047     /// A Top level geometry id generator
0048     std::shared_ptr<const Acts::Experimental::IGeometryIdGenerator>
0049         geoIdGenerator = nullptr;
0050     /// A Top level material decorator
0051     std::shared_ptr<const Acts::IMaterialDecorator> materialDecorator = nullptr;
0052   };
0053 
0054   /// Constructor with from file name
0055   ///
0056   /// @param logger is the screen output logger
0057   ///
0058   /// @note this needs to be provided
0059   explicit DD4hepDetectorStructure(
0060       std::unique_ptr<const Acts::Logger> logger =
0061           Acts::getDefaultLogger("DD4hepLayerStructure", Acts::Logging::INFO));
0062 
0063   DD4hepDetectorStructure() = delete;
0064 
0065   /// @brief This method builds a DD4hep detector
0066   ///
0067   /// @param gctx the geometry context
0068   /// @param dd4hepElement is the dd4hep::DetElement of the world volume
0069   /// @param options is the options struct
0070   ///
0071   /// @note the lifetime of the detector elements in the returned store
0072   /// has to exceed the lifetime of the detector for memory management
0073   /// reasons.
0074   ///
0075   /// @return a detector, and the detector element store
0076   std::tuple<std::shared_ptr<const Acts::Experimental::Detector>,
0077              DD4hepDetectorElement::Store>
0078   construct(const Acts::GeometryContext& gctx,
0079             const dd4hep::DetElement& dd4hepElement,
0080             const Options& options) const;
0081 
0082  private:
0083   /// Logging instance
0084   std::unique_ptr<const Acts::Logger> m_logger;
0085 
0086   /// Private access to the logger
0087   const Acts::Logger& logger() const { return *m_logger; }
0088 };
0089 
0090 }  // namespace ActsPlugins