|
||||
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/Utilities/detail/ReferenceWrapperAnyCompat.hpp" 0012 0013 #include "Acts/Definitions/Algebra.hpp" 0014 #include "Acts/Definitions/Common.hpp" 0015 #include "Acts/Definitions/Units.hpp" 0016 #include "Acts/Detector/LayerStructureBuilder.hpp" 0017 #include "Acts/Detector/ProtoBinning.hpp" 0018 #include "Acts/Geometry/Extent.hpp" 0019 #include "Acts/Surfaces/Surface.hpp" 0020 #include "Acts/Utilities/BinningData.hpp" 0021 0022 #include <tuple> 0023 #include <vector> 0024 0025 #include <DD4hep/DD4hepUnits.h> 0026 0027 class TGeoMatrix; 0028 0029 namespace dd4hep { 0030 class DetElement; 0031 } 0032 0033 namespace Acts { 0034 0035 using namespace UnitLiterals; 0036 0037 class DD4hepDetectorElement; 0038 0039 /// A factory to convert DD4hep DetectorElements into sensitive 0040 /// of passive surfaces which are filled into a Cache object, 0041 /// also the create DD4hepDetector elements are provided 0042 /// 0043 class DD4hepDetectorSurfaceFactory { 0044 public: 0045 /// Collect the sensitive surface & detector element 0046 using DD4hepSensitiveSurface = 0047 std::tuple<std::shared_ptr<DD4hepDetectorElement>, 0048 std::shared_ptr<Surface>>; 0049 0050 /// Collect the passive surfaces, bool whether it should be 0051 /// added as an "always try, i.e. assignToAll=true" surface 0052 using DD4hepPassiveSurface = std::tuple<std::shared_ptr<Surface>, bool>; 0053 0054 /// Nested cache that records the conversion status 0055 struct Cache { 0056 /// The created detector elements - for the detector store 0057 std::vector<DD4hepSensitiveSurface> sensitiveSurfaces; 0058 /// The created non-const surfaces - for further processing, 0059 std::vector<DD4hepPassiveSurface> passiveSurfaces; 0060 /// matching and conversion statistics: surfaces 0061 std::size_t convertedSurfaces = 0; 0062 /// matching and conversion statistics: materials 0063 std::size_t convertedMaterials = 0; 0064 /// The collected binnings 0065 std::vector<Experimental::ProtoBinning> binnings = {}; 0066 /// The collected supports 0067 std::vector<Experimental::ProtoSupport> supports = {}; 0068 /// Optionally provide an Extent object to measure the sensitives 0069 std::optional<Extent> sExtent = std::nullopt; 0070 /// Optionally provide an Extent object to measure the passive 0071 std::optional<Extent> pExtent = std::nullopt; 0072 /// Optionally provide an Extent constraints to measure the layers 0073 std::vector<BinningValue> extentConstraints = {}; 0074 /// The approximination for extent measuring 0075 std::size_t nExtentSegments = 1u; 0076 }; 0077 0078 /// Nested options struct to steer the conversion 0079 struct Options { 0080 /// Convert sensitive surfaces 0081 bool convertSensitive = true; 0082 /// Convert passive surfaces 0083 bool convertPassive = true; 0084 /// Convert material directly 0085 bool convertMaterial = false; 0086 /// New reference material thickness for surfaces 0087 ActsScalar surfaceMaterialThickness = 1_mm; 0088 }; 0089 0090 /// The DD4hep detector element factory 0091 /// 0092 /// @param mlogger a screen output logger 0093 DD4hepDetectorSurfaceFactory( 0094 std::unique_ptr<const Logger> mlogger = getDefaultLogger( 0095 "DD4hepDetectorSurfaceFactory", Acts::Logging::INFO)); 0096 0097 /// Construction method of the detector elements 0098 /// 0099 /// @param cache [in,out] into which the Elements are filled 0100 /// @param gctx the geometry context 0101 /// @param dd4hepElement the detector element representing the super structure 0102 /// @param options to steer the conversion 0103 /// 0104 /// @note this method will call the recursive construction 0105 void construct(Cache& cache, const GeometryContext& gctx, 0106 const dd4hep::DetElement& dd4hepElement, 0107 const Options& options); 0108 0109 private: 0110 /// @brief auto-calculate the unit length conversion 0111 static constexpr ActsScalar unitLength = 0112 Acts::UnitConstants::mm / dd4hep::millimeter; 0113 0114 /// Logging instance 0115 std::unique_ptr<const Logger> m_logger; 0116 0117 /// Private access to the logger 0118 const Logger& logger() const { return *m_logger; } 0119 0120 /// Construction method of the detector elements - recursive walk down 0121 /// 0122 /// @param cache [in,out] into which the Elements are filled 0123 /// @param gctx the geometry context 0124 /// @param dd4hepElement the detector element representing the super structure 0125 /// @param options to steer the conversion 0126 /// @param level the current level of the tree, used for log message output 0127 /// 0128 /// @note this method is called recursively 0129 void recursiveConstruct(Cache& cache, const GeometryContext& gctx, 0130 const dd4hep::DetElement& dd4hepElement, 0131 const Options& options, int level); 0132 0133 /// Method to convert a single sensitive detector element 0134 /// 0135 /// @param cache [in,out] into which the Elements are filled 0136 /// @param gctx the geometry context 0137 /// @param dd4hepElement the detector element 0138 /// @param options to steer the conversion 0139 /// 0140 /// @note the cache is handed through in order to optionally measure the 0141 /// extent of the sensitive surface and register it 0142 /// 0143 /// @return a created detector element and surface 0144 DD4hepSensitiveSurface constructSensitiveComponents( 0145 Cache& cache, const GeometryContext& gctx, 0146 const dd4hep::DetElement& dd4hepElement, const Options& options) const; 0147 0148 /// Method to convert a single sensitive detector element 0149 /// 0150 /// @param cache [in,out] into which the Elements are filled 0151 /// @param gctx the geometry context 0152 /// @param dd4hepElement the detector element 0153 /// @param options to steer the conversion 0154 /// 0155 /// @return a created surface 0156 DD4hepPassiveSurface constructPassiveComponents( 0157 Cache& cache, const GeometryContext& gctx, 0158 const dd4hep::DetElement& dd4hepElement, const Options& options) const; 0159 0160 /// Attach surface material if present 0161 /// 0162 /// @param gctx the geometry context 0163 /// @param prefix the acts prefix for the variant parameter string 0164 /// @param dd4hepElement the detector element 0165 /// @param surface the surface to attach the material to 0166 /// @param thickness the thickness of the condensed component 0167 /// @param options to steer the conversion 0168 /// 0169 /// @note the cache is handed through in order to optionally measure the 0170 /// extent of the sensitive surface and register it 0171 /// 0172 /// @note void function that also checks the options if the attachment should be applied 0173 void attachSurfaceMaterial(const GeometryContext& gctx, 0174 const std::string& prefix, 0175 const dd4hep::DetElement& dd4hepElement, 0176 Acts::Surface& surface, ActsScalar thickness, 0177 const Options& options) const; 0178 }; 0179 0180 } // namespace Acts
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |