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 constexpr void localToDetectorUnchecked(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
155 {
156 iRow = static_cast<int>(std::floor((WidthH - xRow) / PitchRow));
157 iCol = static_cast<int>(std::floor((zCol + LengthH) / PitchCol));
158 }
159
170 bool detectorToLocal(float const row, float const col, float& xRow, float& zCol) const noexcept
171 {
172 if (!isValidDet(row, col)) {
173 return false;
174 }
175 detectorToLocalUnchecked(row, col, xRow, zCol);
176 return isValidLoc(xRow, zCol);
177 }
178
179 // Same as detectorToLocal w.o. checks.
180 // We position ourself in the middle of the pixel.
181 void detectorToLocalUnchecked(float const row, float const col, float& xRow, float& zCol) const noexcept
182 {
183 xRow = -(row + 0.5f) * PitchRow + WidthH;
184 zCol = (col + 0.5f) * PitchCol - LengthH;
185 }
186
187 bool detectorToLocal(float const row, float const col, math_utils::Point3D<float>& loc) const noexcept
188 {
189 float xRow{0.}, zCol{0.};
190 if (!detectorToLocal(row, col, xRow, zCol)) {
191 return false;
192 }
193 loc.SetCoordinates(xRow, 0.0f, zCol);
194 return true;
195 }
196
197 void detectorToLocalUnchecked(float const row, float const col, math_utils::Point3D<float>& loc) const noexcept
198 {
199 float xRow{0.}, zCol{0.};
200 detectorToLocalUnchecked(row, col, xRow, zCol);
201 loc.SetCoordinates(xRow, 0.0f, zCol);
202 }
203
204 private:
205 // Check local coordinates (cm) validity.
206 template <typename T>
207 constexpr bool isValidLoc(T const x, T const z) const noexcept
208 {
209 return (-WidthH < x && x < WidthH && -LengthH < z && z < LengthH);
210 }
211
212 // Check detector coordinates validity.
213 template <typename T>
214 constexpr bool isValidDet(T const row, T const col) const noexcept
215 {
216 return (row >= 0 && row < static_cast<T>(NRows) &&
217 col >= 0 && col < static_cast<T>(NCols));
218 }
219
220 float mRadius;
221};
222
223} // namespace o2::its3
224
225#endif
uint32_t col
Definition RawData.h:4
Segmentation and response for pixels in ITS3 upgrade.
static constexpr float SensorLayerThickness
constexpr SegmentationMosaix(SegmentationMosaix &&)=delete
void detectorToLocalUnchecked(float const row, float const col, float &xRow, float &zCol) const noexcept
void detectorToLocalUnchecked(float const row, float const col, math_utils::Point3D< float > &loc) const noexcept
constexpr void flatToCurved(float xFlat, float yFlat, float &xCurved, float &yCurved) const noexcept
static constexpr float Length
bool detectorToLocal(float const row, float const col, math_utils::Point3D< float > &loc) const noexcept
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
bool detectorToLocal(float const row, float const col, float &xRow, float &zCol) const noexcept
constexpr SegmentationMosaix & operator=(const SegmentationMosaix &)=default
constexpr SegmentationMosaix(int layer)
static constexpr float WidthH
static constexpr float Width
constexpr void localToDetectorUnchecked(float const xRow, float const zCol, int &iRow, int &iCol) const noexcept
static constexpr float PitchRow
constexpr bool localToDetector(float const xRow, float const zCol, int &iRow, int &iCol) 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:132
std::vector< int > row