Skip to content

Commit 391fa81

Browse files
davidrohrsawenzel
authored andcommitted
GPU: Expose cluster-state based cluster errors, clean up some bogus variable / function names
1 parent 4f4b06f commit 391fa81

22 files changed

Lines changed: 184 additions & 133 deletions

File tree

DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNative.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ namespace tpc
4848
* Not for permanent storage.
4949
*/
5050
struct ClusterNative {
51-
static constexpr int scaleTimePacked =
52-
64; //< ~50 is needed for 0.1mm precision, but leads to float rounding artifacts around 20ms
51+
// NOTE: These states must match those from GPUTPCGMMergedTrackHit!
52+
enum clusterState { flagSplitPad = 0x1, // Split in pad direction
53+
flagSplitTime = 0x2, // Split in time direction
54+
flagEdge = 0x4, // At edge of TPC sector
55+
flagSingle = 0x8 }; // Single pad or single time-bin cluster
56+
57+
static constexpr int scaleTimePacked = 64; //< ~50 is needed for 0.1mm precision, but leads to float rounding artifacts around 20ms
5358
static constexpr int scalePadPacked = 64; //< ~60 is needed for 0.1mm precision, but power of two avoids rounding
5459
static constexpr int scaleSigmaTimePacked = 32; // 1/32nd of pad/timebin precision for cluster size
5560
static constexpr int scaleSigmaPadPacked = 32;

Detectors/GlobalTracking/src/MatchTPCITS.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "TPCReconstruction/TPCFastTransformHelperO2.h"
4141

4242
#include "GPUO2Interface.h" // Needed for propper settings in GPUParam.h
43-
#include "GPUParam.h" // Consider more universal access
43+
#include "GPUParam.inc" // Consider more universal access
4444

4545
using namespace o2::globaltracking;
4646

Detectors/TPC/reconstruction/include/TPCReconstruction/GPUCATracking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class GPUCATracking
6060
float getPseudoVDrift(); //Return artificial VDrift used to convert time to Z
6161
float getTFReferenceLength() { return sContinuousTFReferenceLength; } //Return reference time frame length used to obtain Z from T in continuous data
6262
int getNTracksASide() { return mNTracksASide; }
63-
void GetClusterErrors2(int row, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const;
63+
void GetClusterErrors2(int row, float z, float sinPhi, float DzDs, short clusterState, float& ErrY2, float& ErrZ2) const;
6464

6565
private:
6666
std::unique_ptr<o2::gpu::GPUTPCO2Interface> mTrackingCAO2Interface; //Pointer to Interface class in HLT O2 CA Tracking library.

Detectors/TPC/reconstruction/src/GPUCATracking.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ float GPUCATracking::getPseudoVDrift()
285285
return (elParam.ZbinWidth * gasParam.DriftV);
286286
}
287287

288-
void GPUCATracking::GetClusterErrors2(int row, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const
288+
void GPUCATracking::GetClusterErrors2(int row, float z, float sinPhi, float DzDs, short clusterState, float& ErrY2, float& ErrZ2) const
289289
{
290290
if (mTrackingCAO2Interface == nullptr) {
291291
return;
292292
}
293-
mTrackingCAO2Interface->GetClusterErrors2(row, z, sinPhi, DzDs, ErrY2, ErrZ2);
293+
mTrackingCAO2Interface->GetClusterErrors2(row, z, sinPhi, DzDs, clusterState, ErrY2, ErrZ2);
294294
}

GPU/GPUTracking/Base/GPUParam.cxx

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -234,90 +234,3 @@ void GPUParam::LoadClusterErrors(bool Print)
234234
}
235235
#endif
236236
#endif
237-
238-
MEM_CLASS_PRE()
239-
void MEM_LG(GPUParam)::Slice2Global(int iSlice, float x, float y, float z, float* X, float* Y, float* Z) const
240-
{
241-
// conversion of coorinates sector->global
242-
*X = x * SliceParam[iSlice].CosAlpha - y * SliceParam[iSlice].SinAlpha;
243-
*Y = y * SliceParam[iSlice].CosAlpha + x * SliceParam[iSlice].SinAlpha;
244-
*Z = z;
245-
}
246-
247-
MEM_CLASS_PRE()
248-
void MEM_LG(GPUParam)::Global2Slice(int iSlice, float X, float Y, float Z, float* x, float* y, float* z) const
249-
{
250-
// conversion of coorinates global->sector
251-
*x = X * SliceParam[iSlice].CosAlpha + Y * SliceParam[iSlice].SinAlpha;
252-
*y = Y * SliceParam[iSlice].CosAlpha - X * SliceParam[iSlice].SinAlpha;
253-
*z = Z;
254-
}
255-
256-
MEM_CLASS_PRE()
257-
GPUd() float MEM_LG(GPUParam)::GetClusterRMS(int yz, int type, float z, float angle2) const
258-
{
259-
//* recalculate the cluster error wih respect to the track slope
260-
261-
MakeType(const float*) c = ParamRMS0[yz][type];
262-
float v = c[0] + c[1] * z + c[2] * angle2;
263-
v = CAMath::Abs(v);
264-
return v;
265-
}
266-
267-
MEM_CLASS_PRE()
268-
GPUd() void MEM_LG(GPUParam)::GetClusterRMS2(int iRow, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const
269-
{
270-
int rowType = tpcGeometry.GetROC(iRow);
271-
if (rowType > 2) {
272-
rowType = 2; // TODO: Add type 3
273-
}
274-
z = CAMath::Abs((250.f - 0.275f) - CAMath::Abs(z));
275-
float s2 = sinPhi * sinPhi;
276-
if (s2 > 0.95f * 0.95f) {
277-
s2 = 0.95f * 0.95f;
278-
}
279-
float sec2 = 1.f / (1.f - s2);
280-
float angleY2 = s2 * sec2; // dy/dx
281-
float angleZ2 = DzDs * DzDs * sec2; // dz/dx
282-
283-
ErrY2 = GetClusterRMS(0, rowType, z, angleY2);
284-
ErrZ2 = GetClusterRMS(1, rowType, z, angleZ2);
285-
ErrY2 *= ErrY2;
286-
ErrZ2 *= ErrZ2;
287-
}
288-
289-
MEM_CLASS_PRE()
290-
GPUd() float MEM_LG(GPUParam)::GetClusterError2(int yz, int type, float z, float angle2) const
291-
{
292-
//* recalculate the cluster error wih respect to the track slope
293-
294-
MakeType(const float*) c = ParamS0Par[yz][type];
295-
float v = c[0] + c[1] * z + c[2] * angle2 + c[3] * z * z + c[4] * angle2 * angle2 + c[5] * z * angle2;
296-
v = CAMath::Abs(v);
297-
if (v < 0.01f) {
298-
v = 0.01f;
299-
}
300-
v *= yz ? rec.ClusterError2CorrectionZ : rec.ClusterError2CorrectionY;
301-
return v;
302-
}
303-
304-
MEM_CLASS_PRE()
305-
GPUd() void MEM_LG(GPUParam)::GetClusterErrors2(int iRow, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const
306-
{
307-
// Calibrated cluster error from OCDB for Y and Z
308-
int rowType = tpcGeometry.GetROC(iRow);
309-
if (rowType > 2) {
310-
rowType = 2; // TODO: Add type 3
311-
}
312-
z = CAMath::Abs((250.f - 0.275f) - CAMath::Abs(z));
313-
float s2 = sinPhi * sinPhi;
314-
if (s2 > 0.95f * 0.95f) {
315-
s2 = 0.95f * 0.95f;
316-
}
317-
float sec2 = 1.f / (1.f - s2);
318-
float angleY2 = s2 * sec2; // dy/dx
319-
float angleZ2 = DzDs * DzDs * sec2; // dz/dx
320-
321-
ErrY2 = GetClusterError2(0, rowType, z, angleY2);
322-
ErrZ2 = GetClusterError2(1, rowType, z, angleZ2);
323-
}

GPU/GPUTracking/Base/GPUParam.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,16 @@ struct GPUParam {
8383

8484
GPUd() float GetClusterError2(int yz, int type, float z, float angle2) const;
8585
GPUd() void GetClusterErrors2(int row, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const;
86+
GPUd() void UpdateClusterError2ByState(short clusterState, float& ErrY2, float& ErrZ2) const;
8687

87-
void Slice2Global(int iSlice, float x, float y, float z, float* X, float* Y, float* Z) const;
88-
void Global2Slice(int iSlice, float x, float y, float z, float* X, float* Y, float* Z) const;
88+
GPUd() void Slice2Global(int iSlice, float x, float y, float z, float* X, float* Y, float* Z) const;
89+
GPUd() void Global2Slice(int iSlice, float x, float y, float z, float* X, float* Y, float* Z) const;
8990

9091
protected:
9192
float ParamRMS0[2][3][4]; // cluster shape parameterization coeficients
9293
float ParamS0Par[2][3][6]; // cluster error parameterization coeficients
9394
};
95+
9496
} // namespace gpu
9597
} // namespace GPUCA_NAMESPACE
9698

GPU/GPUTracking/Base/GPUParam.inc

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file GPUParam.inc
12+
/// \author David Rohr, Sergey Gorbunov
13+
14+
#ifndef GPUPARAM_INC
15+
#define GPUPARAM_INC
16+
17+
#include "GPUParam.h"
18+
#include "GPUTPCGMMergedTrackHit.h"
19+
20+
namespace GPUCA_NAMESPACE
21+
{
22+
namespace gpu
23+
{
24+
25+
MEM_CLASS_PRE()
26+
GPUdi() void MEM_LG(GPUParam)::Slice2Global(int iSlice, float x, float y, float z, float* X, float* Y, float* Z) const
27+
{
28+
// conversion of coorinates sector->global
29+
*X = x * SliceParam[iSlice].CosAlpha - y * SliceParam[iSlice].SinAlpha;
30+
*Y = y * SliceParam[iSlice].CosAlpha + x * SliceParam[iSlice].SinAlpha;
31+
*Z = z;
32+
}
33+
34+
MEM_CLASS_PRE()
35+
GPUdi() void MEM_LG(GPUParam)::Global2Slice(int iSlice, float X, float Y, float Z, float* x, float* y, float* z) const
36+
{
37+
// conversion of coorinates global->sector
38+
*x = X * SliceParam[iSlice].CosAlpha + Y * SliceParam[iSlice].SinAlpha;
39+
*y = Y * SliceParam[iSlice].CosAlpha - X * SliceParam[iSlice].SinAlpha;
40+
*z = Z;
41+
}
42+
43+
MEM_CLASS_PRE()
44+
GPUdi() float MEM_LG(GPUParam)::GetClusterRMS(int yz, int type, float z, float angle2) const
45+
{
46+
//* recalculate the cluster error wih respect to the track slope
47+
48+
MakeType(const float*) c = ParamRMS0[yz][type];
49+
float v = c[0] + c[1] * z + c[2] * angle2;
50+
v = CAMath::Abs(v);
51+
return v;
52+
}
53+
54+
MEM_CLASS_PRE()
55+
GPUdi() void MEM_LG(GPUParam)::GetClusterRMS2(int iRow, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const
56+
{
57+
int rowType = tpcGeometry.GetROC(iRow);
58+
if (rowType > 2) {
59+
rowType = 2; // TODO: Add type 3
60+
}
61+
z = CAMath::Abs((250.f - 0.275f) - CAMath::Abs(z));
62+
float s2 = sinPhi * sinPhi;
63+
if (s2 > 0.95f * 0.95f) {
64+
s2 = 0.95f * 0.95f;
65+
}
66+
float sec2 = 1.f / (1.f - s2);
67+
float angleY2 = s2 * sec2; // dy/dx
68+
float angleZ2 = DzDs * DzDs * sec2; // dz/dx
69+
70+
ErrY2 = GetClusterRMS(0, rowType, z, angleY2);
71+
ErrZ2 = GetClusterRMS(1, rowType, z, angleZ2);
72+
ErrY2 *= ErrY2;
73+
ErrZ2 *= ErrZ2;
74+
}
75+
76+
MEM_CLASS_PRE()
77+
GPUdi() float MEM_LG(GPUParam)::GetClusterError2(int yz, int type, float z, float angle2) const
78+
{
79+
//* recalculate the cluster error wih respect to the track slope
80+
81+
MakeType(const float*) c = ParamS0Par[yz][type];
82+
float v = c[0] + c[1] * z + c[2] * angle2 + c[3] * z * z + c[4] * angle2 * angle2 + c[5] * z * angle2;
83+
v = CAMath::Abs(v);
84+
if (v < 0.01f) {
85+
v = 0.01f;
86+
}
87+
v *= yz ? rec.ClusterError2CorrectionZ : rec.ClusterError2CorrectionY;
88+
return v;
89+
}
90+
91+
MEM_CLASS_PRE()
92+
GPUdi() void MEM_LG(GPUParam)::GetClusterErrors2(int iRow, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const
93+
{
94+
// Calibrated cluster error from OCDB for Y and Z
95+
int rowType = tpcGeometry.GetROC(iRow);
96+
if (rowType > 2) {
97+
rowType = 2; // TODO: Add type 3
98+
}
99+
z = CAMath::Abs((250.f - 0.275f) - CAMath::Abs(z));
100+
float s2 = sinPhi * sinPhi;
101+
if (s2 > 0.95f * 0.95f) {
102+
s2 = 0.95f * 0.95f;
103+
}
104+
float sec2 = 1.f / (1.f - s2);
105+
float angleY2 = s2 * sec2; // dy/dx
106+
float angleZ2 = DzDs * DzDs * sec2; // dz/dx
107+
108+
ErrY2 = GetClusterError2(0, rowType, z, angleY2);
109+
ErrZ2 = GetClusterError2(1, rowType, z, angleZ2);
110+
}
111+
112+
MEM_CLASS_PRE()
113+
GPUdi() void MEM_LG(GPUParam)::UpdateClusterError2ByState(short clusterState, float& ErrY2, float& ErrZ2) const
114+
{
115+
if (clusterState & GPUTPCGMMergedTrackHit::flagEdge) {
116+
ErrY2 += 0.35f;
117+
ErrZ2 += 0.15f;
118+
}
119+
if (clusterState & GPUTPCGMMergedTrackHit::flagSingle) {
120+
ErrY2 += 0.2f;
121+
ErrZ2 += 0.2f;
122+
}
123+
if (clusterState & (GPUTPCGMMergedTrackHit::flagSplitPad | GPUTPCGMMergedTrackHit::flagShared | GPUTPCGMMergedTrackHit::flagSingle)) {
124+
ErrY2 += 0.03f;
125+
ErrY2 *= 3;
126+
}
127+
if (clusterState & (GPUTPCGMMergedTrackHit::flagSplitTime | GPUTPCGMMergedTrackHit::flagShared | GPUTPCGMMergedTrackHit::flagSingle)) {
128+
ErrZ2 += 0.03f;
129+
ErrZ2 *= 3;
130+
}
131+
}
132+
133+
} // namespace gpu
134+
} // namespace GPUCA_NAMESPACE
135+
136+
#endif

GPU/GPUTracking/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ set(HDRS_INSTALL
117117
TPCConvert/GPUTPCConvertImpl.h
118118
Base/GPUReconstructionKernelMacros.h
119119
Base/GPUO2FakeClasses.h
120+
Base/GPUParam.inc
120121
)
121122

122123
# Sources only for O2

GPU/GPUTracking/DataCompression/GPUTPCCompressionTrackModel.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "GPUTPCCompressionTrackModel.h"
1515
#include "GPUConstantMem.h"
16+
#include "GPUParam.inc"
1617

1718
using namespace GPUCA_NAMESPACE::gpu;
1819

@@ -28,8 +29,8 @@ GPUd() void GPUTPCCompressionTrackModel::Init(float x, float y, float z, float a
2829
mProp.SetMaterial(kRadLen, kRho);
2930
mProp.SetMaxSinPhi(GPUCA_MAX_SIN_PHI);
3031
mProp.SetToyMCEventsFlag(false);
31-
mProp.SetSpecialErrors(false);
32-
mProp.SetFitInProjections(false);
32+
mProp.SetSeedingErrors(true); // Larger errors for seeds, better since we don't start with good hypothesis
33+
mProp.SetFitInProjections(true);
3334
mProp.SetPolynomialField(&param.polynomialField);
3435
mTrk.X() = x;
3536
mTrk.Y() = y;

GPU/GPUTracking/Interface/GPUO2Interface.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "GPUReconstruction.h"
1616
#include "GPUChainTracking.h"
1717
#include "GPUO2InterfaceConfiguration.h"
18+
#include "GPUParam.inc"
1819
#include <iostream>
1920
#include <fstream>
2021
#ifdef GPUCA_HAVE_OPENMP
@@ -103,10 +104,11 @@ int GPUTPCO2Interface::RunTracking(GPUTrackingInOutPointers* data)
103104

104105
void GPUTPCO2Interface::Clear(bool clearOutputs) { mRec->ClearAllocatedMemory(clearOutputs); }
105106

106-
void GPUTPCO2Interface::GetClusterErrors2(int row, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const
107+
void GPUTPCO2Interface::GetClusterErrors2(int row, float z, float sinPhi, float DzDs, short clusterState, float& ErrY2, float& ErrZ2) const
107108
{
108109
if (!mInitialized) {
109110
return;
110111
}
111112
mRec->GetParam().GetClusterErrors2(row, z, sinPhi, DzDs, ErrY2, ErrZ2);
113+
mRec->GetParam().UpdateClusterError2ByState(clusterState, ErrY2, ErrZ2);
112114
}

0 commit comments

Comments
 (0)