Project
Loading...
Searching...
No Matches
PadRegionInfo.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
16
26
27#ifndef AliceO2_TPC_PadRegionInfo_H
28#define AliceO2_TPC_PadRegionInfo_H
29
30#include <vector>
31
32#include "DataFormatsTPC/Defs.h"
33#include "TPCBase/PadPos.h"
34
35namespace o2
36{
37namespace tpc
38{
39
41{
42 public:
44 PadRegionInfo() = default;
45
56 PadRegionInfo(const unsigned char region,
57 const unsigned char partition,
58 const unsigned char numberOfPadRows,
59 const float padHeight,
60 const float padWidth,
61 const float radiusFirstRow,
62 const unsigned char rowOffset,
63 const float xhelper,
64 const unsigned char globalRowOffset);
65
68 unsigned char getRegion() const { return mRegion; }
69
72 unsigned char getPartition() const { return mPartition; }
73
76 unsigned char getNumberOfPadRows() const { return mNumberOfPadRows; }
77
80 unsigned short getNumberOfPads() const { return mNumberOfPads; }
81
84 float getPadHeight() const { return mPadHeight; }
85
88 float getPadWidth() const { return mPadWidth; }
89
92 float getRadiusFirstRow() const { return mRadiusFirstRow; }
93
96 unsigned char getGlobalRowOffset() const { return mGlobalRowOffset; }
97
99 unsigned char getRowOffset() const { return mRowOffset; }
100
102 float getXhelper() const { return mXhelper; }
103
107 unsigned char getPadsInRow(const PadPos& padPos) const
108 {
109 return mPadsPerRow[padPos.getRow() - mGlobalRowOffset];
110 }
111
115 unsigned char getPadsInRow(const int row) const { return mPadsPerRow[row - mGlobalRowOffset]; }
116
120 unsigned char getPadsInRowRegion(const int row) const { return mPadsPerRow[row]; }
121
127 bool isInRegion(float localX, float border = 0.f) const
128 {
129 return localX - mRadiusFirstRow - border > 0.f && localX - mRadiusFirstRow < (mNumberOfPadRows + 1) * mPadHeight + border;
130 }
131
132#ifndef GPUCA_ALIGPUCODE // LocalPosition.. = ROOT:Cartesian.. is not available on the GPU
136 const PadPos findPad(const LocalPosition3D& pos) const
137 {
138 return findPad(pos.X(), pos.Y(), (pos.Z() >= 0) ? Side::A : Side::C);
139 }
140
145 const PadPos findPad(const LocalPosition2D& pos, const Side side = Side::A) const
146 {
147 return findPad(pos.X(), pos.Y(), side);
148 }
149#endif
150
156 const PadPos findPad(const float localX, const float localY, const Side side /*=Side::A*/) const
157 {
158 if (!isInRegion(localX)) {
159 return PadPos(255, 255);
160 }
161
162 // the pad coordinate system is for pad-side view.
163 // on the A-Side one looks from the back-side, therefore
164 // the localY-sign must be changed
165 const float localYfactor = (side == Side::A) ? -1.f : 1.f;
166 const unsigned int row = (localX - mRadiusFirstRow) * mInvPadHeight;
167 if (row >= mNumberOfPadRows) {
168 return PadPos(255, 255);
169 }
170
171 const unsigned int npads = getPadsInRowRegion(row);
172 const float padfloat = (0.5f * npads * mPadWidth - localYfactor * localY) * mInvPadWidth;
173 if (padfloat < 0) {
174 return PadPos(255, 255);
175 }
176 const unsigned int pad = static_cast<unsigned int>(padfloat);
177
178 if (pad >= npads) {
179 return PadPos(255, 255);
180 }
181
182 return PadPos(row, pad);
183 }
184
185 private:
186 float mPadHeight{0.f};
187 float mPadWidth{0.f};
188 float mInvPadHeight{0.f};
189 float mInvPadWidth{0.f};
190 float mRadiusFirstRow{0.f};
191 float mXhelper{0.f};
192 unsigned short mNumberOfPads{0};
193 unsigned char mPartition{0};
194 unsigned char mRegion{0};
195 unsigned char mNumberOfPadRows{0};
196
197 unsigned char mRowOffset{0};
198
199 unsigned char mGlobalRowOffset{0};
200
201 void init();
202
203 std::vector<unsigned char> mPadsPerRow;
204};
205
206} // namespace tpc
207} // namespace o2
208#endif
uint16_t pos
Definition RawData.h:3
uint32_t side
Definition RawData.h:0
PadRegionInfo()=default
default constructor
const PadPos findPad(const float localX, const float localY, const Side side) const
unsigned char getPadsInRow(const PadPos &padPos) const
unsigned char getPadsInRow(const int row) const
unsigned char getNumberOfPadRows() const
float getRadiusFirstRow() const
unsigned short getNumberOfPads() const
const PadPos findPad(const LocalPosition3D &pos) const
bool isInRegion(float localX, float border=0.f) const
unsigned char getPadsInRowRegion(const int row) const
float getXhelper() const
Helper variable for geometry calculations.
unsigned char getGlobalRowOffset() const
unsigned char getRegion() const
const PadPos findPad(const LocalPosition2D &pos, const Side side=Side::A) const
float getPadWidth() const
unsigned char getRowOffset() const
Local row offset for geometry calculations.
unsigned char getPartition() const
float getPadHeight() const
GLint GLint GLsizei GLint border
Definition glcorearb.h:275
Side
TPC readout sidE.
Definition Defs.h:35
@ A
Definition Defs.h:35
@ C
Definition Defs.h:36
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< int > row