Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:11

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-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 #include "Acts/Definitions/Algebra.hpp"
0011 #include "Acts/Digitization/DigitizationCell.hpp"
0012 #include "Acts/Digitization/Segmentation.hpp"
0013 #include "Acts/Surfaces/RegularSurface.hpp"
0014 
0015 #include <memory>
0016 #include <vector>
0017 
0018 namespace Acts {
0019 
0020 class Surface;
0021 
0022 using SurfacePtr = std::shared_ptr<const RegularSurface>;
0023 using SurfacePtrVector = std::vector<SurfacePtr>;
0024 
0025 /// @class DigitizationModule
0026 ///
0027 /// Class that holds the surfaces for a planar digitization detector module.
0028 ///
0029 /// It needs a descriptor to design different pixel/strixels/strip setups
0030 /// (with a segmentation class) in order to define the readout segmentation
0031 ///
0032 /// The digitizaiton is done in the local frame of the surface.
0033 ///
0034 /// The lorentz angle is assumed to be only in x-direction and constant for the
0035 /// module, it is measured from the local z-direction towards the local
0036 /// x-direction.
0037 ///
0038 /// The readout direction defines the charge drift either:
0039 /// a) towards the surface at -halfThickness if readout is defined at -1
0040 /// b) towards the surface at +halfThickness if readout is defined at +1
0041 ///
0042 /// Conventions:
0043 ///   - 3D positions are within the 3D frame of the module
0044 ///   - 2D positions are corrected to parameter surface  at the center of the
0045 ///   module (and not the readout surface)
0046 ///
0047 /// The lorenzShift is the correction from the readout surface to the parameter
0048 /// surface
0049 ///
0050 class DigitizationModule {
0051  public:
0052   /// Constructor from a Segmentation descriptor
0053   ///
0054   /// @param moduleSegmentation is the segmentation descriptions
0055   /// @param halfThickness is the half thickness of the module
0056   /// @param readoutDirection is the readout drift direction
0057   /// @param lorentzAngle is the lorentz drift angle
0058   /// @param energyThreshold Optional energy threshold for digitization
0059   /// @param analogue Run analogue digitization (defaults to false)
0060   DigitizationModule(std::shared_ptr<const Segmentation> moduleSegmentation,
0061                      double halfThickness, int readoutDirection,
0062                      double lorentzAngle, double energyThreshold = 0.,
0063                      bool analogue = false);
0064 
0065   /// Virtual Destructor
0066   virtual ~DigitizationModule() = default;
0067 
0068   /// Return the internal test segmentation surfaces to test between entry
0069   /// and exit given by their cell id's - the boundaries are not given
0070   ///
0071   /// @param entryCids are the entry digitisation cell ids
0072   /// @param exitCids are the exit digitisation cell ids
0073   ///
0074   /// @return object is a vector of shared surfaces
0075   const SurfacePtrVector segmentationSurfaces(
0076       const DigitizationCell& entryCids,
0077       const DigitizationCell& exitCids) const;
0078 
0079   /// Get the digitization cell from a position
0080   /// @param position The position to query
0081   /// @return
0082   const DigitizationCell cell(const Vector2& position) const;
0083 
0084   /// Return the module thickness
0085   double halfThickness() const;
0086 
0087   /// Return the readout direction
0088   int readoutDirection() const;
0089 
0090   /// Return the lorentz Angle
0091   double lorentzAngle() const;
0092 
0093   /// Return the energy threshold per cell of the module
0094   double energyThreshold() const;
0095 
0096   /// Indicates if the readout of the module is analogue, default is digital
0097   bool analogue() const;
0098 
0099   /// return the segmenation
0100   const Segmentation& segmentation() const;
0101 
0102   /// Return the test surfaces between these points
0103   ///
0104   /// @param start is the start position of the step
0105   /// @param end is the end position of the step
0106   ///
0107   /// @return stepSurfaces are the surfaces to test
0108   SurfacePtrVector stepSurfaces(const Vector3& start, const Vector3& end) const;
0109 
0110   /// Fill the associated digitization cell from this start and end position,
0111   /// correct for lorentz effect if needed
0112   ///
0113   /// @param start is the start position of the step
0114   /// @param end is the end position of the step
0115   /// @return the digitization step
0116   DigitizationStep digitizationStep(const Vector3& start,
0117                                     const Vector3& end) const;
0118 
0119   /// Return the bounding surfaces including top and bottom
0120   const SurfacePtrVector& boundarySurfaces() const;
0121 
0122   /// Return all surfaces in X - excluding the boundaries
0123   const SurfacePtrVector& segmentationSurfacesX() const;
0124 
0125   /// Return all surfaces in Y - excluding the boundaries
0126   const SurfacePtrVector& segmentationSurfacesY() const;
0127 
0128  private:
0129   /// half thickness of the module
0130   double m_halfThickness;
0131   /// readout is along (+1) / (-1) wrt local z axis
0132   int m_readoutDirection;
0133   /// the lorentz angle
0134   double m_lorentzAngle;
0135   /// and the tangent of it
0136   double m_tanLorentzAngle;
0137   /// energy threshold per cell
0138   double m_energyThreshold;
0139   /// flag indicating if module is read out analogue
0140   bool m_analogue;
0141   /// segmentation descriptor
0142   std::shared_ptr<const Segmentation> m_segmentation;
0143   /// boundary surfaces z, x, y
0144   SurfacePtrVector m_boundarySurfaces;
0145   /// segmentation surfaces in X - without boundaries
0146   SurfacePtrVector m_segmentationSurfacesX;
0147   /// segmentation surfaces in Y - without boundaries
0148   SurfacePtrVector m_segmentationSurfacesY;
0149 };
0150 
0151 inline double DigitizationModule::halfThickness() const {
0152   return m_halfThickness;
0153 }
0154 
0155 inline int DigitizationModule::readoutDirection() const {
0156   return m_readoutDirection;
0157 }
0158 
0159 inline double DigitizationModule::lorentzAngle() const {
0160   return m_lorentzAngle;
0161 }
0162 
0163 inline double DigitizationModule::energyThreshold() const {
0164   return m_energyThreshold;
0165 }
0166 
0167 inline bool DigitizationModule::analogue() const {
0168   return m_analogue;
0169 }
0170 
0171 inline const Segmentation& DigitizationModule::segmentation() const {
0172   return (*(m_segmentation.get()));
0173 }
0174 
0175 inline const SurfacePtrVector& DigitizationModule::boundarySurfaces() const {
0176   return m_boundarySurfaces;
0177 }
0178 
0179 inline const SurfacePtrVector& DigitizationModule::segmentationSurfacesX()
0180     const {
0181   return m_segmentationSurfacesX;
0182 }
0183 
0184 inline const SurfacePtrVector& DigitizationModule::segmentationSurfacesY()
0185     const {
0186   return m_segmentationSurfacesY;
0187 }
0188 
0189 inline DigitizationStep DigitizationModule::digitizationStep(
0190     const Vector3& start, const Vector3& end) const {
0191   return m_segmentation->digitizationStep(start, end, m_halfThickness,
0192                                           m_readoutDirection, m_lorentzAngle);
0193 }
0194 }  // namespace Acts