File indexing completed on 2025-08-06 08:17:55
0001
0002
0003
0004
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;
0021 static constexpr float PassiveEdgeTop = 37.44e-4;
0022 static constexpr float PassiveEdgeSide = 29.12e-4;
0023 static constexpr float ActiveMatrixSizeCols = PitchCol * NCols;
0024 static constexpr float ActiveMatrixSizeRows = PitchRow * NRows;
0025
0026
0027 static constexpr float SensorLayerThicknessEff = 22.e-4;
0028 static constexpr float SensorLayerThickness = 30.e-4;
0029 static constexpr float SensorSizeCols = ActiveMatrixSizeCols + PassiveEdgeSide + PassiveEdgeSide;
0030 static constexpr float SensorSizeRows = ActiveMatrixSizeRows + PassiveEdgeTop + PassiveEdgeReadOut;
0031
0032 SegmentationAlpide() = default;
0033 ~SegmentationAlpide() = default;
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 static bool localToDetector(float x, float z, int& iRow, int& iCol);
0047
0048 static void localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol);
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
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
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
0082 xRow = 0.5 * (ActiveMatrixSizeRows - PassiveEdgeTop + PassiveEdgeReadOut) - xRow;
0083 zCol += 0.5 * ActiveMatrixSizeCols;
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
0096 xRow = 0.5 * (ActiveMatrixSizeRows - PassiveEdgeTop + PassiveEdgeReadOut) - xRow;
0097 zCol += 0.5 * ActiveMatrixSizeCols;
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