Project
Loading...
Searching...
No Matches
SegmentationMosaix.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#ifndef ALICEO2_ITS3_SEGMENTATIONMOSAIX_H_
18#define ALICEO2_ITS3_SEGMENTATIONMOSAIX_H_
19
20#include "MathUtils/Cartesian.h"
21#include "ITS3Base/SpecsV2.h"
22
23namespace o2::its3
24{
25
28{
29 // This class defines the segmenation of the pixelArray in the tile. We define
30 // two coordinate systems, one width x,z detector local coordianates (cm) and
31 // the more natural row,col layout: Also all the transformation between these
32 // two. The class provides the transformation from the tile to TGeo
33 // coordinates.
34 // In fact there exist three coordinate systems and one is transient.
35 // 1. The curved coordinate system. The chip's local coordinate system is
36 // defined with its center at the the mid-point of the tube.
37 // 2. The flat coordinate system. This is the tube segment projected onto a flat
38 // surface. In the projection we implicitly assume that the inner and outer
39 // stretch does not depend on the radius.
40 // Additionally, there is a difference between the flat geometrical center
41 // and the phyiscal center defined by the metal layer.
42 // 3. The detector coordinate system. Defined by the row and column segmentation
43 // defined at the upper edge in the flat coord.
44
45 // O----------------------|
46 // | | |
47 // | | | ^ x
48 // | | | |
49 // | | | |
50 // | | | |
51 // | | | X----> z X marks (x,z)=(0,0)
52 // |-----------X----------|
53 // | | | O----> col O marks (row,col)=(0,0)
54 // | | | |
55 // | | | |
56 // | | | v
57 // | | | row
58 // | | |
59 // |----------------------|
60
61 public:
62 constexpr SegmentationMosaix(int layer) : mRadius(static_cast<float>(constants::radiiMiddle[layer])) {}
63 constexpr ~SegmentationMosaix() = default;
64 constexpr SegmentationMosaix(const SegmentationMosaix&) = default;
66 constexpr SegmentationMosaix& operator=(const SegmentationMosaix&) = default;
68
69 static constexpr int NCols{constants::pixelarray::nCols};
70 static constexpr int NRows{constants::pixelarray::nRows};
71 static constexpr int NPixels{NCols * NRows};
72 static constexpr float Length{constants::pixelarray::length};
73 static constexpr float LengthH{Length / 2.f};
74 static constexpr float Width{constants::pixelarray::width};
75 static constexpr float WidthH{Width / 2.f};
76 static constexpr float PitchCol{constants::pixelarray::pixels::mosaix::pitchZ};
77 static constexpr float PitchRow{constants::pixelarray::pixels::mosaix::pitchX};
79
95 constexpr void curvedToFlat(const float xCurved, const float yCurved, float& xFlat, float& yFlat) const noexcept
96 {
97 // MUST align the flat surface with the curved surface with the original pixel array is on and account for metal
98 // stack
99 float dist = std::hypot(xCurved, yCurved);
100 float phi = std::atan2(yCurved, xCurved);
101 // the y position is in the silicon volume however we need the chip volume (silicon+metalstack)
102 // this is accounted by a y shift
103 xFlat = WidthH - mRadius * phi;
104 yFlat = dist - mRadius;
105 }
106
117 constexpr void flatToCurved(float xFlat, float yFlat, float& xCurved, float& yCurved) const noexcept
118 {
119 // MUST align the flat surface with the curved surface with the original pixel array is on and account for metal
120 // stack
121 float dist = yFlat + mRadius;
122 float phi = (WidthH - xFlat) / mRadius;
123 // the y position is in the chip volume however we need the silicon volume
124 // this is accounted by a -y shift
125 xCurved = dist * std::cos(phi);
126 yCurved = dist * std::sin(phi);
127 }
128
140 constexpr bool localToDetector(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
141 {
142 if (!isValidLoc(xRow, zCol)) {
143 return false;
144 }
145 localToDetectorUnchecked(xRow, zCol, iRow, iCol);
146 if (!isValidDet(iRow, iCol)) {
147 iRow = iCol = -1;
148 return false;
149 }
150 return true;
151 }
152
153 // Same as localToDetector w.o. checks.
154 template <typename T = float>
155 constexpr void localToDetectorUnchecked(T const xRow, T const zCol, int& iRow, int& iCol) const noexcept
156 {
157 iRow = static_cast<int>(std::floor((WidthH - xRow) / PitchRow));
158 iCol = static_cast<int>(std::floor((zCol + LengthH) / PitchCol));
159 }
160
171 template <typename T = float, typename L = float>
172 bool detectorToLocal(T const row, T const col, L& xRow, L& zCol) const noexcept
173 {
174 if (!isValidDet(row, col)) {
175 return false;
176 }
177 detectorToLocalUnchecked(row, col, xRow, zCol);
178 return isValidLoc(xRow, zCol);
179 }
180
181 // Same as detectorToLocal w.o. checks.
182 // We position ourself in the middle of the pixel.
183 template <typename T = float, typename L = float>
184 void detectorToLocalUnchecked(T const row, T const col, L& xRow, L& zCol) const noexcept
185 {
186 xRow = -(row + 0.5f) * PitchRow + WidthH;
187 zCol = (col + 0.5f) * PitchCol - LengthH;
188 }
189
190 template <typename T = float, typename L = float>
191 bool detectorToLocal(T const row, T const col, math_utils::Point3D<L>& loc) const noexcept
192 {
193 L xRow{0.}, zCol{0.};
194 if (!detectorToLocal(row, col, xRow, zCol)) {
195 return false;
196 }
197 loc.SetCoordinates(xRow, 0.0f, zCol);
198 return true;
199 }
200
201 template <typename T = float, typename L = float>
202 void detectorToLocalUnchecked(T const row, T const col, math_utils::Point3D<L>& loc) const noexcept
203 {
204 L xRow{0.}, zCol{0.};
205 detectorToLocalUnchecked(row, col, xRow, zCol);
206 loc.SetCoordinates(xRow, 0.0f, zCol);
207 }
208
209 private:
210 // Check local coordinates (cm) validity.
211 template <typename T>
212 constexpr bool isValidLoc(T const x, T const z) const noexcept
213 {
214 return (-WidthH < x && x < WidthH && -LengthH < z && z < LengthH);
215 }
216
217 // Check detector coordinates validity.
218 template <typename T>
219 constexpr bool isValidDet(T const row, T const col) const noexcept
220 {
221 return (row >= 0 && row < static_cast<T>(NRows) &&
222 col >= 0 && col < static_cast<T>(NCols));
223 }
224
225 float mRadius;
226};
227
228} // namespace o2::its3
229
230#endif
uint32_t col
Definition RawData.h:4
Segmentation and response for pixels in ITS3 upgrade.
static constexpr float SensorLayerThickness
constexpr SegmentationMosaix(SegmentationMosaix &&)=delete
constexpr void flatToCurved(float xFlat, float yFlat, float &xCurved, float &yCurved) const noexcept
static constexpr float Length
constexpr void curvedToFlat(const float xCurved, const float yCurved, float &xFlat, float &yFlat) const noexcept
static constexpr float PitchCol
constexpr SegmentationMosaix(const SegmentationMosaix &)=default
constexpr ~SegmentationMosaix()=default
static constexpr float LengthH
constexpr SegmentationMosaix & operator=(SegmentationMosaix &&)=delete
void detectorToLocalUnchecked(T const row, T const col, math_utils::Point3D< L > &loc) const noexcept
constexpr SegmentationMosaix & operator=(const SegmentationMosaix &)=default
constexpr SegmentationMosaix(int layer)
bool detectorToLocal(T const row, T const col, L &xRow, L &zCol) const noexcept
static constexpr float WidthH
static constexpr float Width
bool detectorToLocal(T const row, T const col, math_utils::Point3D< L > &loc) const noexcept
static constexpr float PitchRow
constexpr void localToDetectorUnchecked(T const xRow, T const zCol, int &iRow, int &iCol) const noexcept
constexpr bool localToDetector(float const xRow, float const zCol, int &iRow, int &iCol) const noexcept
void detectorToLocalUnchecked(T const row, T const col, L &xRow, L &zCol) const noexcept
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr double length
Definition SpecsV2.h:37
constexpr double totalThickness
Definition SpecsV2.h:133
std::vector< int > row