Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:55

0001 /**
0002  * @file mvtx/SegmentationAlpide.h
0003  * @author YCM, from ALICE geom of 08/04/2019
0004  * @brief mvtx object with ALPIDE chip description
0005  */
0006 #ifndef MVTX_ALPIDE_SEGMENTATION_H
0007 #define MVTX_ALPIDE_SEGMENTATION_H
0008 
0009 #include <TVector3.h>
0010 #include <iostream>
0011 
0012 class SegmentationAlpide
0013 {
0014  public:
0015   static constexpr int NCols = 1024;
0016   static constexpr int NRows = 512;
0017   static constexpr int NPixels = NRows * NCols;
0018   static constexpr float PitchCol = 29.24e-4;
0019   static constexpr float PitchRow = 26.88e-4;
0020   static constexpr float PassiveEdgeReadOut = 0.12f;               // width of the readout edge (Passive bottom)
0021   static constexpr float PassiveEdgeTop = 37.44e-4;                // Passive area on top
0022   static constexpr float PassiveEdgeSide = 29.12e-4;               // width of Passive area on left/right of the sensor
0023   static constexpr float ActiveMatrixSizeCols = PitchCol * NCols;  // Active size along columns
0024   static constexpr float ActiveMatrixSizeRows = PitchRow * NRows;  // Active size along rows
0025 
0026   // effective thickness of sensitive layer, accounting for charge collection non-unifoemity, https://alice.its.cern.ch/jira/browse/AOC-46
0027   static constexpr float SensorLayerThicknessEff = 22.e-4;
0028   static constexpr float SensorLayerThickness = 30.e-4;                                                // effective thickness of sensitive part
0029   static constexpr float SensorSizeCols = ActiveMatrixSizeCols + PassiveEdgeSide + PassiveEdgeSide;    // SensorSize along columns
0030   static constexpr float SensorSizeRows = ActiveMatrixSizeRows + PassiveEdgeTop + PassiveEdgeReadOut;  // SensorSize along rows
0031 
0032   SegmentationAlpide() = default;
0033   ~SegmentationAlpide() = default;
0034 
0035   /// Transformation from Geant detector centered local coordinates (cm) to
0036   /// Pixel cell numbers iRow and iCol.
0037   /// Returns kTRUE if point x,z is inside sensitive volume, kFALSE otherwise.
0038   /// A value of -1 for iRow or iCol indicates that this point is outside of the
0039   /// detector segmentation as defined.
0040   /// @param float x Detector local coordinate x in cm with respect to
0041   /// the center of the sensitive volume.
0042   /// @param float z Detector local coordinate z in cm with respect to
0043   /// the center of the sensitive volulme.
0044   /// @param int iRow Detector x cell coordinate. Has the range 0 <= iRow < mNumberOfRows
0045   /// @param int iCol Detector z cell coordinate. Has the range 0 <= iCol < mNumberOfColumns
0046   static bool localToDetector(float x, float z, int& iRow, int& iCol);
0047   /// same but w/o check for row/column range
0048   static void localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol);
0049 
0050   /// Transformation from Detector cell coordiantes to Geant detector centered
0051   /// local coordinates (cm)
0052   /// @param int iRow Detector x cell coordinate. Has the range 0 <= iRow < mNumberOfRows
0053   /// @param int iCol Detector z cell coordinate. Has the range 0 <= iCol < mNumberOfColumns
0054   /// @param float x Detector local coordinate x in cm with respect to the
0055   /// center of the sensitive volume.
0056   /// @param float z Detector local coordinate z in cm with respect to the
0057   /// center of the sensitive volulme.
0058   /// If iRow and or iCol is outside of the segmentation range a value of -0.5*Dx()
0059   /// or -0.5*Dz() is returned.
0060   static bool detectorToLocal(int iRow, int iCol, float& xRow, float& zCol);
0061   static bool detectorToLocal(float row, float col, float& xRow, float& zCol);
0062   static bool detectorToLocal(float row, float col, TVector3& loc);
0063 
0064   // same but w/o check for row/col range
0065   static void detectorToLocalUnchecked(int iRow, int iCol, float& xRow, float& zCol);
0066   static void detectorToLocalUnchecked(float row, float col, float& xRow, float& zCol);
0067   static void detectorToLocalUnchecked(float row, float col, TVector3& loc);
0068 
0069   static constexpr float getFirstRowCoordinate()
0070   {
0071     return 0.5 * ((ActiveMatrixSizeRows - PassiveEdgeTop + PassiveEdgeReadOut) - PitchRow);
0072   }
0073   static constexpr float getFirstColCoordinate() { return 0.5 * (PitchCol - ActiveMatrixSizeCols); }
0074 
0075   static void print();
0076 };
0077 
0078 //_________________________________________________________________________________________________
0079 inline void SegmentationAlpide::localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol)
0080 {
0081   // convert to row/col w/o over/underflow check
0082   xRow = 0.5 * (ActiveMatrixSizeRows - PassiveEdgeTop + PassiveEdgeReadOut) - xRow;  // coordinate wrt top edge of Active matrix
0083   zCol += 0.5 * ActiveMatrixSizeCols;                                                // coordinate wrt left edge of Active matrix
0084   iRow = int(xRow / PitchRow);
0085   iCol = int(zCol / PitchCol);
0086   if (xRow < 0)
0087     iRow -= 1;
0088   if (zCol < 0)
0089     iCol -= 1;
0090 }
0091 
0092 //_________________________________________________________________________________________________
0093 inline bool SegmentationAlpide::localToDetector(float xRow, float zCol, int& iRow, int& iCol)
0094 {
0095   // convert to row/col
0096   xRow = 0.5 * (ActiveMatrixSizeRows - PassiveEdgeTop + PassiveEdgeReadOut) - xRow;  // coordinate wrt left edge of Active matrix
0097   zCol += 0.5 * ActiveMatrixSizeCols;                                                // coordinate wrt bottom edge of Active matrix
0098   if (xRow < 0 || xRow >= ActiveMatrixSizeRows || zCol < 0 || zCol >= ActiveMatrixSizeCols)
0099   {
0100     iRow = iCol = -1;
0101     return false;
0102   }
0103   iRow = int(xRow / PitchRow);
0104   iCol = int(zCol / PitchCol);
0105   return true;
0106 }
0107 
0108 //_________________________________________________________________________________________________
0109 inline void SegmentationAlpide::detectorToLocalUnchecked(int iRow, int iCol, float& xRow, float& zCol)
0110 {
0111   xRow = getFirstRowCoordinate() - iRow * PitchRow;
0112   zCol = iCol * PitchCol + getFirstColCoordinate();
0113 }
0114 
0115 //_________________________________________________________________________________________________
0116 inline void SegmentationAlpide::detectorToLocalUnchecked(float row, float col, float& xRow, float& zCol)
0117 {
0118   xRow = getFirstRowCoordinate() - row * PitchRow;
0119   zCol = col * PitchCol + getFirstColCoordinate();
0120 }
0121 
0122 //_________________________________________________________________________________________________
0123 inline void SegmentationAlpide::detectorToLocalUnchecked(float row, float col, TVector3& loc)
0124 {
0125   loc.SetXYZ(getFirstRowCoordinate() - row * PitchRow, 0.f, col * PitchCol + getFirstColCoordinate());
0126 }
0127 
0128 //_________________________________________________________________________________________________
0129 inline bool SegmentationAlpide::detectorToLocal(int iRow, int iCol, float& xRow, float& zCol)
0130 {
0131   if (iRow < 0 || iRow >= NRows || iCol < 0 || iCol >= NCols)
0132     return false;
0133   detectorToLocalUnchecked(iRow, iCol, xRow, zCol);
0134   return true;
0135 }
0136 
0137 //_________________________________________________________________________________________________
0138 inline bool SegmentationAlpide::detectorToLocal(float row, float col, float& xRow, float& zCol)
0139 {
0140   if (row < 0 || row >= NRows || col < 0 || col >= NCols)
0141     return false;
0142   detectorToLocalUnchecked(row, col, xRow, zCol);
0143   return true;
0144 }
0145 
0146 //_________________________________________________________________________________________________
0147 inline bool SegmentationAlpide::detectorToLocal(float row, float col, TVector3& loc)
0148 {
0149   if (row < 0 || row >= NRows || col < 0 || col >= NCols)
0150     return false;
0151   detectorToLocalUnchecked(row, col, loc);
0152   return true;
0153 }
0154 
0155 #endif