Project
Loading...
Searching...
No Matches
SegmentationChip.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
14
15#ifndef ALICEO2_TRK_SEGMENTATIONCHIP_H_
16#define ALICEO2_TRK_SEGMENTATIONCHIP_H_
17
18#include <type_traits>
19#include <fairlogger/Logger.h>
20
21#include "MathUtils/Cartesian.h"
22#include "TRKBase/Specs.h"
23
24namespace o2::trk
25{
26
30{
31 // This class defines the segmenation of the TRK chips in the ALICE3 upgrade.
32 // The "global coordinate system" refers to the hit position in cm in the global coordinate system centered in 0,0,0
33 // The "local coordinate system" refers to the hit position in cm in the coordinate system of the sensor, which
34 // is centered in 0,0,0 in the case of curved layers, and in the middle of the chip in the case of flat layers
35 // The "detector coordinate system" refers to the hit position in row,col inside the sensor
36 // This class provides the transformations from the local and detector coordinate systems
37 // The conversion between global and local coordinate systems is operated by the transformation matrices
38 // For the curved VD layers there exist four coordinate systems.
39 // 1. The global (curved) coordinate system. The chip's center of coordinate system is
40 // defined at the the mid-point of the detector.
41 // 2. The local (curved) coordinate system, centered in 0,0,0.
42 // 3. The local (flat) coordinate system. This is the tube segment projected onto a flat
43 // surface, centered in the middle of the chip, with the y axis pointing towards the interaction point.
44 // In the projection we implicitly assume that the inner and outer stretch does not depend on the radius.
45 // 4. The detector coordinate system. Defined by the row and column segmentation.
46 // For the flat ML and OT layers, there exist two coordinate systems:
47 // 1. The global (flat) coordinate system. The chip's center of coordinate system is
48 // defined at the the mid-point of the detector.
49 // 2. The detector coordinate system. Defined by the row and column segmentation.
50 // TODO: add segmentation for VD disks
51
52 public:
53 constexpr SegmentationChip() = default;
54 ~SegmentationChip() = default;
55 constexpr SegmentationChip(const SegmentationChip&) = default;
56 constexpr SegmentationChip(SegmentationChip&&) = delete;
57 constexpr SegmentationChip& operator=(const SegmentationChip&) = default;
59
60 static constexpr float PitchColVD{constants::VD::petal::layer::pitchZ};
61 static constexpr float PitchRowVD{constants::VD::petal::layer::pitchX};
62
65
66 static constexpr float SensorLayerThicknessVD = {constants::VD::petal::layer::totalThickness}; // physical thickness of sensitive part = 30 um
67 static constexpr float SensorLayerThicknessML = {constants::moduleMLOT::chip::totalThickness}; // physical thickness of sensitive part = 100 um
68 static constexpr float SensorLayerThicknessOT = {constants::moduleMLOT::chip::totalThickness}; // physical thickness of sensitive part = 100 um
69
70 static constexpr float SiliconThicknessVD = constants::VD::silicon::thickness; // effective thickness of sensitive part
71 static constexpr float SiliconThicknessMLOT = constants::moduleMLOT::silicon::thickness; // effective thickness of sensitive part
72
73 static constexpr std::array<double, constants::VD::petal::nLayers> radiiVD = constants::VD::petal::layer::radii;
74
75 static inline int sNPetalsVD = -1; // not set
76 static void setNumberOfPetalsVD(int n) { sNPetalsVD = n; }
77 static float getWidthVD(int layer) // get the width of the petal according to the simulated geometry (supported: kIRIS4 (4 petals), kIRIS4a (3 petals), kIRISFullCyl)
78 {
79 if (sNPetalsVD < 1) {
80 LOGP(fatal, "SegmentationChip: VD number of petals not set. GeometryTGeo::Build() must be called before using the VD segmentation");
81 }
82 if (sNPetalsVD == 1) { // FullCyl: 360°, no gap
83 return 2 * M_PI * constants::VD::petal::layer::radii[layer];
84 }
85 return constants::VD::petal::layer::radii[layer] * 2 * M_PI / sNPetalsVD - constants::VD::petal::layer::gaps[layer];
86 }
87 static int getNRowsVD(int layer) { return static_cast<int>(getWidthVD(layer) / PitchRowVD); }
88
103 static bool localToDetector(float xRow, float zCol, int& iRow, int& iCol, int subDetID, int layer, int disk) noexcept
104 {
105 if (!isValidLoc(xRow, zCol, subDetID, layer)) {
106 LOGP(debug, "Local coordinates not valid: row = {} cm, col = {} cm", xRow, zCol);
107 return false;
108 }
109 localToDetectorUnchecked(xRow, zCol, iRow, iCol, subDetID, layer, disk);
110
111 LOG(debug) << "Result from localToDetectorUnchecked: xRow " << xRow << " -> iRow " << iRow << ", zCol " << zCol << " -> iCol " << iCol << " on subDetID, layer, disk: " << subDetID << " " << layer << " " << disk;
112
113 if (!isValidDet(iRow, iCol, subDetID, layer)) {
114 iRow = iCol = -1;
115 LOGP(debug, "Detector coordinates not valid: iRow = {}, iCol = {}", iRow, iCol);
116 return false;
117 }
118 return true;
119 };
121 static void localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol, int subDetID, int layer, int disk) noexcept
122 {
123 // convert to row/col w/o over/underflow check
124 float pitchRow(0), pitchCol(0);
125 float maxWidth(0), maxLength(0);
126
127 if (subDetID == 0) {
128 pitchRow = PitchRowVD;
129 pitchCol = PitchColVD;
130 maxWidth = getWidthVD(layer);
131 maxLength = constants::VD::petal::layer::length;
132 // TODO: change this to use the layer and disk
133 } else if (subDetID == 1 || subDetID == 2) {
134 pitchRow = PitchRowMLOT;
135 pitchCol = PitchColMLOT;
136 maxWidth = constants::moduleMLOT::chip::width - constants::moduleMLOT::chip::passiveEdgeReadOut;
138 }
139 // convert to row/col
140 iRow = static_cast<int>(std::floor((maxWidth / 2 - xRow) / pitchRow));
141 iCol = static_cast<int>(std::floor((zCol + maxLength / 2) / pitchCol));
142 };
143
144 // Check local coordinates (cm) validity.
145 static bool isValidLoc(float x, float z, int subDetID, int layer) noexcept
146 {
147 float maxWidth(0), maxLength(0);
148 if (subDetID == 0) {
149 maxWidth = getWidthVD(layer);
150 maxLength = constants::VD::petal::layer::length;
151 // TODO: change this to use the layer and disk
152 } else if (subDetID == 1 || subDetID == 2) { // ML/OT
153 maxWidth = constants::moduleMLOT::chip::width - constants::moduleMLOT::chip::passiveEdgeReadOut;
155 }
156 return (-maxWidth / 2 < x && x < maxWidth / 2 && -maxLength / 2 < z && z < maxLength / 2);
157 }
158
159 // Check detector coordinates validity.
160 static bool isValidDet(int row, int col, int subDetID, int layer) noexcept
161 {
162 // Check if the row and column are within the valid range
163 int nRows(0), nCols(0);
164 if (subDetID == 0) {
165 nRows = getNRowsVD(layer);
166 nCols = constants::VD::petal::layer::nCols;
167 // TODO: change this to use the layer and disk
168 } else if (subDetID == 1 || subDetID == 2) {
171 }
172 return (row >= 0 && row < nRows && col >= 0 && col < nCols);
173 }
174
188 static bool detectorToLocal(int iRow, int iCol, float& xRow, float& zCol, int subDetID, int layer, int disk) noexcept
189 {
190 if (!isValidDet(iRow, iCol, subDetID, layer)) {
191 LOGP(debug, "Detector coordinates not valid: iRow = {}, iCol = {}", iRow, iCol);
192 return false;
193 }
194 detectorToLocalUnchecked(iRow, iCol, xRow, zCol, subDetID, layer, disk);
195 LOG(debug) << "Result from detectorToLocalUnchecked: iRow " << iRow << " -> xRow " << xRow << ", iCol " << iCol << " -> zCol " << zCol << " on subDetID, layer, disk: " << subDetID << " " << layer << " " << disk;
196
197 if (!isValidLoc(xRow, zCol, subDetID, layer)) {
198 LOGP(debug, "Local coordinates not valid: row = {} cm, col = {} cm", xRow, zCol);
199 return false;
200 }
201 return true;
202 };
203
204 // Same as detectorToLocal w.o. checks.
205 // We position ourself in the middle of the pixel.
206 static void detectorToLocalUnchecked(int row, int col, float& xRow, float& zCol, int subDetID, int layer, int disk) noexcept
207 {
210 if (subDetID == 0) {
211 xRow = 0.5 * (getWidthVD(layer) - PitchRowVD) - (row * PitchRowVD);
212 zCol = col * PitchColVD + 0.5 * (PitchColVD - constants::VD::petal::layer::length);
213 } else if (subDetID == 1 || subDetID == 2) { // ML/OT
214 xRow = 0.5 * (constants::moduleMLOT::chip::width - constants::moduleMLOT::chip::passiveEdgeReadOut - PitchRowMLOT) - (row * PitchRowMLOT);
216 }
217 }
218
230 // in cm with respect to the center of the sensitive volume.
231 static math_utils::Vector2D<float> curvedToFlat(const int layer, const float xCurved, const float yCurved) noexcept
232 {
233 // Align the flat surface with the curved survace of the original chip (and account for metal stack, TODO)
234 float dist = std::hypot(xCurved, yCurved);
235 float phi = std::atan2(yCurved, xCurved);
236
237 // the y position is in the silicon volume however we need the chip volume (silicon+metalstack)
238 // this is accounted by a y shift
239 float xFlat = constants::VD::petal::layer::radii[layer] * phi;
240 float yFlat = constants::VD::petal::layer::radii[layer] - dist;
241 return math_utils::Vector2D<float>(xFlat, yFlat);
242 }
243
252 // in cm with respect to the center of the sensitive volume.
253 static constexpr math_utils::Vector2D<float> flatToCurved(int layer, float xFlat, float yFlat) noexcept
254 {
255 // Revert the curvedToFlat transformation
256 float dist = constants::VD::petal::layer::radii[layer] - yFlat;
257 float phi = xFlat / constants::VD::petal::layer::radii[layer];
258 // the y position is in the chip volume however we need the silicon volume
259 // this is accounted by a -y shift
260 float xCurved = dist * std::cos(phi);
261 float yCurved = dist * std::sin(phi);
262 return math_utils::Vector2D<float>(xCurved, yCurved);
263 }
264
266 static void Print() noexcept
267 {
268 LOG(info) << "Number of rows:\nVD L0: " << getNRowsVD(0)
269 << "\nVD L1: " << getNRowsVD(1)
270 << "\nVD L2: " << getNRowsVD(2)
271 << "\nML/OT chip: " << constants::moduleMLOT::chip::nRows;
272
273 LOG(info) << "Number of cols:\nVD: " << constants::VD::petal::layer::nCols
274 << "\nML/OT chip: " << constants::moduleMLOT::chip::nCols;
275
276 LOG(info) << "Pitch rows x cols [um]:\nVD: " << PitchRowVD * 1e4 << "x" << PitchColVD * 1e4
277 << "\nML/OT chip: " << PitchRowMLOT * 1e4 << "x" << PitchColMLOT * 1e4;
278 }
279};
280
281} // namespace o2::trk
282
283#endif
std::ostringstream debug
uint32_t col
Definition RawData.h:4
specs of the ALICE3 TRK
static void localToDetectorUnchecked(float xRow, float zCol, int &iRow, int &iCol, int subDetID, int layer, int disk) noexcept
same but w/o check for row/column range
static constexpr math_utils::Vector2D< float > flatToCurved(int layer, float xFlat, float yFlat) noexcept
static constexpr float SiliconThicknessVD
static constexpr float SensorLayerThicknessOT
constexpr SegmentationChip()=default
static void detectorToLocalUnchecked(int row, int col, float &xRow, float &zCol, int subDetID, int layer, int disk) noexcept
constexpr SegmentationChip(SegmentationChip &&)=delete
static constexpr float SensorLayerThicknessML
static constexpr float SensorLayerThicknessVD
static bool isValidLoc(float x, float z, int subDetID, int layer) noexcept
static constexpr float PitchColVD
constexpr SegmentationChip & operator=(SegmentationChip &&)=delete
static bool localToDetector(float xRow, float zCol, int &iRow, int &iCol, int subDetID, int layer, int disk) noexcept
static constexpr float PitchColMLOT
static constexpr float PitchRowMLOT
static bool isValidDet(int row, int col, int subDetID, int layer) noexcept
static constexpr std::array< double, constants::VD::petal::nLayers > radiiVD
static float getWidthVD(int layer)
static void Print() noexcept
Print segmentation info.
static constexpr float PitchRowVD
constexpr SegmentationChip & operator=(const SegmentationChip &)=default
static void setNumberOfPetalsVD(int n)
static bool detectorToLocal(int iRow, int iCol, float &xRow, float &zCol, int subDetID, int layer, int disk) noexcept
constexpr SegmentationChip(const SegmentationChip &)=default
static constexpr float SiliconThicknessMLOT
static int getNRowsVD(int layer)
static math_utils::Vector2D< float > curvedToFlat(const int layer, const float xCurved, const float yCurved) noexcept
GLdouble n
Definition glcorearb.h:1982
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 thickness
Definition Specs.h:39
constexpr double totalThickness
Definition Specs.h:84
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row