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 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Digitization/DigitizationCell.hpp"
0013 #include "Acts/Digitization/Segmentation.hpp"
0014 #include "Acts/Surfaces/PlanarBounds.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Utilities/BinUtility.hpp"
0017 
0018 #include <cstddef>
0019 #include <memory>
0020 #include <utility>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 /// @brief Segmentation Base class
0026 ///
0027 /// Segmentation class for generic pixel, strixels and strip segmentations
0028 /// in a cartesian frame, this uses a cartesian X/Y local surface definition
0029 ///
0030 /// The calculation can be done in full 3D, i.e. the segments of the path
0031 /// through
0032 /// the planar module are calculated in a 3D model - or in 2D, when the entire
0033 /// calculation is done on the projective surface. When the 2D option is used,
0034 /// segmentation surfaces are not created. The 2D calculation is faster and uses
0035 /// less memory, however, effects within the sensor volume can not be easily
0036 /// integrated
0037 ///
0038 /// Conventions:
0039 ///   - 3D positions are within the 3D frame of the module
0040 ///   - 2D positions are corrected to the readout surface
0041 ///     they need to be corrected by the lorentzShift
0042 ///     for the parameter surface in the center of the surface)
0043 ///
0044 class CartesianSegmentation : public Segmentation {
0045  public:
0046   /// Constructor for all same-size pixels or strips
0047   /// (in cas numCellsY is set to 1)
0048   ///
0049   /// @param mBounds are the rectangle bounds of the sensitive volume
0050   /// @param numCellsX is the number of cells in X
0051   /// @param numCellsY is the number of cells in Y
0052   CartesianSegmentation(const std::shared_ptr<const PlanarBounds>& mBounds,
0053                         std::size_t numCellsX, std::size_t numCellsY = 1);
0054 
0055   /// @todo constructor from BinUtilities for more complex readouts
0056   ///
0057   /// @param bUtility is the bin Utility,
0058   //  it will define the RectangleBounds if none are provided
0059   /// @param mBounds are the rectangle bounds if provided for memory
0060   /// optimisation
0061   ///
0062   /// @note if both RectangleBounds and BinUtility are provided, no check is
0063   /// done for consistency
0064   CartesianSegmentation(std::shared_ptr<const BinUtility> bUtility,
0065                         std::shared_ptr<const PlanarBounds> mBounds = nullptr);
0066 
0067   /// Virtual Destructor
0068   ~CartesianSegmentation() override;
0069 
0070   /// @copydoc Acts::Segmentation::createSegmentationSurfaces
0071   ///
0072   /// Create the segmentation surfaces in X and Y for rectangular shapes
0073   /// These are needed for a full three dimensional module
0074   void createSegmentationSurfaces(SurfacePtrVector& boundarySurfaces,
0075                                   SurfacePtrVector& segmentationSurfacesX,
0076                                   SurfacePtrVector& segmentationSurfacesY,
0077                                   double halfThickness,
0078                                   int readoutDirection = 1.,
0079                                   double lorentzAngle = 0.) const final;
0080 
0081   /// @copydoc Segmentation::cell
0082   DigitizationCell cell(const Vector3& position) const final;
0083 
0084   /// @copydoc Segmentation::cell
0085   DigitizationCell cell(const Vector2& position) const final;
0086 
0087   /// @copydoc Segmentation::cellPosition
0088   Vector2 cellPosition(const DigitizationCell& dCell) const final;
0089 
0090   /// Fill the associated digitization cell from this start and end position
0091   /// correct for lorentz effect if needed
0092   ///
0093   /// @copydoc Segmentation::digitizationStep
0094   DigitizationStep digitizationStep(const Vector3& start, const Vector3& end,
0095                                     double halfThickness,
0096                                     int readoutDirection = 1,
0097                                     double lorentzAngle = 0.) const final;
0098 
0099   /// return the surface bounds by reference
0100   /// specialization for Rectangle Bounds
0101   const PlanarBounds& moduleBounds() const final;
0102 
0103   /// return the bin utility that defines the
0104   /// readout segmentation
0105   const BinUtility& binUtility() const final;
0106 
0107   /// return the pitch sizes as a pair
0108   std::pair<double, double> pitch() const;
0109 
0110  private:
0111   template <class T>
0112   DigitizationCell cellT(const T& position) const;
0113 
0114   std::shared_ptr<const PlanarBounds> m_activeBounds;  /// active area size
0115   std::shared_ptr<const BinUtility> m_binUtility;      /// bin Utility
0116 };
0117 
0118 inline const PlanarBounds& CartesianSegmentation::moduleBounds() const {
0119   return (*(m_activeBounds.get()));
0120 }
0121 
0122 inline const BinUtility& CartesianSegmentation::binUtility() const {
0123   return (*(m_binUtility.get()));
0124 }
0125 
0126 template <class T>
0127 DigitizationCell CartesianSegmentation::cellT(const T& position) const {
0128   return DigitizationCell(m_binUtility->bin(position, 0),
0129                           m_binUtility->bin(position, 1));
0130 }
0131 
0132 inline DigitizationCell CartesianSegmentation::cell(
0133     const Vector3& position) const {
0134   return cellT<Vector3>(position);
0135 }
0136 
0137 inline DigitizationCell CartesianSegmentation::cell(
0138     const Vector2& position) const {
0139   return cellT<Vector2>(position);
0140 }
0141 
0142 inline std::pair<double, double> CartesianSegmentation::pitch() const {
0143   auto boundingBox = m_activeBounds->boundingBox();
0144   auto values = boundingBox.values();
0145   double pitchX = 2. * values[0] / m_binUtility->bins(0);
0146   double pitchY = 2. * values[1] / m_binUtility->bins(1);
0147   return std::pair<double, double>(pitchX, pitchY);
0148 }
0149 
0150 }  // namespace Acts