|
|
|||
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/Definitions/Algebra.hpp" 0012 #include "Acts/Definitions/Units.hpp" 0013 #include "Acts/Geometry/GeometryContext.hpp" 0014 #include "Acts/Geometry/ILayerBuilder.hpp" 0015 #include "Acts/Geometry/LayerCreator.hpp" 0016 #include "Acts/Surfaces/Surface.hpp" 0017 #include "Acts/Utilities/BinUtility.hpp" 0018 #include "Acts/Utilities/BinningType.hpp" 0019 #include "Acts/Utilities/Logger.hpp" 0020 #include "ActsPlugins/DD4hep/DD4hepDetectorElement.hpp" 0021 0022 #include <memory> 0023 #include <string> 0024 #include <vector> 0025 0026 #include <DD4hep/DetElement.h> 0027 0028 class TGeoMatrix; 0029 0030 namespace Acts { 0031 class LayerCreator; 0032 class Logger; 0033 class Surface; 0034 class ISurfaceMaterial; 0035 } // namespace Acts 0036 0037 namespace ActsPlugins { 0038 /// @brief build layers of one cylinder-endcap setup from DD4hep input 0039 /// 0040 /// This class is an implementation of the Acts::ILayerBuilder, 0041 /// creating the central (layers of barrel), the negative and positive layers 0042 /// (layers of endcaps) of one hierarchy (e.g. PixelDetector, StripDetector,...) 0043 /// with input from DD4hep. 0044 0045 class DD4hepLayerBuilder : public Acts::ILayerBuilder { 0046 public: 0047 /// DD4hepDetectorElement construction factory 0048 using ElementFactory = std::function<std::shared_ptr<DD4hepDetectorElement>( 0049 const dd4hep::DetElement&, const std::string&, double, bool, 0050 std::shared_ptr<const Acts::ISurfaceMaterial>)>; 0051 /// Default factory for DD4hepDetectorElement 0052 /// @param detElement The DD4hep detector element 0053 /// @param detAxis The detector axis string 0054 /// @param thickness The thickness of the element 0055 /// @param isDisc Whether this is a disc element 0056 /// @param surfaceMaterial The surface material 0057 /// @return Shared pointer to the created DD4hepDetectorElement 0058 static std::shared_ptr<DD4hepDetectorElement> defaultDetectorElementFactory( 0059 const dd4hep::DetElement& detElement, const std::string& detAxis, 0060 double thickness, bool isDisc, 0061 std::shared_ptr<const Acts::ISurfaceMaterial> surfaceMaterial); 0062 0063 /// @struct Config 0064 /// nested configuration struct for steering of the layer builder 0065 struct Config { 0066 /// string based identification 0067 std::string configurationName = "undefined"; 0068 /// layer creator which is internally used to build layers 0069 std::shared_ptr<const Acts::LayerCreator> layerCreator = nullptr; 0070 /// the binning type of the contained surfaces in phi 0071 /// (equidistant/arbitrary) 0072 Acts::BinningType bTypePhi = Acts::equidistant; 0073 /// the binning type of the contained surfaces in r 0074 /// (equidistant/arbitrary) 0075 Acts::BinningType bTypeR = Acts::equidistant; 0076 /// the binning type of the contained surfaces in z 0077 /// (equidistant/arbitrary) 0078 Acts::BinningType bTypeZ = Acts::equidistant; 0079 /// the DD4hep::DetElements of the layers of the negative volume (negative 0080 /// endcap) 0081 /// @note if the current volume has no endcaps or no layers this parameter 0082 /// will not be set 0083 std::vector<dd4hep::DetElement> negativeLayers; 0084 /// the DD4hep::DetElements of the layers of the central volume (barrel) 0085 /// @note if the current volume has no layers this parameter will not be set 0086 std::vector<dd4hep::DetElement> centralLayers; 0087 /// the DD4hep::DetElements of the layers of the positive volume (positive 0088 /// endcap) 0089 /// @note if the current volume has no endcaps or no layers this parameter 0090 /// will not be set 0091 std::vector<dd4hep::DetElement> positiveLayers; 0092 /// The factory to create the DD4hepDetectorElement 0093 ElementFactory detectorElementFactory = defaultDetectorElementFactory; 0094 0095 /// In case no surfaces (to be contained by the layer) are handed over, the 0096 /// layer thickness will be set to this value 0097 /// @note Layers containing surfaces per default are not allowed to be 0098 /// attached to each other (navigation will bail at this point). 0099 /// However, to allow material layers (not containing surfaces) to be 0100 /// attached to each other, this default thickness is needed. In this 0101 /// way, the layer will be thin (with space to the next layer), but 0102 /// the material will have the 'real' thickness. 0103 /// @attention The default thickness should be set thin enough that no 0104 /// touching or overlapping with the next layer can happen. 0105 double defaultThickness = Acts::UnitConstants::fm; 0106 }; 0107 0108 /// Constructor 0109 /// @param config is the configuration struct 0110 /// @param logger is the logging instance 0111 DD4hepLayerBuilder(const DD4hepLayerBuilder::Config& config, 0112 std::unique_ptr<const Acts::Logger> logger); 0113 /// Destructor 0114 ~DD4hepLayerBuilder() override; 0115 0116 /// LayerBuilder interface method 0117 /// 0118 /// @param gctx the geometry context for this build call 0119 /// 0120 /// @return the layers at negative side 0121 const Acts::LayerVector negativeLayers( 0122 const Acts::GeometryContext& gctx) const final; 0123 0124 /// LayerBuilder interface method 0125 /// 0126 /// @param gctx the geometry context for this build call 0127 /// 0128 /// @return the layers at the central sector 0129 const Acts::LayerVector centralLayers( 0130 const Acts::GeometryContext& gctx) const final; 0131 0132 /// LayerBuilder interface method 0133 /// 0134 /// @param gctx the geometry context for this build call 0135 /// 0136 /// @return the layers at positive side 0137 const Acts::LayerVector positiveLayers( 0138 const Acts::GeometryContext& gctx) const final; 0139 0140 /// Name identification 0141 /// @return the string based identification of this configuration 0142 const std::string& identification() const final; 0143 0144 /// set the configuration object 0145 /// @param config is the configuration struct 0146 void setConfiguration(const Config& config); 0147 0148 /// get the configuration object 0149 /// @return Copy of the current configuration 0150 Config getConfiguration() const; 0151 0152 /// set logging instance 0153 void setLogger(std::unique_ptr<const Acts::Logger> logger); 0154 /// @param logger The logger instance to set 0155 0156 private: 0157 /// configuration object 0158 Config m_cfg; 0159 0160 /// logging instance 0161 std::unique_ptr<const Acts::Logger> m_logger; 0162 0163 /// Private access to the logger 0164 const Acts::Logger& logger() const { return *m_logger; } 0165 0166 /// Private helper method to be called for endcap layers 0167 /// 0168 /// @param gctx the geometry context for this build call 0169 /// @param dendcapLayers Vector of detector elements for the endcap layers 0170 /// @param side Which endcap side it is 0171 /// 0172 /// @return the layers for either endcap side 0173 const Acts::LayerVector endcapLayers( 0174 const Acts::GeometryContext& gctx, 0175 const std::vector<dd4hep::DetElement>& dendcapLayers, 0176 const std::string& side) const; 0177 0178 /// Private helper function collecting all sensitive detector elements of a 0179 /// layer 0180 /// @param detElement the DD4hep::DetElement of the layer 0181 /// @param surfaces the vector of surfaces which should be filled with the 0182 /// sensitive detector elements 0183 void resolveSensitive( 0184 const dd4hep::DetElement& detElement, 0185 std::vector<std::shared_ptr<const Acts::Surface>>& surfaces) const; 0186 0187 /// Private helper function to create a sensitive surface from a given 0188 /// detector element 0189 /// @param detElement the DD4hep::DetElement of sensitive surface to be 0190 /// created 0191 /// @param isDisc in case the sensitive detector module should be translated 0192 /// as disc (e.g. for endcaps) this flag should be set to true 0193 std::shared_ptr<const Acts::Surface> createSensitiveSurface( 0194 const dd4hep::DetElement& detElement, bool isDisc = false) const; 0195 0196 // Private helper function to convert the TGeo transformation matrix into 0197 // an Acts transformation matrix 0198 // @param tGeoTrans TGeo transformation matrix which should be converted 0199 Acts::Transform3 convertTransform(const TGeoMatrix* tGeoTrans) const; 0200 }; 0201 0202 inline const std::string& DD4hepLayerBuilder::identification() const { 0203 return m_cfg.configurationName; 0204 } 0205 0206 inline DD4hepLayerBuilder::Config DD4hepLayerBuilder::getConfiguration() const { 0207 return m_cfg; 0208 } 0209 0210 } // namespace ActsPlugins
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|