ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SegmentationAlpide.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SegmentationAlpide.h
1 
6 #ifndef MVTX_ALPIDE_SEGMENTATION_H
7 #define MVTX_ALPIDE_SEGMENTATION_H
8 
9 #include <TVector3.h>
10 #include <iostream>
11 
13 {
14  public:
15  static constexpr int NCols = 1024;
16  static constexpr int NRows = 512;
17  static constexpr int NPixels = NRows * NCols;
18  static constexpr float PitchCol = 29.24e-4;
19  static constexpr float PitchRow = 26.88e-4;
20  static constexpr float PassiveEdgeReadOut = 0.12f; // width of the readout edge (Passive bottom)
21  static constexpr float PassiveEdgeTop = 37.44e-4; // Passive area on top
22  static constexpr float PassiveEdgeSide = 29.12e-4; // width of Passive area on left/right of the sensor
23  static constexpr float ActiveMatrixSizeCols = PitchCol * NCols; // Active size along columns
24  static constexpr float ActiveMatrixSizeRows = PitchRow * NRows; // Active size along rows
25 
26  // effective thickness of sensitive layer, accounting for charge collection non-unifoemity, https://alice.its.cern.ch/jira/browse/AOC-46
27  static constexpr float SensorLayerThicknessEff = 22.e-4;
28  static constexpr float SensorLayerThickness = 30.e-4; // effective thickness of sensitive part
29  static constexpr float SensorSizeCols = ActiveMatrixSizeCols + PassiveEdgeSide + PassiveEdgeSide; // SensorSize along columns
30  static constexpr float SensorSizeRows = ActiveMatrixSizeRows + PassiveEdgeTop + PassiveEdgeReadOut; // SensorSize along rows
31 
32  SegmentationAlpide() = default;
33  ~SegmentationAlpide() = default;
34 
46  static bool localToDetector(float x, float z, int& iRow, int& iCol);
48  static void localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol);
49 
60  static bool detectorToLocal(int iRow, int iCol, float& xRow, float& zCol);
61  static bool detectorToLocal(float row, float col, float& xRow, float& zCol);
62  static bool detectorToLocal(float row, float col, TVector3& loc);
63 
64  // same but w/o check for row/col range
65  static void detectorToLocalUnchecked(int iRow, int iCol, float& xRow, float& zCol);
66  static void detectorToLocalUnchecked(float row, float col, float& xRow, float& zCol);
67  static void detectorToLocalUnchecked(float row, float col, TVector3& loc);
68 
69  static constexpr float getFirstRowCoordinate()
70  {
72  }
73  static constexpr float getFirstColCoordinate() { return 0.5 * (PitchCol - ActiveMatrixSizeCols); }
74 
75  static void print();
76 };
77 
78 //_________________________________________________________________________________________________
79 inline void SegmentationAlpide::localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol)
80 {
81  // convert to row/col w/o over/underflow check
82  xRow = 0.5 * (ActiveMatrixSizeRows - PassiveEdgeTop + PassiveEdgeReadOut) - xRow; // coordinate wrt top edge of Active matrix
83  zCol += 0.5 * ActiveMatrixSizeCols; // coordinate wrt left edge of Active matrix
84  iRow = int(xRow / PitchRow);
85  iCol = int(zCol / PitchCol);
86  if (xRow < 0)
87  iRow -= 1;
88  if (zCol < 0)
89  iCol -= 1;
90 }
91 
92 //_________________________________________________________________________________________________
93 inline bool SegmentationAlpide::localToDetector(float xRow, float zCol, int& iRow, int& iCol)
94 {
95  // convert to row/col
96  xRow = 0.5 * (ActiveMatrixSizeRows - PassiveEdgeTop + PassiveEdgeReadOut) - xRow; // coordinate wrt left edge of Active matrix
97  zCol += 0.5 * ActiveMatrixSizeCols; // coordinate wrt bottom edge of Active matrix
98  if (xRow < 0 || xRow >= ActiveMatrixSizeRows || zCol < 0 || zCol >= ActiveMatrixSizeCols) {
99  iRow = iCol = -1;
100  return false;
101  }
102  iRow = int(xRow / PitchRow);
103  iCol = int(zCol / PitchCol);
104  return true;
105 }
106 
107 //_________________________________________________________________________________________________
108 inline void SegmentationAlpide::detectorToLocalUnchecked(int iRow, int iCol, float& xRow, float& zCol)
109 {
110  xRow = getFirstRowCoordinate() - iRow * PitchRow;
111  zCol = iCol*PitchCol + getFirstColCoordinate();
112 }
113 
114 //_________________________________________________________________________________________________
115 inline void SegmentationAlpide::detectorToLocalUnchecked(float row, float col, float& xRow, float& zCol)
116 {
117  xRow = getFirstRowCoordinate() - row * PitchRow;
118  zCol = col * PitchCol + getFirstColCoordinate();
119 }
120 
121 //_________________________________________________________________________________________________
122 inline void SegmentationAlpide::detectorToLocalUnchecked(float row, float col, TVector3& loc)
123 {
124  loc.SetXYZ(getFirstRowCoordinate() - row * PitchRow, 0.f, col * PitchCol + getFirstColCoordinate());
125 }
126 
127 //_________________________________________________________________________________________________
128 inline bool SegmentationAlpide::detectorToLocal(int iRow, int iCol, float& xRow, float& zCol)
129 {
130  if (iRow < 0 || iRow >= NRows || iCol<0 || iCol >= NCols)
131  return false;
132  detectorToLocalUnchecked(iRow,iCol,xRow,zCol);
133  return true;
134 }
135 
136 //_________________________________________________________________________________________________
137 inline bool SegmentationAlpide::detectorToLocal(float row, float col, float& xRow, float& zCol)
138 {
139  if (row < 0 || row >= NRows || col < 0 || col >= NCols)
140  return false;
141  detectorToLocalUnchecked(row, col, xRow, zCol);
142  return true;
143 }
144 
145 //_________________________________________________________________________________________________
146 inline bool SegmentationAlpide::detectorToLocal(float row, float col, TVector3& loc)
147 {
148  if (row < 0 || row >= NRows || col < 0 || col >= NCols)
149  return false;
150  detectorToLocalUnchecked(row, col, loc);
151  return true;
152 }
153 
154 #endif