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
32{
33 private:
35 static std::unique_ptr<o2::iotof::Segmentation> sInstance;
36
37 public:
40 static Segmentation* Instance();
41
42 ~Segmentation() = default;
43
44 void configChip(const int nCols, const int nRows, const float pitchCol, const float pitchRow, const float passiveEdgeReadOut, const float passiveEdgeTop,
45 const float passiveEdgeSide, const float PixelPassiveEdgeX, const float PixelPassiveEdgeZ, const float sensorLayerThicknessEff, const float sensorLayerThickness, const int subDetectorID);
46 void configChip(const ChipSpecifics& specsConfig, const int subDetectorID);
47
59 bool localToDetector(float x, float z, int& iRow, int& iCol, const int subDetectorID);
61 void localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol, const int subDetectorID);
62
73
74 // w/o check for row/col range
75 template <typename T = float, typename L = float>
76 void detectorToLocalUnchecked(L row, L col, T& xRow, T& zCol, const int subDetectorID)
77 {
78 if (subDetectorID != 0 && subDetectorID != 1) {
79 row = col = -1;
80 return;
81 }
82 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
83 xRow = getFirstRowCoordinate(subDetectorID) - row * specsConfig.PitchRow;
84 zCol = col * specsConfig.PitchCol + getFirstColCoordinate(subDetectorID);
85 }
86 template <typename T = float, typename L = float>
87 void detectorToLocalUnchecked(L row, L col, math_utils::Point3D<T>& loc, const int subDetectorID)
88 {
89 if (subDetectorID != 0 && subDetectorID != 1) {
90 row = col = -1;
91 return;
92 }
93 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
94 loc.SetCoordinates(getFirstRowCoordinate(subDetectorID) - row * specsConfig.PitchRow, T(0.), col * specsConfig.PitchCol + getFirstColCoordinate(subDetectorID));
95 }
96 template <typename T = float, typename L = float>
97 void detectorToLocalUnchecked(L row, L col, std::array<T, 3>& loc, const int subDetectorID)
98 {
99 if (subDetectorID != 0 && subDetectorID != 1) {
100 row = col = -1;
101 return;
102 }
103 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
104 loc[0] = getFirstRowCoordinate(subDetectorID) - row * specsConfig.PitchRow;
105 loc[1] = T(0);
106 loc[2] = col * specsConfig.PitchCol + getFirstColCoordinate(subDetectorID);
107 }
108
109 // same but with check for row/col range
110
111 template <typename T = float, typename L = float>
112 bool detectorToLocal(L row, L col, T& xRow, T& zCol, const int subDetectorID)
113 {
114 if (subDetectorID != 0 && subDetectorID != 1) {
115 row = col = -1;
116 return false;
117 }
118 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
119 if (row < 0 || row >= specsConfig.NRows || col < 0 || col >= specsConfig.NCols) {
120 return false;
121 }
122 detectorToLocalUnchecked(row, col, xRow, zCol, subDetectorID);
123 return true;
124 }
125
126 template <typename T = float, typename L = float>
127 bool detectorToLocal(L row, L col, math_utils::Point3D<T>& loc, const int subDetectorID)
128 {
129 if (subDetectorID != 0 && subDetectorID != 1) {
130 row = col = -1;
131 return false;
132 }
133 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
134 if (row < 0 || row >= specsConfig.NRows || col < 0 || col >= specsConfig.NCols) {
135 return false;
136 }
137 detectorToLocalUnchecked(row, col, loc, subDetectorID);
138 return true;
139 }
140 template <typename T = float, typename L = float>
141 bool detectorToLocal(L row, L col, std::array<T, 3>& loc, const int subDetectorID)
142 {
143 if (subDetectorID != 0 && subDetectorID != 1) {
144 row = col = -1;
145 return false;
146 }
147 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
148 if (row < 0 || row >= specsConfig.NRows || col < 0 || col >= specsConfig.NCols) {
149 return false;
150 }
151 detectorToLocalUnchecked(row, col, loc, subDetectorID);
152 return true;
153 }
154
155 float getFirstRowCoordinate(const int subDetectorID)
156 {
157 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
158 return 0.5 * ((specsConfig.ActiveMatrixSizeRows() - specsConfig.PassiveEdgeTop + specsConfig.PassiveEdgeReadOut) - specsConfig.PitchRow);
159 }
160 float getFirstColCoordinate(const int subDetectorID)
161 {
162 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
163 return 0.5 * (specsConfig.PitchCol - specsConfig.ActiveMatrixSizeCols());
164 }
165
166 void print();
167
168 ClassDefNV(Segmentation, 1); // Segmentation class upgrade pixels
169};
170
171//_________________________________________________________________________________________________
172inline void Segmentation::localToDetectorUnchecked(float xRow, float zCol, int& iRow, int& iCol, const int subDetectorID)
173{
174 // convert to row/col w/o over/underflow check
175 if (subDetectorID != 0 && subDetectorID != 1) {
176 iRow = iCol = -1;
177 return;
178 }
179 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
180 xRow = 0.5 * (specsConfig.ActiveMatrixSizeRows() - specsConfig.PassiveEdgeTop + specsConfig.PassiveEdgeReadOut) - xRow; // coordinate wrt top edge of Active matrix
181 zCol += 0.5 * specsConfig.ActiveMatrixSizeCols(); // coordinate wrt left edge of Active matrix
182 iRow = int(xRow / specsConfig.PitchRow);
183 iCol = int(zCol / specsConfig.PitchCol);
184 // check pixel passive region
185 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)) {
186 iRow = iCol = -1;
187 return;
188 }
189 if (xRow < 0) {
190 iRow -= 1;
191 }
192 if (zCol < 0) {
193 iCol -= 1;
194 }
195}
196
197//_________________________________________________________________________________________________
198inline bool Segmentation::localToDetector(float xRow, float zCol, int& iRow, int& iCol, const int subDetectorID)
199{
200 // convert to row/col
201 if (subDetectorID != 0 && subDetectorID != 1) {
202 iRow = iCol = -1;
203 return false;
204 }
205 const ChipSpecifics& specsConfig = (subDetectorID == 0) ? mITofSpecsConfig : mOTofSpecsConfig;
206 xRow = 0.5 * (specsConfig.ActiveMatrixSizeRows() - specsConfig.PassiveEdgeTop + specsConfig.PassiveEdgeReadOut) - xRow; // coordinate wrt top edge of Active matrix
207 zCol += 0.5 * specsConfig.ActiveMatrixSizeCols(); // coordinate wrt left edge of Active matrix
208 if (xRow < 0 || xRow >= specsConfig.ActiveMatrixSizeRows() || zCol < 0 || zCol >= specsConfig.ActiveMatrixSizeCols()) {
209 iRow = iCol = -1;
210 return false;
211 }
212 iRow = int(xRow / specsConfig.PitchRow);
213 iCol = int(zCol / specsConfig.PitchCol);
214 // check pixel passive region
215 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)) {
216 iRow = iCol = -1;
217 return false;
218 }
219 return true;
220}
221
222} // namespace iotof
223} // namespace o2
224
225#endif
uint32_t col
Definition RawData.h:4
float getFirstColCoordinate(const int subDetectorID)
bool detectorToLocal(L row, L col, std::array< T, 3 > &loc, const int subDetectorID)
ChipSpecifics mOTofSpecsConfig
float getFirstRowCoordinate(const int subDetectorID)
void localToDetectorUnchecked(float xRow, float zCol, int &iRow, int &iCol, const int subDetectorID)
same but w/o check for row/column range
void detectorToLocalUnchecked(L row, L col, T &xRow, T &zCol, const int subDetectorID)
static Segmentation * Instance()
void configChip(const int nCols, const int nRows, const float pitchCol, const float pitchRow, const float passiveEdgeReadOut, const float passiveEdgeTop, const float passiveEdgeSide, const float PixelPassiveEdgeX, const float PixelPassiveEdgeZ, const float sensorLayerThicknessEff, const float sensorLayerThickness, const int subDetectorID)
ChipSpecifics mITofSpecsConfig
void detectorToLocalUnchecked(L row, L col, math_utils::Point3D< T > &loc, const int subDetectorID)
void detectorToLocalUnchecked(L row, L col, std::array< T, 3 > &loc, const int subDetectorID)
bool detectorToLocal(L row, L col, math_utils::Point3D< T > &loc, const int subDetectorID)
bool detectorToLocal(L row, L col, T &xRow, T &zCol, const int subDetectorID)
bool localToDetector(float x, float z, int &iRow, int &iCol, const int subDetectorID)
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 ...
float ActiveMatrixSizeRows() const
float ActiveMatrixSizeCols() const
std::vector< int > row