Project
Loading...
Searching...
No Matches
SegmentationSuperAlpide.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_SEGMENTATIONSUPERALPIDE_H_
17#define ALICEO2_ITS3_SEGMENTATIONSUPERALPIDE_H_
18
19#include "MathUtils/Cartesian.h"
20#include "ITS3Base/SpecsV2.h"
21#include "Rtypes.h"
22
23#include <type_traits>
24
25namespace o2::its3
26{
27
30{
31 // This class defines the segmenation of the pixelArray in the tile. We define
32 // two coordinate systems, one width x,z detector local coordianates (cm) and
33 // the more natural row,col layout: Also all the transformation between these
34 // two. The class provides the transformation from the tile to TGeo
35 // coordinates.
36
37 // row,col=0
38 // |
39 // v
40 // x----------------------x
41 // | | |
42 // | | |
43 // | | | ^ x
44 // | | | |
45 // | | | |
46 // | | | |
47 // |-----------X----------| X marks (x,z)=(0,0) X----> z
48 // | | |
49 // | | |
50 // | | |
51 // | | |
52 // | | |
53 // | | |
54 // x----------------------x
55 public:
56 virtual ~SegmentationSuperAlpide() = default;
61 constexpr SegmentationSuperAlpide(int layer) : mLayer{layer} {}
62
63 static constexpr int mNCols{constants::pixelarray::nCols};
64 static constexpr int mNRows{constants::pixelarray::nRows};
65 static constexpr int nPixels{mNCols * mNRows};
66 static constexpr float mLength{constants::pixelarray::length};
67 static constexpr float mWidth{constants::pixelarray::width};
68 static constexpr float mPitchCol{constants::pixelarray::length / static_cast<float>(mNCols)};
69 static constexpr float mPitchRow{constants::pixelarray::width / static_cast<float>(mNRows)};
72 static constexpr std::array<float, constants::nLayers> mRadii{constants::radii};
73
83 void curvedToFlat(const float xCurved, const float yCurved, float& xFlat, float& yFlat) const noexcept
84 {
85 // MUST align the flat surface with the curved surface with the original pixel array is on
86 float dist = std::hypot(xCurved, yCurved);
87 float phiReadout = constants::tile::readout::width / constants::radii[mLayer];
88 float phi = std::atan2(yCurved, xCurved);
89 xFlat = mRadii[mLayer] * (phi - phiReadout) - constants::pixelarray::width / 2.;
90 yFlat = dist - mRadii[mLayer];
91 }
92
103 void flatToCurved(float xFlat, float yFlat, float& xCurved, float& yCurved) const noexcept
104 {
105 // MUST align the flat surface with the curved surface with the original pixel array is on
106 float dist = yFlat + mRadii[mLayer];
107 float phiReadout = constants::tile::readout::width / mRadii[mLayer];
108 xCurved = dist * std::cos(phiReadout + (xFlat + constants::pixelarray::width / 2.) / mRadii[mLayer]);
109 yCurved = dist * std::sin(phiReadout + (xFlat + constants::pixelarray::width / 2.) / mRadii[mLayer]);
110 }
111
123 bool localToDetector(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
124 {
125 localToDetectorUnchecked(xRow, zCol, iRow, iCol);
126 if (!isValid(iRow, iCol)) {
127 iRow = iCol = -1;
128 return false;
129 }
130 return true;
131 }
132
133 // Same as localToDetector w.o. checks.
134 void localToDetectorUnchecked(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
135 {
136 namespace cp = constants::pixelarray;
137 iRow = std::floor((cp::width / 2. - xRow) / mPitchRow);
138 iCol = std::floor((zCol + cp::length / 2.) / mPitchCol);
139 }
140
151 bool detectorToLocal(int const iRow, int const iCol, float& xRow, float& zCol) const noexcept
152 {
153 if (!isValid(iRow, iCol)) {
154 return false;
155 }
156 detectorToLocalUnchecked(iRow, iCol, xRow, zCol);
157 return isValid(xRow, zCol);
158 }
159
160 // Same as detectorToLocal w.o. checks.
161 // We position ourself in the middle of the pixel.
162 void detectorToLocalUnchecked(int const iRow, int const iCol, float& xRow, float& zCol) const noexcept
163 {
164 namespace cp = constants::pixelarray;
165 xRow = -(iRow + 0.5) * mPitchRow + cp::width / 2.;
166 zCol = (iCol + 0.5) * mPitchCol - cp::length / 2.;
167 }
168
169 bool detectorToLocal(int const row, int const col, math_utils::Point3D<float>& loc) const noexcept
170 {
171 float xRow{0.}, zCol{0.};
172 if (!detectorToLocal(row, col, xRow, zCol)) {
173 return false;
174 }
175 loc.SetCoordinates(xRow, 0., zCol);
176 return true;
177 }
178
179 void detectorToLocalUnchecked(int const row, int const col, math_utils::Point3D<float>& loc) const noexcept
180 {
181 float xRow{0.}, zCol{0.};
182 detectorToLocalUnchecked(row, col, xRow, zCol);
183 loc.SetCoordinates(xRow, 0., zCol);
184 }
185
186 private:
187 template <typename T>
188 [[nodiscard]] bool isValid(T const row, T const col) const noexcept
189 {
190 if constexpr (std::is_floating_point_v<T>) { // compares in local coord.
191 namespace cp = constants::pixelarray;
192 return !static_cast<bool>(row <= -cp::width / 2. || cp::width / 2. <= row || col <= -cp::length / 2. || cp::length / 2. <= col);
193 } else { // compares in rows/cols
194 return !static_cast<bool>(row < 0 || row >= static_cast<int>(mNRows) || col < 0 || col >= static_cast<int>(mNCols));
195 }
196 }
197
198 const int mLayer{0};
199
200 ClassDef(SegmentationSuperAlpide, 1);
201};
202
204extern const std::array<SegmentationSuperAlpide, constants::nLayers> SuperSegmentations;
205} // namespace o2::its3
206
207#endif
uint32_t col
Definition RawData.h:4
Segmentation and response for pixels in ITS3 upgrade.
void curvedToFlat(const float xCurved, const float yCurved, float &xFlat, float &yFlat) const noexcept
SegmentationSuperAlpide & operator=(SegmentationSuperAlpide &&)=delete
bool detectorToLocal(int const row, int const col, math_utils::Point3D< float > &loc) const noexcept
SegmentationSuperAlpide(const SegmentationSuperAlpide &)=default
SegmentationSuperAlpide & operator=(const SegmentationSuperAlpide &)=delete
void detectorToLocalUnchecked(int const iRow, int const iCol, float &xRow, float &zCol) const noexcept
static constexpr std::array< float, constants::nLayers > mRadii
SegmentationSuperAlpide(SegmentationSuperAlpide &&)=delete
virtual ~SegmentationSuperAlpide()=default
bool localToDetector(float const xRow, float const zCol, int &iRow, int &iCol) const noexcept
bool detectorToLocal(int const iRow, int const iCol, float &xRow, float &zCol) const noexcept
void flatToCurved(float xFlat, float yFlat, float &xCurved, float &yCurved) const noexcept
void detectorToLocalUnchecked(int const row, int const col, math_utils::Point3D< float > &loc) const noexcept
void localToDetectorUnchecked(float const xRow, float const zCol, int &iRow, int &iCol) const noexcept
static constexpr float mSensorLayerThicknessEff
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
constexpr float effThickness
Definition SpecsV2.h:115
constexpr float thickness
Definition SpecsV2.h:114
constexpr std::array< float, nLayers > radii
Definition SpecsV2.h:116
const std::array< SegmentationSuperAlpide, constants::nLayers > SuperSegmentations
Segmentation array.
std::vector< int > row