|
||||
File indexing completed on 2025-01-18 09:27:41
0001 // This file is part of the Acts project. 0002 // 0003 // Copyright (C) 2017-2018 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/Geometry/CylinderVolumeBuilder.hpp" 0013 #include "Acts/Geometry/CylinderVolumeHelper.hpp" 0014 #include "Acts/Geometry/GeometryContext.hpp" 0015 #include "Acts/Geometry/GeometryIdentifier.hpp" 0016 #include "Acts/Geometry/TrackingGeometry.hpp" 0017 #include "Acts/Plugins/DD4hep/DD4hepConversionHelpers.hpp" 0018 #include "Acts/Utilities/BinningType.hpp" 0019 #include "Acts/Utilities/Logger.hpp" 0020 0021 #include <algorithm> 0022 #include <functional> 0023 #include <memory> 0024 #include <vector> 0025 0026 #include <DD4hep/DetElement.h> 0027 0028 namespace Acts { 0029 class CylinderVolumeBuilder; 0030 class CylinderVolumeHelper; 0031 class IMaterialDecorator; 0032 class Logger; 0033 class TrackingGeometry; 0034 0035 /// Sort function which sorts dd4hep::DetElement by their ID 0036 /// @param [in,out] det the dd4hep::DetElements to be sorted 0037 inline void sortDetElementsByID(std::vector<dd4hep::DetElement>& det) { 0038 sort(det.begin(), det.end(), 0039 [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { 0040 return (a.id() < b.id()); 0041 }); 0042 } 0043 0044 /// @brief Global method which creates the TrackingGeometry from DD4hep input 0045 /// 0046 /// This method returns a std::unique_ptr of the TrackingGeometry from the 0047 /// World DD4hep \a DetElement. 0048 /// @pre Before using this method make sure, that the preconditions described in 0049 /// DD4hepPlugins are met. 0050 /// 0051 /// 0052 /// @param [in] worldDetElement the DD4hep DetElement of the world 0053 /// @param [in] logger A logger instance 0054 /// geometry building 0055 /// @param [in] bTypePhi is how the sensitive surfaces (modules) should be 0056 /// binned in a layer in phi direction. 0057 /// @note Possible binningtypes: 0058 /// - arbitrary - of the sizes if the surfaces and the distance in between 0059 /// vary. This mode finds out the bin boundaries by scanning through 0060 /// the surfaces. 0061 /// - equidistant - if the sensitive surfaces are placed equidistantly 0062 /// @note equidistant binningtype is recommended because it is faster not only 0063 /// while building the geometry but also for look up during the extrapolation 0064 /// @param [in] bTypeR is how the sensitive surfaces (modules) should be binned 0065 /// in a layer in r direction 0066 /// @param [in] bTypeZ is how the sensitive surfaces (modules) should be binned 0067 /// in a layer in z direction 0068 /// @param [in] layerEnvelopeR the tolerance added to the geometrical extension 0069 /// in r of the layers contained to build the volume envelope around 0070 /// @param [in] layerEnvelopeZ the tolerance added to the geometrical extension 0071 /// in z of the layers contained to build the volume envelope around 0072 /// @param [in] defaultLayerThickness In case no surfaces (to be contained by 0073 /// the layer) are handed over, the layer thickness will be set to this value 0074 /// @note Layers containing surfaces per default are not allowed to be 0075 /// attached to each other (navigation will fail at this point). 0076 /// However, to allow material layers (not containing surfaces) to be 0077 /// attached to each other, this default thickness is needed. In this 0078 /// way, the layer will be thin (with space to the next layer), but 0079 /// the material will have the 'real' thickness. 0080 /// @attention The default thickness should be set thin enough that no 0081 /// touching or overlapping with the next layer can happen. 0082 /// @param [in] sortSubDetectors @c std::function which should be used in order to 0083 /// sort all sub detectors (=all Detelements 0084 /// collected by the method 0085 /// @c collectSubDetectors() ) from bottom to top to 0086 /// ensure correct wrapping of the volumes, which 0087 /// is needed for navigation. Therefore the 0088 /// different hierarchies need to be sorted 0089 /// ascending. The default is sorting by ID. 0090 /// @param gctx The geometry context to use 0091 /// @param matDecorator is the material decorator that loads material maps 0092 /// @param geometryIdentifierHook Hook to apply to surfaces during geometry closure. 0093 /// 0094 /// @exception std::logic_error if an error in the translation occurs 0095 /// @return std::unique_ptr to the full TrackingGeometry 0096 0097 /// * The Tracking geometry needs to be built from bottom to top to ensure 0098 /// Navigation. Therefore the different hierarchies need to be sorted ascending. 0099 /// Per default the sub detectors are sorted by the id of their 0100 /// dd4hep::DetElement. In case another sorting needs to be applied, the users 0101 /// can provide their own function 0102 0103 std::unique_ptr<const TrackingGeometry> convertDD4hepDetector( 0104 dd4hep::DetElement worldDetElement, const Logger& logger, 0105 BinningType bTypePhi = equidistant, BinningType bTypeR = equidistant, 0106 BinningType bTypeZ = equidistant, double layerEnvelopeR = UnitConstants::mm, 0107 double layerEnvelopeZ = UnitConstants::mm, 0108 double defaultLayerThickness = UnitConstants::fm, 0109 const std::function<void(std::vector<dd4hep::DetElement>& detectors)>& 0110 sortSubDetectors = sortDetElementsByID, 0111 const GeometryContext& gctx = GeometryContext(), 0112 std::shared_ptr<const IMaterialDecorator> matDecorator = nullptr, 0113 std::shared_ptr<const GeometryIdentifierHook> geometryIdentifierHook = 0114 std::make_shared<GeometryIdentifierHook>()); 0115 0116 /// @brief Method internally used to create an Acts::CylinderVolumeBuilder 0117 /// 0118 /// This method creates an Acts::CylinderVolumeBuilder from a sub detector 0119 /// (= 'compound' DetElement or DetElements which are declared as 'isBarrel' or 0120 /// 'isBeampipe' by their extension. 0121 /// 0122 /// 0123 /// @param [in] subDetector the DD4hep DetElement of the subdetector 0124 /// @param [in] logger A logger instance 0125 /// @param [in] bTypePhi is how the sensitive surfaces (modules) should be 0126 /// binned in a layer in phi direction. 0127 /// @note Possible binningtypes: 0128 /// - arbitrary - of the sizes if the surfaces and the distance in between 0129 /// vary. This mode finds out the bin boundaries by scanning through 0130 /// the surfaces. 0131 /// - equidistant - if the sensitive surfaces are placed equidistantly 0132 /// @note equidistant binningtype is recommended because it is faster not only 0133 /// while building the geometry but also for look up during the extrapolation 0134 /// @param [in] bTypeR is how the sensitive surfaces (modules) should be binned 0135 /// in a layer in r direction 0136 /// @param [in] bTypeZ is how the sensitive surfaces (modules) should be binned 0137 /// in a layer in z direction 0138 /// @param [in] layerEnvelopeR the tolerance added to the geometrical extension 0139 /// in r of the layers contained to build the volume envelope around 0140 /// @param [in] layerEnvelopeZ the tolerance added to the geometrical extension 0141 /// in z of the layers contained to build the volume envelope around 0142 /// @param [in] defaultLayerThickness In case no surfaces (to be contained by 0143 /// the layer) are handed over, the layer thickness will be set to this value 0144 /// @note Layers containing surfaces per default are not allowed to be 0145 /// attached to each other (navigation will fail at this point). 0146 /// However, to allow material layers (not containing surfaces) to be 0147 /// attached to each other, this default thickness is needed. In this 0148 /// way, the layer will be thin (with space to the next layer), but 0149 /// the material will have the 'real' thickness. 0150 /// @attention The default thickness should be set thin enough that no 0151 /// touching or overlapping with the next layer can happen. 0152 /// @return std::shared_ptr the Acts::CylinderVolumeBuilder which can be used to 0153 /// build the full tracking geometry 0154 std::shared_ptr<const CylinderVolumeBuilder> volumeBuilder_dd4hep( 0155 dd4hep::DetElement subDetector, const Logger& logger, 0156 BinningType bTypePhi = equidistant, BinningType bTypeR = equidistant, 0157 BinningType bTypeZ = equidistant, double layerEnvelopeR = UnitConstants::mm, 0158 double layerEnvelopeZ = UnitConstants::mm, 0159 double defaultLayerThickness = UnitConstants::fm); 0160 0161 /// Helper method internally used to create a default 0162 /// Acts::CylinderVolumeBuilder 0163 std::shared_ptr<const CylinderVolumeHelper> cylinderVolumeHelper_dd4hep( 0164 const Logger& logger); 0165 0166 /// Method internally used by convertDD4hepDetector to collect all sub detectors 0167 /// Sub detector means each 'compound' DetElement or DetElements which are 0168 /// declared as 'isBarrel' or 'isBeampipe' by their extension. 0169 /// @param [in] detElement the dd4hep::DetElement of the volume of which the sub 0170 /// detectors should be collected 0171 /// @param [out] subdetectors the DD4hep::DetElements of the sub detectors 0172 /// contained by detElement 0173 /// @param logger a @c Logger for output 0174 void collectSubDetectors_dd4hep(dd4hep::DetElement& detElement, 0175 std::vector<dd4hep::DetElement>& subdetectors, 0176 const Logger& logger); 0177 0178 /// Method internally used by convertDD4hepDetector to collect all volumes of a 0179 /// compound detector 0180 /// @param [in] detElement the dd4hep::DetElement of the volume of which the 0181 /// compounds should be collected 0182 /// @param [out] compounds the DD4hep::DetElements of the compounds contained by 0183 /// detElement 0184 void collectCompounds_dd4hep(dd4hep::DetElement& detElement, 0185 std::vector<dd4hep::DetElement>& compounds); 0186 0187 /// Method internally used by convertDD4hepDetector 0188 /// @param [in] detElement the dd4hep::DetElement of the volume of which the 0189 /// layers should be collected 0190 /// @param [out] layers the DD4hep::DetElements of the layers contained by 0191 /// detElement 0192 /// @param logger a @c Logger for output 0193 void collectLayers_dd4hep(dd4hep::DetElement& detElement, 0194 std::vector<dd4hep::DetElement>& layers, 0195 const Logger& logger); 0196 0197 } // 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 |