Project
Loading...
Searching...
No Matches
IndexTableUtils.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.
15
16#ifndef TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_
17#define TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_
18
22#include "GPUCommonMath.h"
23#include "GPUCommonDef.h"
24
25namespace o2
26{
27namespace its
28{
30{
31 public:
32 template <class T>
33 void setTrackingParameters(const T& params);
34 float getInverseZCoordinate(const int layerIndex) const;
35 GPUhdi() int getZBinIndex(const int, const float) const;
36 GPUhdi() int getPhiBinIndex(const float) const;
37 GPUhdi() int getBinIndex(const int, const int) const;
38 GPUhdi() int countRowSelectedBins(const int*, const int, const int, const int) const;
39 GPUhdi() void print() const;
40
41 GPUhdi() int getNzBins() const { return mNzBins; }
42 GPUhdi() int getNphiBins() const { return mNphiBins; }
43 GPUhdi() float getLayerZ(int i) const { return mLayerZ[i]; }
44 GPUhdi() void setNzBins(const int zBins) { mNzBins = zBins; }
45 GPUhdi() void setNphiBins(const int phiBins) { mNphiBins = phiBins; }
46
47 private:
48 int mNzBins = 0;
49 int mNphiBins = 0;
50 float mInversePhiBinSize = 0.f;
51 float mLayerZ[8] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
52 float mInverseZBinSize[8] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
53};
54
55template <class T>
57{
58 mInversePhiBinSize = params.PhiBins / constants::math::TwoPi;
59 mNzBins = params.ZBins;
60 mNphiBins = params.PhiBins;
61 for (int iLayer{0}; iLayer < params.LayerZ.size(); ++iLayer) {
62 mLayerZ[iLayer] = params.LayerZ[iLayer];
63 }
64 for (unsigned int iLayer{0}; iLayer < params.LayerZ.size(); ++iLayer) {
65 mInverseZBinSize[iLayer] = 0.5f * params.ZBins / params.LayerZ[iLayer];
66 }
67}
68
69inline float IndexTableUtils::getInverseZCoordinate(const int layerIndex) const
70{
71 return 0.5f * mNzBins / mLayerZ[layerIndex];
72}
73
74GPUhdi() int IndexTableUtils::getZBinIndex(const int layerIndex, const float zCoordinate) const
75{
76 return (zCoordinate + mLayerZ[layerIndex]) * mInverseZBinSize[layerIndex];
77}
78
79GPUhdi() int IndexTableUtils::getPhiBinIndex(const float currentPhi) const
80{
81 return (currentPhi * mInversePhiBinSize);
82}
83
84GPUhdi() int IndexTableUtils::getBinIndex(const int zIndex, const int phiIndex) const
85{
86 return o2::gpu::GPUCommonMath::Min(phiIndex * mNzBins + zIndex, mNzBins * mNphiBins - 1);
87}
88
89GPUhdi() int IndexTableUtils::countRowSelectedBins(const int* indexTable, const int phiBinIndex,
90 const int minZBinIndex, const int maxZBinIndex) const
91{
92 const int firstBinIndex{getBinIndex(minZBinIndex, phiBinIndex)};
93 const int maxBinIndex{firstBinIndex + maxZBinIndex - minZBinIndex + 1};
94
95 return indexTable[maxBinIndex] - indexTable[firstBinIndex];
96}
97
98GPUhdi() void IndexTableUtils::print() const
99{
100 printf("NzBins: %d, NphiBins: %d, InversePhiBinSize: %f\n", mNzBins, mNphiBins, mInversePhiBinSize);
101 for (int iLayer{0}; iLayer < 7; ++iLayer) {
102 printf("Layer %d: Z: %f, InverseZBinSize: %f\n", iLayer, mLayerZ[iLayer], mInverseZBinSize[iLayer]);
103 }
104}
105} // namespace its
106} // namespace o2
107
108#endif /* TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_ */
void print() const
int32_t i
GPUhdi() void setNphiBins(const int phiBins)
GPUhdi() float getLayerZ(int i) const
GPUhdi() int getZBinIndex(const int
void setTrackingParameters(const T &params)
float getInverseZCoordinate(const int layerIndex) const
GPUhdi() int getNphiBins() const
GPUhdi() void setNzBins(const int zBins)
GLenum const GLfloat * params
Definition glcorearb.h:272
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
constexpr float TwoPi
Definition Constants.h:44
GPUhdi() Cell
Definition Cell.h:55
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...