forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexTableUtils.h
More file actions
108 lines (94 loc) · 3.69 KB
/
IndexTableUtils.h
File metadata and controls
108 lines (94 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file IndexTableUtils.h
/// \brief
///
#ifndef TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_
#define TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_
#include "ITStracking/Configuration.h"
#include "ITStracking/Definitions.h"
#include "CommonConstants/MathConstants.h"
#include "GPUCommonMath.h"
#include "GPUCommonDef.h"
namespace o2
{
namespace its
{
class IndexTableUtils
{
public:
template <class T>
void setTrackingParameters(const T& params);
float getInverseZCoordinate(const int layerIndex) const;
GPUhdi() int getZBinIndex(const int, const float) const;
GPUhdi() int getPhiBinIndex(const float) const;
GPUhdi() int getBinIndex(const int, const int) const;
GPUhdi() int countRowSelectedBins(const int*, const int, const int, const int) const;
GPUhdi() void print() const;
GPUhdi() int getNzBins() const { return mNzBins; }
GPUhdi() int getNphiBins() const { return mNphiBins; }
GPUhdi() float getLayerZ(int i) const { return mLayerZ[i]; }
GPUhdi() void setNzBins(const int zBins) { mNzBins = zBins; }
GPUhdi() void setNphiBins(const int phiBins) { mNphiBins = phiBins; }
private:
int mNzBins = 0;
int mNphiBins = 0;
float mInversePhiBinSize = 0.f;
float mLayerZ[8] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
float mInverseZBinSize[8] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
};
template <class T>
inline void IndexTableUtils::setTrackingParameters(const T& params)
{
mInversePhiBinSize = params.PhiBins / o2::constants::math::TwoPI;
mNzBins = params.ZBins;
mNphiBins = params.PhiBins;
for (int iLayer{0}; iLayer < params.LayerZ.size(); ++iLayer) {
mLayerZ[iLayer] = params.LayerZ[iLayer];
}
for (unsigned int iLayer{0}; iLayer < params.LayerZ.size(); ++iLayer) {
mInverseZBinSize[iLayer] = 0.5f * params.ZBins / params.LayerZ[iLayer];
}
}
inline float IndexTableUtils::getInverseZCoordinate(const int layerIndex) const
{
return 0.5f * mNzBins / mLayerZ[layerIndex];
}
GPUhdi() int IndexTableUtils::getZBinIndex(const int layerIndex, const float zCoordinate) const
{
return (zCoordinate + mLayerZ[layerIndex]) * mInverseZBinSize[layerIndex];
}
GPUhdi() int IndexTableUtils::getPhiBinIndex(const float currentPhi) const
{
return (currentPhi * mInversePhiBinSize);
}
GPUhdi() int IndexTableUtils::getBinIndex(const int zIndex, const int phiIndex) const
{
return o2::gpu::GPUCommonMath::Min(phiIndex * mNzBins + zIndex, mNzBins * mNphiBins - 1);
}
GPUhdi() int IndexTableUtils::countRowSelectedBins(const int* indexTable, const int phiBinIndex,
const int minZBinIndex, const int maxZBinIndex) const
{
const int firstBinIndex{getBinIndex(minZBinIndex, phiBinIndex)};
const int maxBinIndex{firstBinIndex + maxZBinIndex - minZBinIndex + 1};
return indexTable[maxBinIndex] - indexTable[firstBinIndex];
}
GPUhdi() void IndexTableUtils::print() const
{
printf("NzBins: %d, NphiBins: %d, InversePhiBinSize: %f\n", mNzBins, mNphiBins, mInversePhiBinSize);
for (int iLayer{0}; iLayer < 7; ++iLayer) {
printf("Layer %d: Z: %f, InverseZBinSize: %f\n", iLayer, mLayerZ[iLayer], mInverseZBinSize[iLayer]);
}
}
} // namespace its
} // namespace o2
#endif /* TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_ */