-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathGPUTPCGeometry.h
More file actions
186 lines (161 loc) · 17 KB
/
GPUTPCGeometry.h
File metadata and controls
186 lines (161 loc) · 17 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// 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 GPUTPCGeometry.h
/// \author David Rohr, Jens Wiechula, Sergey Gorbunov
#ifndef GPUTPCGEOMETRY_H
#define GPUTPCGEOMETRY_H
#include "GPUCommonDef.h"
#include "GPUCommonMath.h"
#include "DataFormatsTPC/Constants.h"
#ifndef GPUCA_GPUCODE_DEVICE
#include <cmath>
#endif
namespace o2::gpu
{
// Copy of TPC constants from AliRoot:TPCGeometry / O2:TPC/Base/Mapper, cannot take the contants from the official headers for now, since we want it to be const / constexpr
namespace gputpcgeometry_internal
{
#ifndef GPUCA_RUN2 // clang-format off
constexpr uint32_t NREGIONS = 10;
GPUconstexpr() float mX[o2::tpc::constants::MAXGLOBALPADROW] = {85.225f, 85.975f, 86.725f, 87.475f, 88.225f, 88.975f, 89.725f, 90.475f, 91.225f, 91.975f, 92.725f, 93.475f, 94.225f, 94.975f, 95.725f, 96.475f, 97.225f, 97.975f, 98.725f, 99.475f, 100.225f, 100.975f,
101.725f, 102.475f, 103.225f, 103.975f, 104.725f, 105.475f, 106.225f, 106.975f, 107.725f, 108.475f, 109.225f, 109.975f, 110.725f, 111.475f, 112.225f, 112.975f, 113.725f, 114.475f, 115.225f, 115.975f, 116.725f, 117.475f,
118.225f, 118.975f, 119.725f, 120.475f, 121.225f, 121.975f, 122.725f, 123.475f, 124.225f, 124.975f, 125.725f, 126.475f, 127.225f, 127.975f, 128.725f, 129.475f, 130.225f, 130.975f, 131.725f, 135.2f, 136.2f, 137.2f,
138.2f, 139.2f, 140.2f, 141.2f, 142.2f, 143.2f, 144.2f, 145.2f, 146.2f, 147.2f, 148.2f, 149.2f, 150.2f, 151.2f, 152.2f, 153.2f, 154.2f, 155.2f, 156.2f, 157.2f, 158.2f, 159.2f,
160.2f, 161.2f, 162.2f, 163.2f, 164.2f, 165.2f, 166.2f, 167.2f, 168.2f, 171.4f, 172.6f, 173.8f, 175.f, 176.2f, 177.4f, 178.6f, 179.8f, 181.f, 182.2f, 183.4f, 184.6f, 185.8f,
187.f, 188.2f, 189.4f, 190.6f, 191.8f, 193.f, 194.2f, 195.4f, 196.6f, 197.8f, 199.f, 200.2f, 201.4f, 202.6f, 203.8f, 205.f, 206.2f, 209.65f, 211.15f, 212.65f, 214.15f, 215.65f,
217.15f, 218.65f, 220.15f, 221.65f, 223.15f, 224.65f, 226.15f, 227.65f, 229.15f, 230.65f, 232.15f, 233.65f, 235.15f, 236.65f, 238.15f, 239.65f, 241.15f, 242.65f, 244.15f, 245.65f};
GPUconstexpr() uint8_t mNPads[o2::tpc::constants::MAXGLOBALPADROW] = {66, 66, 66, 68, 68, 68, 70, 70, 70, 72, 72, 72, 74, 74, 74, 74, 76, 76, 76, 76, 78, 78, 78, 80, 80, 80, 82, 82, 82, 84, 84, 84, 86, 86, 86, 88, 88, 88,
90, 90, 90, 90, 92, 92, 92, 94, 94, 94, 92, 92, 92, 94, 94, 94, 96, 96, 96, 98, 98, 98, 100, 100, 100, 76, 76, 76, 76, 78, 78, 78, 80, 80, 80, 80, 82, 82,
82, 84, 84, 84, 84, 86, 86, 86, 88, 88, 88, 90, 90, 90, 90, 92, 92, 92, 94, 94, 94, 94, 96, 96, 96, 98, 98, 98, 100, 100, 102, 102, 102, 104, 104, 104, 106, 110,
110, 112, 112, 112, 114, 114, 114, 116, 116, 116, 118, 118, 118, 118, 118, 120, 120, 122, 122, 124, 124, 124, 126, 126, 128, 128, 128, 130, 130, 132, 132, 132, 134, 134, 136, 136, 138, 138};
GPUconstexpr() uint8_t mRegion[o2::tpc::constants::MAXGLOBALPADROW] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9};
GPUconstexpr() uint8_t mRegionRows[NREGIONS] = {17, 15, 16, 15, 18, 16, 16, 14, 13, 12};
GPUconstexpr() uint8_t mRegionStart[NREGIONS] = {0, 17, 32, 48, 63, 81, 97, 113, 127, 140};
GPUconstexpr() uint8_t mSampaMapping[NREGIONS] = {0, 0, 1, 1, 2, 3, 3, 4, 4, 2};
GPUconstexpr() uint8_t mChannelOffset[NREGIONS] = {0, 16, 0, 16, 0, 0, 16, 0, 16, 16};
GPUconstexpr() uint8_t mSectorFECOffset[5] = {0, 15, 15 + 18, 15 + 18 + 18, 15 + 18 + 18 + 20};
GPUconstexpr() float mPadHeight[NREGIONS] = {.75f, .75f, .75f, .75f, 1.f, 1.f, 1.2f, 1.2f, 1.5f, 1.5f};
GPUconstexpr() float mPadWidth[NREGIONS] = {.416f, .420f, .420f, .436f, .6f, .6f, .608f, .588f, .604f, .607f};
GPUconstexpr() float mPadWidthRow[o2::tpc::constants::MAXGLOBALPADROW] = {.416, .416, .416, .416, .416, .416, .416, .416, .416, .416, .416, .416, .416, .416, .416, .416, .416,
.420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420,
.420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420, .420,
.436, .436, .436, .436, .436, .436, .436, .436, .436, .436, .436, .436, .436, .436, .436,
.600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600,
.600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600, .600,
.608, .608, .608, .608, .608, .608, .608, .608, .608, .608, .608, .608, .608, .608, .608, .608,
.588, .588, .588, .588, .588, .588, .588, .588, .588, .588, .588, .588, .588, .588,
.604, .604, .604, .604, .604, .604, .604, .604, .604, .604, .604, .604, .604,
.607, .607, .607, .607, .607, .607, .607, .607, .607, .607, .607, .607};
constexpr float TPC_LENGTH = 250.f;
constexpr float FACTOR_T2Z = 250.f / 512.f; // Used in compression, must remain constant at 250cm, 512 time bins!
#else
constexpr uint32_t NREGIONS = 3;
GPUconstexpr() float mX[o2::tpc::constants::MAXGLOBALPADROW] = {85.195f, 85.945f, 86.695f, 87.445f, 88.195f, 88.945f, 89.695f, 90.445f, 91.195f, 91.945f, 92.695f, 93.445f, 94.195f, 94.945f, 95.695f, 96.445f, 97.195f, 97.945f, 98.695f, 99.445f, 100.195f, 100.945f, 101.695f,
102.445f, 103.195f, 103.945f, 104.695f, 105.445f, 106.195f, 106.945f, 107.695f, 108.445f, 109.195f, 109.945f, 110.695f, 111.445f, 112.195f, 112.945f, 113.695f, 114.445f, 115.195f, 115.945f, 116.695f, 117.445f, 118.195f, 118.945f,
119.695f, 120.445f, 121.195f, 121.945f, 122.695f, 123.445f, 124.195f, 124.945f, 125.695f, 126.445f, 127.195f, 127.945f, 128.695f, 129.445f, 130.195f, 130.945f, 131.695f, 135.180f, 136.180f, 137.180f, 138.180f, 139.180f, 140.180f,
141.180f, 142.180f, 143.180f, 144.180f, 145.180f, 146.180f, 147.180f, 148.180f, 149.180f, 150.180f, 151.180f, 152.180f, 153.180f, 154.180f, 155.180f, 156.180f, 157.180f, 158.180f, 159.180f, 160.180f, 161.180f, 162.180f, 163.180f,
164.180f, 165.180f, 166.180f, 167.180f, 168.180f, 169.180f, 170.180f, 171.180f, 172.180f, 173.180f, 174.180f, 175.180f, 176.180f, 177.180f, 178.180f, 179.180f, 180.180f, 181.180f, 182.180f, 183.180f, 184.180f, 185.180f, 186.180f,
187.180f, 188.180f, 189.180f, 190.180f, 191.180f, 192.180f, 193.180f, 194.180f, 195.180f, 196.180f, 197.180f, 198.180f, 199.430f, 200.930f, 202.430f, 203.930f, 205.430f, 206.930f, 208.430f, 209.930f, 211.430f, 212.930f, 214.430f,
215.930f, 217.430f, 218.930f, 220.430f, 221.930f, 223.430f, 224.930f, 226.430f, 227.930f, 229.430f, 230.930f, 232.430f, 233.930f, 235.430f, 236.930f, 238.430f, 239.930f, 241.430f, 242.930f, 244.430f, 245.930f};
GPUconstexpr() uint8_t mNPads[o2::tpc::constants::MAXGLOBALPADROW] = {68, 68, 68, 68, 70, 70, 70, 72, 72, 72, 74, 74, 74, 76, 76, 76, 78, 78, 78, 80, 80, 80, 82, 82, 82, 84, 84, 84, 86, 86, 86, 88, 88, 88, 90, 90, 90, 92, 92, 92,
94, 94, 94, 96, 96, 96, 98, 98, 98, 100, 100, 100, 102, 102, 102, 104, 104, 104, 106, 106, 106, 108, 108, 74, 76, 76, 76, 76, 78, 78, 78, 80, 80, 80, 80, 82, 82, 82, 84, 84,
84, 86, 86, 86, 86, 88, 88, 88, 90, 90, 90, 90, 92, 92, 92, 94, 94, 94, 96, 96, 96, 96, 98, 98, 98, 100, 100, 100, 100, 102, 102, 102, 104, 104, 104, 106, 106, 106, 106, 108,
108, 108, 110, 110, 110, 110, 112, 112, 114, 114, 114, 116, 116, 118, 118, 120, 120, 122, 122, 122, 124, 124, 126, 126, 128, 128, 130, 130, 130, 132, 132, 134, 134, 136, 136, 138, 138, 138, 140};
GPUconstexpr() float mPadHeight[NREGIONS] = {.75f, 1.f, 1.5f};
GPUconstexpr() float mPadWidth[NREGIONS] = {.4f, .6f, .6f};
constexpr float TPC_LENGTH = 250.f - 0.275f;
constexpr float FACTOR_T2Z = 250.f / 1024.f; // Used in compression, must remain constant at 250cm, 1024 time bins!
#endif
GPUconstexpr() float mSectorAngle[o2::tpc::constants::MAXSECTOR][2] = {{0x1.63a1a8p-3f, 0x1.f838b8p-1f}, {0x1p-1f, 0x1.bb67aep-1f}, {0x1.8836fap-1f, 0x1.491b76p-1f}, {0x1.e11f64p-1f, 0x1.5e3a88p-2f}, {0x1p+0f, 0x1.1a6264p-54f}, {0x1.e11f64p-1f, -0x1.5e3a88p-2f},
{0x1.8836fap-1f, -0x1.491b76p-1f}, {0x1p-1f, -0x1.bb67aep-1f}, {0x1.63a1a8p-3f, -0x1.f838b8p-1f}, {-0x1.63a1a8p-3f, -0x1.f838b8p-1f}, {-0x1p-1f, -0x1.bb67aep-1f}, {-0x1.8836fap-1f, -0x1.491b76p-1f},
{-0x1.e11f64p-1f, -0x1.5e3a88p-2f}, {-0x1p+0f, -0x1.a79394p-53f}, {-0x1.e11f64p-1f, 0x1.5e3a88p-2f}, {-0x1.8836fap-1f, 0x1.491b76p-1f}, {-0x1p-1f, 0x1.bb67aep-1f}, {-0x1.63a1a8p-3f, 0x1.f838b8p-1f},
{0x1.63a1a8p-3f, 0x1.f838b8p-1f}, {0x1p-1f, 0x1.bb67aep-1f}, {0x1.8836fap-1f, 0x1.491b76p-1f}, {0x1.e11f64p-1f, 0x1.5e3a88p-2f}, {0x1p+0f, 0x1.60fafcp-52f}, {0x1.e11f64p-1f, -0x1.5e3a88p-2f},
{0x1.8836fap-1f, -0x1.491b76p-1f}, {0x1p-1f, -0x1.bb67aep-1f}, {0x1.63a1a8p-3f, -0x1.f838b8p-1f}, {-0x1.63a1a8p-3f, -0x1.f838b8p-1f}, {-0x1p-1f, -0x1.bb67aep-1f}, {-0x1.8836fap-1f, -0x1.491b76p-1f},
{-0x1.e11f64p-1f, -0x1.5e3a88p-2f}, {-0x1p+0f, -0x1.ee2c2ep-52f}, {-0x1.e11f64p-1f, 0x1.5e3a88p-2f}, {-0x1.8836fap-1f, 0x1.491b76p-1f}, {-0x1p-1f, 0x1.bb67aep-1f}, {-0x1.63a1a8p-3f, 0x1.f838b8p-1f}};
GPUconstexpr() float mSectorAlpha[o2::tpc::constants::MAXSECTOR] = {0x1.65718ep-3f, 0x1.0c152ap-1f, 0x1.becdf2p-1f, 0x1.38c35cp+0f, 0x1.921fcp+0f, 0x1.eb7c24p+0f, 0x1.226c44p+1f, 0x1.4f1a76p+1f, 0x1.7bc8a6p+1f,
-0x1.7bc8a6p+1f, -0x1.4f1a76p+1f, -0x1.226c44p+1f, -0x1.eb7c24p+0f, -0x1.921fcp+0f, -0x1.38c35cp+0f, -0x1.becdf2p-1f, -0x1.0c152ap-1f, -0x1.65718ep-3f,
0x1.65718ep-3f, 0x1.0c152ap-1f, 0x1.becdf2p-1f, 0x1.38c35cp+0f, 0x1.921fcp+0f, 0x1.eb7c24p+0f, 0x1.226c44p+1f, 0x1.4f1a76p+1f, 0x1.7bc8a6p+1f,
-0x1.7bc8a6p+1f, -0x1.4f1a76p+1f, -0x1.226c44p+1f, -0x1.eb7c24p+0f, -0x1.921fcp+0f, -0x1.38c35cp+0f, -0x1.becdf2p-1f, -0x1.0c152ap-1f, -0x1.65718ep-3f};
// clang-format on
} // namespace gputpcgeometry_internal
class GPUTPCGeometry
{
static constexpr float FACTOR_Z2T = 1.f / gputpcgeometry_internal::FACTOR_T2Z;
public:
static constexpr uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
static constexpr uint32_t NROWS = o2::tpc::constants::MAXGLOBALPADROW;
#ifndef GPUCA_RUN2
GPUd() static constexpr int32_t GetRegion(int32_t row) { return gputpcgeometry_internal::mRegion[row]; }
GPUd() static constexpr int32_t GetRegionRows(int32_t region) { return gputpcgeometry_internal::mRegionRows[region]; }
GPUd() static constexpr int32_t GetRegionStart(int32_t region) { return gputpcgeometry_internal::mRegionStart[region]; }
GPUd() static constexpr int32_t GetSampaMapping(int32_t region) { return gputpcgeometry_internal::mSampaMapping[region]; }
GPUd() static constexpr int32_t GetChannelOffset(int32_t region) { return gputpcgeometry_internal::mChannelOffset[region]; }
GPUd() static constexpr int32_t GetSectorFECOffset(int32_t partition) { return gputpcgeometry_internal::mSectorFECOffset[partition]; }
GPUd() static constexpr int32_t GetROC(int32_t row) { return row < 97 ? (row < 63 ? 0 : 1) : (row < 127 ? 2 : 3); }
GPUd() static constexpr int32_t EndIROC() { return 63; }
GPUd() static constexpr int32_t EndOROC1() { return 97; }
GPUd() static constexpr int32_t EndOROC2() { return 127; }
GPUd() static constexpr int32_t MaxNPadsPerRow() { return 138; }
GPUd() static constexpr float PadWidth(int32_t row) { return (gputpcgeometry_internal::mPadWidthRow[row]); }
#else
GPUd() static constexpr int32_t GetRegion(int32_t row) { return (row < 63 ? 0 : row < 63 + 64 ? 1 : 2); }
GPUd() static constexpr int32_t GetRegionRows(int32_t region) { return 0; } // dummy
GPUd() static constexpr int32_t GetRegionStart(int32_t region) { return 0; } // dummy
GPUd() static constexpr int32_t GetROC(int32_t row) { return GetRegion(row); }
GPUd() static constexpr int32_t EndIROC() { return 63; }
GPUd() static constexpr int32_t EndOROC1() { return 63 + 64; }
GPUd() static constexpr int32_t EndOROC2() { return GPUTPCGeometry::NROWS; }
GPUd() static constexpr int32_t MaxNPadsPerRow() { return 140; }
GPUd() static constexpr float PadWidth(int32_t row) { return (gputpcgeometry_internal::mPadWidth[GetRegion(row)]); }
#endif
GPUd() static constexpr float Row2X(uint32_t row) { return (gputpcgeometry_internal::mX[row]); }
GPUd() static constexpr float NRegions() { return gputpcgeometry_internal::NREGIONS; }
GPUd() static constexpr float TPCLength() { return gputpcgeometry_internal::TPC_LENGTH; }
GPUd() static constexpr float PadHeight(uint32_t row) { return (gputpcgeometry_internal::mPadHeight[GetRegion(row)]); }
GPUd() static constexpr float PadHeightByRegion(uint32_t region) { return (gputpcgeometry_internal::mPadHeight[region]); }
GPUd() static constexpr float PadWidthByRegion(uint32_t region) { return (gputpcgeometry_internal::mPadWidth[region]); }
GPUd() static constexpr uint8_t NPads(uint32_t row) { return gputpcgeometry_internal::mNPads[row]; }
GPUd() static constexpr float SectorSin(uint32_t sector) { return gputpcgeometry_internal::mSectorAngle[sector][0]; }
GPUd() static constexpr float SectorCos(uint32_t sector) { return gputpcgeometry_internal::mSectorAngle[sector][1]; }
GPUd() static constexpr float SectorAlpha(uint32_t sector) { return gputpcgeometry_internal::mSectorAlpha[sector]; }
GPUd() static constexpr float LinearPad2Y(uint32_t sector, uint32_t row, float pad)
{
#ifndef GPUCA_RUN2
const float u = (pad - 0.5f * (gputpcgeometry_internal::mNPads[row] - 1)) * PadWidth(row);
#else
const float u = (pad - 0.5f * gputpcgeometry_internal::mNPads[row]) * PadWidth(row);
#endif
return (sector >= NSECTORS / 2) ? -u : u;
}
GPUd() static constexpr float LinearTime2Z(uint32_t sector, float time)
{
const float v = 250.f - time * gputpcgeometry_internal::FACTOR_T2Z; // Used in compression, must remain constant at 250cm!
return (sector >= NSECTORS / 2) ? -v : v;
}
GPUd() static constexpr float LinearY2Pad(uint32_t sector, uint32_t row, float y)
{
const float u = (sector >= NSECTORS / 2) ? -y : y;
#ifndef GPUCA_RUN2
return u / PadWidth(row) + 0.5f * (gputpcgeometry_internal::mNPads[row] - 1);
#else
return u / PadWidth(row) + 0.5f * gputpcgeometry_internal::mNPads[row];
#endif
}
GPUd() static constexpr float LinearZ2Time(uint32_t sector, float z)
{
const float v = (sector >= NSECTORS / 2) ? -z : z;
return (250.f - v) * FACTOR_Z2T; // Used in compression, must remain constant at 250cm
}
GPUd() static constexpr float kSectAngle() { return 2 * CAMath::Pi() / 18.f; }
};
} // namespace o2::gpu
#endif