Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:51

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