Project
Loading...
Searching...
No Matches
Segmentation.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_IOTOF_SEGMENTATION_H
17#define ALICEO2_IOTOF_SEGMENTATION_H
18
19#include <Rtypes.h>
20#include <memory>
21#include "MathUtils/Cartesian.h"
23
24namespace o2
25{
26namespace iotof
27{
28
31{
32 private:
34 static std::unique_ptr<o2::iotof::Segmentation> sInstance;
35
36 public:
37 static Segmentation* Instance();
38
39 ~Segmentation() = default;
40
52 bool localToDetector(float x, float z, int& iRow, int& iCol, const int subDetectorID) const;
54 void localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol, const int subDetectorID) const;
55
66
67 // w/o check for row/col range
68 template <typename T = float, typename L = float>
69 void detectorToLocalUnchecked(L row, L col, T& xRow, T& zCol, const int subDetectorID) const
70 {
71 if (subDetectorID != 0 && subDetectorID != 1) {
72 row = col = -1;
73 return;
74 }
75 const auto& specsConfig = ChipSpecificsParam::Instance();
76 xRow = getFirstRowCoordinate(subDetectorID) - row * specsConfig.PitchRow;
77 zCol = col * specsConfig.PitchCol + getFirstColCoordinate(subDetectorID);
78 }
79 template <typename T = float, typename L = float>
80 void detectorToLocalUnchecked(L row, L col, math_utils::Point3D<T>& loc, const int subDetectorID) const
81 {
82 if (subDetectorID != 0 && subDetectorID != 1) {
83 row = col = -1;
84 return;
85 }
86 const auto& specsConfig = ChipSpecificsParam::Instance();
87 loc.SetCoordinates(getFirstRowCoordinate(subDetectorID) - row * specsConfig.PitchRow, T(0.), col * specsConfig.PitchCol + getFirstColCoordinate(subDetectorID));
88 }
89 template <typename T = float, typename L = float>
90 void detectorToLocalUnchecked(L row, L col, std::array<T, 3>& loc, const int subDetectorID) const
91 {
92 if (subDetectorID != 0 && subDetectorID != 1) {
93 row = col = -1;
94 return;
95 }
96 const auto& specsConfig = ChipSpecificsParam::Instance();
97 loc[0] = getFirstRowCoordinate(subDetectorID) - row * specsConfig.PitchRow;
98 loc[1] = T(0);
99 loc[2] = col * specsConfig.PitchCol + getFirstColCoordinate(subDetectorID);
100 }
101
102 // same but with check for row/col range
103
104 template <typename T = float, typename L = float>
105 bool detectorToLocal(L row, L col, T& xRow, T& zCol, const int subDetectorID) const
106 {
107 if (subDetectorID != 0 && subDetectorID != 1) {
108 row = col = -1;
109 return false;
110 }
111 const auto& specsConfig = ChipSpecificsParam::Instance();
112 if (row < 0 || row >= specsConfig.NRows || col < 0 || col >= specsConfig.NCols) {
113 return false;
114 }
115 detectorToLocalUnchecked(row, col, xRow, zCol, subDetectorID);
116 return true;
117 }
118
119 template <typename T = float, typename L = float>
120 bool detectorToLocal(L row, L col, math_utils::Point3D<T>& loc, const int subDetectorID) const
121 {
122 if (subDetectorID != 0 && subDetectorID != 1) {
123 row = col = -1;
124 return false;
125 }
126 const auto& specsConfig = ChipSpecificsParam::Instance();
127 if (row < 0 || row >= specsConfig.NRows || col < 0 || col >= specsConfig.NCols) {
128 return false;
129 }
130 detectorToLocalUnchecked(row, col, loc, subDetectorID);
131 return true;
132 }
133 template <typename T = float, typename L = float>
134 bool detectorToLocal(L row, L col, std::array<T, 3>& loc, const int subDetectorID) const
135 {
136 if (subDetectorID != 0 && subDetectorID != 1) {
137 row = col = -1;
138 return false;
139 }
140 const auto& specsConfig = ChipSpecificsParam::Instance();
141 if (row < 0 || row >= specsConfig.NRows || col < 0 || col >= specsConfig.NCols) {
142 return false;
143 }
144 detectorToLocalUnchecked(row, col, loc, subDetectorID);
145 return true;
146 }
147
148 float getFirstRowCoordinate(const int subDetectorID) const
149 {
150 const auto& specsConfig = ChipSpecificsParam::Instance();
151 return 0.5 * ((specsConfig.ActiveMatrixSizeRows() - specsConfig.PassiveEdgeTop + specsConfig.PassiveEdgeReadOut) - specsConfig.PitchRow);
152 }
153 float getFirstColCoordinate(const int subDetectorID) const
154 {
155 const auto& specsConfig = ChipSpecificsParam::Instance();
156 return 0.5 * (specsConfig.PitchCol - specsConfig.ActiveMatrixSizeCols());
157 }
158
159 ClassDefNV(Segmentation, 1); // Segmentation class upgrade pixels
160};
161
162//_________________________________________________________________________________________________
163inline void Segmentation::localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol, const int subDetectorID) const
164{
165 // convert to row/col w/o over/underflow check
166 if (subDetectorID != 0 && subDetectorID != 1) {
167 iRow = iCol = -1;
168 return;
169 }
170 const auto& specsConfig = ChipSpecificsParam::Instance();
171 xRow = 0.5 * (specsConfig.ActiveMatrixSizeRows() - specsConfig.PassiveEdgeTop + specsConfig.PassiveEdgeReadOut) - xRow; // coordinate wrt top edge of Active matrix
172 zCol += 0.5 * specsConfig.ActiveMatrixSizeCols(); // coordinate wrt left edge of Active matrix
173 iRow = int(xRow / specsConfig.PitchRow);
174 iCol = int(zCol / specsConfig.PitchCol);
175 // check pixel passive region
176 if (std::abs(xRow - (iRow + 0.5) * specsConfig.PitchRow) > (0.5 * specsConfig.PitchRow - specsConfig.PixelPassiveEdgeX) || std::abs(zCol - (iCol + 0.5) * specsConfig.PitchCol) > (0.5 * specsConfig.PitchCol - specsConfig.PixelPassiveEdgeZ)) {
177 iRow = iCol = -1;
178 return;
179 }
180 if (xRow < 0) {
181 iRow -= 1;
182 }
183 if (zCol < 0) {
184 iCol -= 1;
185 }
186}
187
188//_________________________________________________________________________________________________
189inline bool Segmentation::localToDetector(float xRow, float zCol, int& iRow, int& iCol, const int subDetectorID) const
190{
191 // convert to row/col
192 if (subDetectorID != 0 && subDetectorID != 1) {
193 iRow = iCol = -1;
194 return false;
195 }
196 const auto& specsConfig = ChipSpecificsParam::Instance();
197 xRow = 0.5 * (specsConfig.ActiveMatrixSizeRows() - specsConfig.PassiveEdgeTop + specsConfig.PassiveEdgeReadOut) - xRow; // coordinate wrt top edge of Active matrix
198 zCol += 0.5 * specsConfig.ActiveMatrixSizeCols(); // coordinate wrt left edge of Active matrix
199 if (xRow < 0 || xRow >= specsConfig.ActiveMatrixSizeRows() || zCol < 0 || zCol >= specsConfig.ActiveMatrixSizeCols()) {
200 iRow = iCol = -1;
201 return false;
202 }
203 iRow = int(xRow / specsConfig.PitchRow);
204 iCol = int(zCol / specsConfig.PitchCol);
205 // check pixel passive region
206 // if (specsConfig.PixelPassiveEdgeX > 1e-6 && specsConfig.PixelPassiveEdgeZ > 1e-6) {
207 if (std::abs(xRow - (iRow + 0.5) * specsConfig.PitchRow) > (0.5 * specsConfig.PitchRow - specsConfig.PixelPassiveEdgeX) || std::abs(zCol - (iCol + 0.5) * specsConfig.PitchCol) > (0.5 * specsConfig.PitchCol - specsConfig.PixelPassiveEdgeZ)) {
208 iRow = iCol = -1;
209 return false;
210 }
211 // }
212 return true;
213}
214
215} // namespace iotof
216} // namespace o2
217
218#endif
uint32_t col
Definition RawData.h:4
Segmentation and response for pixels in inner and outer TOF of the ALICE 3 apparatus.
void localToDetectorUnchecked(float xRow, float zCol, int &iRow, int &iCol, const int subDetectorID) const
same but w/o check for row/column range
void detectorToLocalUnchecked(L row, L col, std::array< T, 3 > &loc, const int subDetectorID) const
void detectorToLocalUnchecked(L row, L col, T &xRow, T &zCol, const int subDetectorID) const
bool detectorToLocal(L row, L col, T &xRow, T &zCol, const int subDetectorID) const
float getFirstColCoordinate(const int subDetectorID) const
void detectorToLocalUnchecked(L row, L col, math_utils::Point3D< T > &loc, const int subDetectorID) const
bool detectorToLocal(L row, L col, math_utils::Point3D< T > &loc, const int subDetectorID) const
float getFirstRowCoordinate(const int subDetectorID) const
static Segmentation * Instance()
bool detectorToLocal(L row, L col, std::array< T, 3 > &loc, const int subDetectorID) const
bool localToDetector(float x, float z, int &iRow, int &iCol, const int subDetectorID) const
ClassDefNV(Segmentation, 1)
static bool localToDetector(float x, float z, int &iRow, int &iCol)
static void localToDetectorUnchecked(float xRow, float zCol, int &iRow, int &iCol)
same but w/o check for row/column range
GLint GLenum GLint x
Definition glcorearb.h:403
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< int > row