Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-06 07:51:41

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/Geometry/BoundarySurfaceFace.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Geometry/ITrackingVolumeHelper.hpp"
0015 #include "Acts/Utilities/AxisDefinitions.hpp"
0016 #include "Acts/Utilities/Logger.hpp"
0017 
0018 #include <iosfwd>
0019 #include <memory>
0020 #include <string>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 class Layer;
0026 class TrackingVolume;
0027 class VolumeBounds;
0028 class CylinderVolumeBounds;
0029 class IVolumeMaterial;
0030 class ILayerArrayCreator;
0031 class ITrackingVolumeArrayCreator;
0032 
0033 /// @class CylinderVolumeHelper
0034 ///
0035 /// The concrete implementation for cylindrical TrackingVolume
0036 /// objects of the ITrackingVolumeCreator interface
0037 ///
0038 class CylinderVolumeHelper : public ITrackingVolumeHelper {
0039  public:
0040   /// @struct Config
0041   /// Nested configuration struct for this CylinderVolumeHelper
0042   struct Config {
0043     /// a tool for coherent LayerArray creation
0044     std::shared_ptr<const ILayerArrayCreator> layerArrayCreator = nullptr;
0045     /// Helper Tool to create TrackingVolume
0046     std::shared_ptr<const ITrackingVolumeArrayCreator>
0047         trackingVolumeArrayCreator = nullptr;
0048     /// thickness of passive layers
0049     double passiveLayerThickness = 1;
0050     /// bins in phi for the passive layer
0051     int passiveLayerPhiBins = 1;
0052     /// bins in r/z for the passive layer
0053     int passiveLayerRzBins = 100;
0054   };
0055 
0056   /// Constructor
0057   /// @param cvhConfig is the configuration struct for this builder
0058   /// @param logger logging instance
0059   explicit CylinderVolumeHelper(const Config& cvhConfig,
0060                                 std::unique_ptr<const Logger> logger =
0061                                     getDefaultLogger("CylinderVolumeHelper",
0062                                                      Logging::INFO));
0063 
0064   /// Create a TrackingVolume* from a set of layers and (optional) parameters
0065   ///
0066   /// @param gctx is the geometry context for witch the volume is built
0067   /// @param layers vector of static layers confined by the TrackingVolume
0068   /// if no bounds or HepTransform is given, they define the size
0069   /// together with the volume enevlope parameters
0070   /// @param volumeMaterial material properties for this TrackingVolume
0071   /// @param volumeBounds: confinement of this TrackingVolume
0072   /// @param mtvVector (optional) Vector of confined TrackingVolumes
0073   /// @param transform (optional) placement of this TrackingVolume
0074   /// @param volumeName  volume name to be given
0075   /// @param bType (optional) BinningType - arbitrary(default) or equidistant
0076   ///
0077   /// @return shared pointer to a new TrackingVolume
0078   MutableTrackingVolumePtr createTrackingVolume(
0079       const GeometryContext& gctx, const LayerVector& layers,
0080       std::shared_ptr<const IVolumeMaterial> volumeMaterial,
0081       std::shared_ptr<VolumeBounds> volumeBounds,
0082       MutableTrackingVolumeVector mtvVector = {},
0083       const Transform3& transform = Transform3::Identity(),
0084       const std::string& volumeName = "UndefinedVolume",
0085       BinningType bType = arbitrary) const override;
0086 
0087   /// Create a TrackingVolume* from a set of layers and (optional) parameters
0088   ///
0089   /// @param gctx is the geometry context for witch the volume is built
0090   /// @param layers vector of static layers confined by the TrackingVolume
0091   /// if no bounds or HepTransform is given, they define the size
0092   /// together with the volume enevlope parameters
0093   /// @param volumeMaterial material properties for this TrackingVolume
0094   /// @param mtvVector Vector of confined TrackingVolumes
0095   /// @param rMin minimum radius
0096   /// @param rMax maximum radius
0097   /// @param zMin minimum z
0098   /// @param zMax maximum z
0099   /// @param volumeName  volume name to be given
0100   /// @param bType (optional) BinningType - arbitrary(default) or equidistant
0101   ///
0102   /// @return shared pointer to a new TrackingVolume
0103   MutableTrackingVolumePtr createTrackingVolume(
0104       const GeometryContext& gctx, const LayerVector& layers,
0105       MutableTrackingVolumeVector mtvVector,
0106       std::shared_ptr<const IVolumeMaterial> volumeMaterial, double rMin,
0107       double rMax, double zMin, double zMax,
0108       const std::string& volumeName = "UndefinedVolume",
0109       BinningType bType = arbitrary) const override;
0110 
0111   /// Create a gap volume from dimensions and
0112   /// @note this TrackingVolume is restricted to Translation only
0113   ///
0114   /// @param [in] gctx the geometry context for this building
0115   /// @param mtvVector Vector of confined TrackingVolumes
0116   /// @param volumeMaterial dense material properties for this TrackingVolume
0117   /// @param rMin minimum radius
0118   /// @param rMax maximum radius
0119   /// @param zMin minimum z
0120   /// @param zMax maximum z
0121   /// @param materialLayers number of material layers (equidistant binning)
0122   /// @param cylinder type of layers
0123   /// @param volumeName  volume name to be given
0124   ///
0125   /// @return shared pointer to a new TrackingVolume
0126   MutableTrackingVolumePtr createGapTrackingVolume(
0127       const GeometryContext& gctx, MutableTrackingVolumeVector& mtvVector,
0128       std::shared_ptr<const IVolumeMaterial> volumeMaterial, double rMin,
0129       double rMax, double zMin, double zMax, unsigned int materialLayers,
0130       bool cylinder = true,
0131       const std::string& volumeName = "UndefinedVolume") const override;
0132 
0133   /// Create a gap volume from dimensions and
0134   ///
0135   /// @param [in] gctx the geometry context for this building
0136   /// @param mtvVector Vector of confined TrackingVolumes
0137   /// @param volumeMaterial dense material properties for this TrackingVolume
0138   /// @param rMin minimum radius
0139   /// @param rMax maximum radius
0140   /// @param zMin minimum z
0141   /// @param zMax maximum z
0142   /// @param layerPositions custom layer positions
0143   /// @param cylinder type of layers
0144   /// @param volumeName  : volume name to be given
0145   /// @param bType (optional) BinningType - arbitrary(default) or equidistant
0146   ///
0147   /// @return shared pointer to a new TrackingVolume
0148   MutableTrackingVolumePtr createGapTrackingVolume(
0149       const GeometryContext& gctx, MutableTrackingVolumeVector& mtvVector,
0150       std::shared_ptr<const IVolumeMaterial> volumeMaterial, double rMin,
0151       double rMax, double zMin, double zMax,
0152       const std::vector<double>& layerPositions, bool cylinder = true,
0153       const std::string& volumeName = "UndefinedVolume",
0154       BinningType bType = arbitrary) const override;
0155 
0156   /// Create a container volumes from sub volumes, input volumes are ordered in
0157   /// R or Z by convention
0158   ///
0159   /// @param [in] gctx the geometry context for this building
0160   /// @param volumes the volumes to be contained
0161   ///
0162   ///
0163   /// @return shared pointer to a new TrackingVolume
0164   MutableTrackingVolumePtr createContainerTrackingVolume(
0165       const GeometryContext& gctx,
0166       const TrackingVolumeVector& volumes) const override;
0167 
0168   /// Set configuration method
0169   ///
0170   /// @param cvhConfig is the configuration struct assigned
0171   void setConfiguration(const Config& cvhConfig);
0172 
0173   /// Get configuration method
0174   Config getConfiguration() const;
0175 
0176   /// Set logging instance
0177   ///
0178   /// @param newLogger is the logger instance to be set
0179   void setLogger(std::unique_ptr<const Logger> newLogger);
0180 
0181  protected:
0182   /// Configuration object
0183   Config m_cfg;
0184 
0185  private:
0186   /// Private access method to the logging instance
0187   const Logger& logger() const { return *m_logger; }
0188 
0189   /// the looging instance
0190   std::unique_ptr<const Logger> m_logger;
0191 
0192   /// Private method - it estimates the CylinderBounds and Translation
0193   /// of layers, these are checked against the layer positions/dimensions.
0194   ///
0195   /// @param gctx [in] the geometry context of this build
0196   /// @param layers the layers for which the dimensions are checked
0197   /// @param cylinderVolumeBounds the cylinder volume bounds needed for wrapping
0198   /// @param transform a transformation of the layers, volume
0199   /// @param rMinClean the smallest radius given by layers
0200   /// @param rMaxClean the maximal radius given by layers
0201   /// @param zMinClean the smallest z extend given by layers
0202   /// @param zMaxClean the maximal z extend given by layers
0203   /// @param bValue the binning value in which the binning works
0204   /// @param bType is the type of binning: equidistant, arbitrary
0205   bool estimateAndCheckDimension(
0206       const GeometryContext& gctx, const LayerVector& layers,
0207       std::shared_ptr<CylinderVolumeBounds>& cylinderVolumeBounds,
0208       const Transform3& transform, double& rMinClean, double& rMaxClean,
0209       double& zMinClean, double& zMaxClean, AxisDirection& bValue,
0210       BinningType bType = arbitrary) const;
0211 
0212   /// Private method - interglue all volumes contained by a TrackingVolume
0213   /// and set the outside glue volumes in the descriptor
0214   ///
0215   /// @param gctx [in] the geometry context of this build
0216   /// @param tVolume the tracking volume that is glued together
0217   /// @param rBinned a boolean indicating if it is binned in r
0218   /// @param rMin the minimum radius of the volume
0219   /// @param rGlueMin the minimum glue radius (@todo check and document)
0220   /// @param rMax the maximum radius of the volume
0221   /// @param zMin the minimum z extend of the volume
0222   /// @param zMax the maximum z extend of the volume
0223   bool interGlueTrackingVolume(const GeometryContext& gctx,
0224                                const MutableTrackingVolumePtr& tVolume,
0225                                bool rBinned, double rMin, double rGlueMin,
0226                                double rMax, double zMin, double zMax) const;
0227 
0228   /// Private method - glue volume to the other
0229   ///
0230   /// @param gctx [in] the geometry context of this build
0231   /// @param tvolOne is the first volume in the glue process
0232   /// @param faceOne is the first boundary face of the glue process
0233   /// @param tvolTwo is the second volume in the glue process
0234   /// @param faceTwo is the second boundary face of the glue process
0235   /// @param rMin the minimum radius of the volume
0236   /// @param rGlueMin the minimum glue radius (@todo check and document)
0237   /// @param rMax the maximum radius of the volume
0238   /// @param zMin the minimum z extend of the volume
0239   /// @param zMax the maximum z extend of the volume
0240   void glueTrackingVolumes(const GeometryContext& gctx,
0241                            const MutableTrackingVolumePtr& tvolOne,
0242                            BoundarySurfaceFace faceOne,
0243                            const MutableTrackingVolumePtr& tvolTwo,
0244                            BoundarySurfaceFace faceTwo, double rMin,
0245                            double rGlueMin, double rMax, double zMin,
0246                            double zMax) const;
0247 
0248   /// Private method - helper method not to duplicate code
0249   ///
0250   /// @param tvol is the volume to which faces are added
0251   /// @param glueFace the boundary surface to which faces are added
0252   /// @param vols are the voluems which are added
0253   void addFaceVolumes(const MutableTrackingVolumePtr& tvol,
0254                       BoundarySurfaceFace glueFace,
0255                       TrackingVolumeVector& vols) const;
0256 
0257   /// Private method - helper method to save some code
0258   ///
0259   /// @param z is the z position of the layer (@todo use Transform)
0260   /// @param r is the radius of the layer
0261   /// @param halflengthZ is the half lengthz in z of the cylinder
0262   /// @param thickness is the thickness of the cylinder
0263   /// @param binsPhi are the bins for the material in phi
0264   /// @param binsZ are the bins for the material in z
0265   ///
0266   /// @return shared pointer to newly created cylinder layer
0267   LayerPtr createCylinderLayer(double z, double r, double halflengthZ,
0268                                double thickness, int binsPhi, int binsZ) const;
0269 
0270   /// Private method - helper method to save some code
0271   ///
0272   /// @param z is the z position of the layer (@todo use Transform)
0273   /// @param rMin is the minimum radius of the layer
0274   /// @param rMax is the maximal radius of the layer
0275   /// @param thickness is the thickness of the cylinder
0276   /// @param binsPhi are the bins for the material in phi
0277   /// @param binsR are the bins for the material in R
0278   ///
0279   /// @return shared pointer to newly created cylinder layer
0280   LayerPtr createDiscLayer(double z, double rMin, double rMax, double thickness,
0281                            int binsPhi, int binsR) const;
0282 };
0283 
0284 inline CylinderVolumeHelper::Config CylinderVolumeHelper::getConfiguration()
0285     const {
0286   return m_cfg;
0287 }
0288 }  // namespace Acts