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
19#include <array>
20
25#include "GPUCommonMath.h"
26#include "GPUCommonDef.h"
27
28namespace o2::its
29{
30
31template <int nLayers>
33{
34 public:
35 template <class T>
37 float getInverseZCoordinate(const int layerIndex) const;
38 GPUhdi() int getZBinIndex(const int, const float) const;
39 GPUhdi() int getPhiBinIndex(const float) const;
40 GPUhdi() int getBinIndex(const int, const int) const;
41 GPUhdi() int countRowSelectedBins(const int*, const int, const int, const int) const;
42 GPUhdi() void print() const;
43
44 GPUhdi() int getNzBins() const { return mNzBins; }
45 GPUhdi() int getNphiBins() const { return mNphiBins; }
46 GPUhdi() float getLayerZ(int i) const { return mLayerZ[i]; }
47 GPUhdi() void setNzBins(const int zBins) { mNzBins = zBins; }
48 GPUhdi() void setNphiBins(const int phiBins) { mNphiBins = phiBins; }
49
50 private:
51 int mNzBins = 0;
52 int mNphiBins = 0;
53 float mInversePhiBinSize = 0.f;
54 std::array<float, nLayers> mLayerZ{};
55 std::array<float, nLayers> mInverseZBinSize{};
56};
57
58template <int nLayers>
59template <class T>
61{
62 mInversePhiBinSize = params.PhiBins / o2::constants::math::TwoPI;
63 mNzBins = params.ZBins;
64 mNphiBins = params.PhiBins;
65 for (int iLayer{0}; iLayer < params.LayerZ.size(); ++iLayer) {
66 mLayerZ[iLayer] = params.LayerZ[iLayer];
67 }
68 for (unsigned int iLayer{0}; iLayer < params.LayerZ.size(); ++iLayer) {
69 mInverseZBinSize[iLayer] = 0.5f * params.ZBins / params.LayerZ[iLayer];
70 }
71}
72
73template <int nLayers>
74inline float IndexTableUtils<nLayers>::getInverseZCoordinate(const int layerIndex) const
75{
76 return 0.5f * mNzBins / mLayerZ[layerIndex];
77}
78
79template <int nLayers>
80GPUhdi() int IndexTableUtils<nLayers>::getZBinIndex(const int layerIndex, const float zCoordinate) const
81{
82 return (zCoordinate + mLayerZ[layerIndex]) * mInverseZBinSize[layerIndex];
83}
84
85template <int nLayers>
86GPUhdi() int IndexTableUtils<nLayers>::getPhiBinIndex(const float currentPhi) const
87{
88 return (currentPhi * mInversePhiBinSize);
89}
90
91template <int nLayers>
92GPUhdi() int IndexTableUtils<nLayers>::getBinIndex(const int zIndex, const int phiIndex) const
93{
94 return o2::gpu::GPUCommonMath::Min(phiIndex * mNzBins + zIndex, mNzBins * mNphiBins - 1);
95}
96
97template <int nLayers>
98GPUhdi() int IndexTableUtils<nLayers>::countRowSelectedBins(const int* indexTable, const int phiBinIndex,
99 const int minZBinIndex, const int maxZBinIndex) const
100{
101 const int firstBinIndex{getBinIndex(minZBinIndex, phiBinIndex)};
102 const int maxBinIndex{firstBinIndex + maxZBinIndex - minZBinIndex + 1};
103
104 return indexTable[maxBinIndex] - indexTable[firstBinIndex];
105}
106
107template <int nLayers>
108GPUhdi() void IndexTableUtils<nLayers>::print() const
109{
110 printf("NzBins: %d, NphiBins: %d, InversePhiBinSize: %f\n", mNzBins, mNphiBins, mInversePhiBinSize);
111 for (int iLayer{0}; iLayer < nLayers; ++iLayer) {
112 printf("Layer %d: Z: %f, InverseZBinSize: %f\n", iLayer, mLayerZ[iLayer], mInverseZBinSize[iLayer]);
113 }
114}
115
116} // namespace o2::its
117#endif /* TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_ */
void print() const
int32_t i
useful math constants
GPUhdi() int getNphiBins() const
GPUhdi() int getZBinIndex(const int
void setTrackingParameters(const T &params)
GPUhdi() float getLayerZ(int i) const
GPUhdi() void setNphiBins(const int phiBins)
float getInverseZCoordinate(const int layerIndex) const
GPUhdi() void setNzBins(const int zBins)
GLenum const GLfloat * params
Definition glcorearb.h:272
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
constexpr float TwoPI
GPUhdi() Line
constexpr int nLayers
Definition Specs.h:45