Skip to content

Commit 958b8b2

Browse files
committed
GPU: Improve debug-dump of TPC cluster to track residuals
1 parent cb20b56 commit 958b8b2

3 files changed

Lines changed: 46 additions & 83 deletions

File tree

GPU/GPUTracking/Debug/GPUROOTDump.h

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
#ifndef GPUROOTDUMP_H
1515
#define GPUROOTDUMP_H
1616

17-
#include "GPUROOTDumpCore.h"
18-
17+
#include "GPUCommonDef.h"
1918
#if !defined(GPUCA_NO_ROOT) && !defined(GPUCA_GPUCODE)
19+
#include "GPUROOTDumpCore.h"
2020
#include <TTree.h>
2121
#include <TNtuple.h>
2222
#include <memory>
2323
#include <stdexcept>
24+
#else
25+
class TNtuple;
2426
#endif
2527

2628
namespace GPUCA_NAMESPACE
@@ -55,11 +57,6 @@ class GPUROOTDump : public GPUROOTDumpBase
5557
{
5658
static GPUROOTDump<T> instance(name);
5759
}
58-
GPUROOTDump(const char* name)
59-
{
60-
mTree = new TTree(name, name);
61-
mTree->Branch(name, &mObj);
62-
}
6360

6461
void write() override { mTree->Write(); }
6562

@@ -70,6 +67,11 @@ class GPUROOTDump : public GPUROOTDumpBase
7067
}
7168

7269
private:
70+
GPUROOTDump(const char* name)
71+
{
72+
mTree = new TTree(name, name);
73+
mTree->Branch(name, &mObj);
74+
}
7375
TTree* mTree = nullptr;
7476
T mObj;
7577
};
@@ -83,10 +85,6 @@ class GPUROOTDump<TNtuple> : public GPUROOTDumpBase
8385
static GPUROOTDump<TNtuple> instance(name, options);
8486
return instance;
8587
}
86-
GPUROOTDump(const char* name, const char* options)
87-
{
88-
mNTuple = new TNtuple(name, name, options);
89-
}
9088

9189
void write() override { mNTuple->Write(); }
9290

@@ -97,14 +95,26 @@ class GPUROOTDump<TNtuple> : public GPUROOTDumpBase
9795
}
9896

9997
private:
98+
GPUROOTDump(const char* name, const char* options)
99+
{
100+
mNTuple = new TNtuple(name, name, options);
101+
}
100102
TNtuple* mNTuple;
101103
};
102104
#else
103105
template <class T>
104106
class GPUROOTDump
105107
{
106108
public:
107-
GPUROOTDump() = delete;
109+
template <typename... Args>
110+
GPUd() void Fill(Args... args) const
111+
{
112+
}
113+
template <typename... Args>
114+
GPUd() static GPUROOTDump<T>& get(Args... args)
115+
{
116+
return *(GPUROOTDump<T>*)(size_t)(1024); // Will never be used, return just some reference
117+
}
108118
};
109119
#endif
110120
} // namespace gpu

GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313

1414
#define GPUCA_CADEBUG 0
1515
#define DEBUG_SINGLE_TRACK -1
16+
#define EXTRACT_RESIDUALS 0
17+
18+
#if EXTRACT_RESIDUALS == 1
19+
#include "GPUROOTDump.h"
20+
#endif
1621

17-
#include "GPUTPCClusterErrorStat.h"
1822
#include "GPUTPCDef.h"
1923
#include "GPUTPCGMTrackParam.h"
2024
#include "GPUTPCGMPhysicalTrackModel.h"
@@ -58,8 +62,6 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger* GPUrestrict() merger, int iT
5862
{
5963
const GPUParam& GPUrestrict() param = merger->Param();
6064

61-
GPUTPCClusterErrorStat errorStat(N);
62-
6365
GPUdEdx dEdx;
6466
GPUTPCGMPropagator prop;
6567
gputpcgmmergertypes::InterpolationErrors interpolation;
@@ -266,14 +268,32 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger* GPUrestrict() merger, int iT
266268
continue;
267269
}
268270
CADEBUG(printf("\n"));
269-
errorStat.Fill(xx, yy, zz, prop.GetAlpha(), mX, mP, mC, ihit, iWay);
270271

271272
int retVal;
272273
float threshold = 3.f + (lastUpdateX >= 0 ? (CAMath::Abs(mX - lastUpdateX) / 2) : 0.f);
273274
if (mNDF > 5 && (CAMath::Abs(yy - mP[0]) > threshold || CAMath::Abs(zz - mP[1]) > threshold)) {
274275
retVal = 2;
275276
} else {
276277
char rejectChi2 = attempt ? 0 : ((param.rec.mergerInterpolateErrors && CAMath::Abs(ihit - ihitMergeFirst) <= 1) ? (refit ? (2 + ((nWays - iWay) & 1)) : 0) : (allowModification && goodRows > 5));
278+
#if EXTRACT_RESIDUALS == 1
279+
if (iWay == nWays - 1 && interpolation.hit[ihit].errorY > (GPUCA_MERGER_INTERPOLATION_ERROR_TYPE)0) {
280+
const float Iz0 = interpolation.hit[ihit].posY - mP[0];
281+
const float Iz1 = interpolation.hit[ihit].posZ - mP[1];
282+
float Iw0 = mC[2] + (float)interpolation.hit[ihit].errorZ;
283+
float Iw2 = mC[0] + (float)interpolation.hit[ihit].errorY;
284+
float Idet1 = 1.f / CAMath::Max(1e-10f, Iw0 * Iw2 - mC[1] * mC[1]);
285+
const float Ik00 = (mC[0] * Iw0 + mC[1] * mC[1]) * Idet1;
286+
const float Ik01 = (mC[0] * mC[1] + mC[1] * Iw2) * Idet1;
287+
const float Ik10 = (mC[1] * Iw0 + mC[2] * mC[1]) * Idet1;
288+
const float Ik11 = (mC[1] * mC[1] + mC[2] * Iw2) * Idet1;
289+
const float ImP0 = mP[0] + Ik00 * Iz0 + Ik01 * Iz1;
290+
const float ImP1 = mP[1] + Ik10 * Iz0 + Ik11 * Iz1;
291+
const float ImC0 = mC[0] - Ik00 * mC[0] + Ik01 * mC[1];
292+
const float ImC2 = mC[2] - Ik10 * mC[1] + Ik11 * mC[2];
293+
auto& tup = GPUROOTDump<TNtuple>::get("clusterres", "row:clX:clY:clZ:angle:trkX:trkY:trkZ:trkSinPhi:trkDzDs:trkQPt:trkSigmaY2:trkSigmaZ2trkSigmaQPt2");
294+
tup.Fill((float)clusters[ihit].row, xx, yy, zz, clAlpha, mX, ImP0, ImP1, mP[2], mP[3], mP[4], ImC0, ImC2, mC[14]);
295+
}
296+
#endif
277297
retVal = prop.Update(yy, zz, clusters[ihit].row, param, clusterState, rejectChi2, &interpolation.hit[ihit], refit);
278298
}
279299
// clang-format off

GPU/GPUTracking/SliceTracker/GPUTPCClusterErrorStat.h

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)