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
15
16#ifndef ALICEO2_ITS3_SEGMENTATIONMOSAIX_H_
17#define ALICEO2_ITS3_SEGMENTATIONMOSAIX_H_
18
19#include <type_traits>
20
21#include "MathUtils/Cartesian.h"
22#include "ITS3Base/SpecsV2.h"
23
24namespace o2::its3
25{
26
29{
30 // This class defines the segmenation of the pixelArray in the tile. We define
31 // two coordinate systems, one width x,z detector local coordianates (cm) and
32 // the more natural row,col layout: Also all the transformation between these
33 // two. The class provides the transformation from the tile to TGeo
34 // coordinates.
35 // In fact there exist three coordinate systems and one is transient.
36 // 1. The curved coordinate system. The chip's local coordinate system is
37 // defined with its center at the the mid-point of the tube.
38 // 2. The flat coordinate system. This is the tube segment projected onto a flat
39 // surface. In the projection we implicitly assume that the inner and outer
40 // stretch does not depend on the radius.
41 // Additionally, there is a difference between the flat geometrical center
42 // and the phyiscal center defined by the metal layer.
43 // 3. The detector coordinate system. Defined by the row and column segmentation
44 // defined at the upper edge in the flat coord.
45
46 // row,col=0
47 // |
48 // v
49 // x----------------------x
50 // | | |
51 // | | |
52 // | | | ^ x
53 // | | | |
54 // | | | |
55 // | | | |
56 // |-----------X----------| X marks (x,z)=(0,0) X----> z
57 // | | |
58 // | | |
59 // | | |
60 // | | |
61 // | | |
62 // | | |
63 // x----------------------x
64 public:
65 constexpr SegmentationMosaix(int layer) : mRadius(static_cast<float>(constants::radiiMiddle[layer])) {}
66 constexpr ~SegmentationMosaix() = default;
67 constexpr SegmentationMosaix(const SegmentationMosaix&) = default;
69 constexpr SegmentationMosaix& operator=(const SegmentationMosaix&) = default;
71
72 static constexpr int NCols{constants::pixelarray::nCols};
73 static constexpr int NRows{constants::pixelarray::nRows};
74 static constexpr int NPixels{NCols * NRows};
75 static constexpr float Length{constants::pixelarray::length};
76 static constexpr float LengthH{Length / 2.f};
77 static constexpr float Width{constants::pixelarray::width};
78 static constexpr float WidthH{Width / 2.f};
79 static constexpr float PitchCol{constants::pixelarray::pixels::mosaix::pitchZ};
80 static constexpr float PitchRow{constants::pixelarray::pixels::mosaix::pitchX};
82 static constexpr float NominalYShift{constants::nominalYShift};
83
99 constexpr void curvedToFlat(const float xCurved, const float yCurved, float& xFlat, float& yFlat) const noexcept
100 {
101 // MUST align the flat surface with the curved surface with the original pixel array is on and account for metal
102 // stack
103 float dist = std::hypot(xCurved, yCurved);
104 float phi = std::atan2(yCurved, xCurved);
105 xFlat = (mRadius * phi) - WidthH;
106 // the y position is in the silicon volume however we need the chip volume (silicon+metalstack)
107 // this is accounted by a y shift
108 yFlat = dist - mRadius + NominalYShift;
109 }
110
121 constexpr void flatToCurved(float xFlat, float yFlat, float& xCurved, float& yCurved) const noexcept
122 {
123 // MUST align the flat surface with the curved surface with the original pixel array is on and account for metal
124 // stack
125 // the y position is in the chip volume however we need the silicon volume
126 // this is accounted by a -y shift
127 float dist = yFlat - NominalYShift + mRadius;
128 xCurved = dist * std::cos((xFlat + WidthH) / mRadius);
129 yCurved = dist * std::sin((xFlat + WidthH) / mRadius);
130 }
131
143 constexpr bool localToDetector(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
144 {
145 localToDetectorUnchecked(xRow, zCol, iRow, iCol);
146 if (!isValid(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 constexpr bool detectorToLocal(int const iRow, int const iCol, float& xRow, float& zCol) const noexcept
171 {
172 if (!isValid(iRow, iCol)) {
173 return false;
174 }
175 detectorToLocalUnchecked(iRow, iCol, xRow, zCol);
176 return isValid(xRow, zCol);
177 }
178
179 // Same as detectorToLocal w.o. checks.
180 // We position ourself in the middle of the pixel.
181 constexpr void detectorToLocalUnchecked(int const iRow, int const iCol, float& xRow, float& zCol) const noexcept
182 {
183 xRow = -(static_cast<float>(iRow) + 0.5f) * PitchRow + WidthH;
184 zCol = (static_cast<float>(iCol) + 0.5f) * PitchCol - LengthH;
185 }
186
187 bool detectorToLocal(int const row, int 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, NominalYShift, zCol);
194 return true;
195 }
196
197 void detectorToLocalUnchecked(int const row, int 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, NominalYShift, zCol);
202 }
203
204 private:
205 template <typename T>
206 [[nodiscard]] constexpr bool isValid(T const row, T const col) const noexcept
207 {
208 if constexpr (std::is_floating_point_v<T>) { // compares in local coord.
209 return (-WidthH < row && row < WidthH && -LengthH < col && col < LengthH);
210 } else { // compares in rows/cols
211 return !static_cast<bool>(row < 0 || row >= static_cast<int>(NRows) || col < 0 || col >= static_cast<int>(NCols));
212 }
213 }
214
215 float mRadius;
216};
217
218} // namespace o2::its3
219
220#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 void detectorToLocalUnchecked(int const iRow, int const iCol, float &xRow, float &zCol) const noexcept
constexpr bool detectorToLocal(int const iRow, int const iCol, float &xRow, float &zCol) const noexcept
constexpr SegmentationMosaix(const SegmentationMosaix &)=default
constexpr ~SegmentationMosaix()=default
static constexpr float LengthH
constexpr SegmentationMosaix & operator=(SegmentationMosaix &&)=delete
void detectorToLocalUnchecked(int const row, int const col, math_utils::Point3D< float > &loc) const noexcept
constexpr SegmentationMosaix & operator=(const SegmentationMosaix &)=default
constexpr SegmentationMosaix(int layer)
bool detectorToLocal(int const row, int const col, math_utils::Point3D< float > &loc) const noexcept
static constexpr float WidthH
static constexpr float Width
static constexpr float NominalYShift
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
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
constexpr double length
Definition SpecsV2.h:37
constexpr double nominalYShift
Definition SpecsV2.h:137
constexpr double totalThickness
Definition SpecsV2.h:132
std::vector< int > row