Skip to content

Commit 05b8a9f

Browse files
authored
TPC: Improve standalone dEdx calculation class (#15650)
1 parent d189c73 commit 05b8a9f

9 files changed

Lines changed: 1883 additions & 432 deletions

File tree

‎Detectors/TPC/calibration/CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ o2_add_test_root_macro(macro/drawCMV.C
165165
COMPILE_ONLY
166166
PUBLIC_LINK_LIBRARIES O2::TPCCalibration O2::TPCBase
167167
LABELS tpc)
168+
o2_add_test_root_macro(macro/calculatedEdx.C
169+
COMPILE_ONLY
170+
PUBLIC_LINK_LIBRARIES O2::TPCCalibration O2::TPCBase
171+
LABELS tpc)
168172

169173
o2_add_test(IDCFourierTransform
170174
COMPONENT_NAME calibration

‎Detectors/TPC/calibration/include/TPCCalibration/CalculatedEdx.h‎

Lines changed: 323 additions & 47 deletions
Large diffs are not rendered by default.

‎Detectors/TPC/calibration/macro/calculatedEdx.C‎

Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.

‎Detectors/TPC/calibration/src/CalculatedEdx.cxx‎

Lines changed: 1154 additions & 368 deletions
Large diffs are not rendered by default.

‎Detectors/TPC/calibration/src/TPCCalibrationLinkDef.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
#pragma link C++ class o2::tpc::TPCFastSpaceChargeCorrectionHelper + ;
116116

117117
#pragma link C++ class o2::tpc::CalculatedEdx + ;
118+
#pragma link C++ struct o2::tpc::AverageOccupancy + ;
118119
#pragma link C++ class o2::tpc::TPCScaler + ;
119120
#pragma link C++ struct o2::tpc::TPCScalerWeights + ;
120121
#pragma link C++ class o2::tpc::TPCMShapeCorrection + ;

‎GPU/GPUTracking/Merger/GPUTPCGMO2Output.cxx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ GPUdii() void GPUTPCGMO2Output::Thread<GPUTPCGMO2Output::output>(int32_t nBlocks
124124
TrackTPC oTrack;
125125
const int32_t i = trackSort[iTmp].x;
126126
const auto& track = tracks[i];
127+
GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamdEdx)) {
128+
o2::utils::DebugStreamer::instance()->getStreamer("debug_dedx", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_indices").data()
129+
<< "trackID=" << iTmp
130+
<< "iTrk=" << i
131+
<< "\n";
132+
})
127133
auto snpIn = track.GetParam().GetSinPhi();
128134
if (snpIn > SNPThresh) {
129135
snpIn = SNPThresh;
@@ -185,7 +191,7 @@ GPUdii() void GPUTPCGMO2Output::Thread<GPUTPCGMO2Output::output>(int32_t nBlocks
185191
uint32_t nOutCl2 = 0;
186192
float t1 = 0, t2 = 0;
187193
int32_t sector1 = 0, sector2 = 0;
188-
const o2::tpc::ClusterNativeAccess* GPUrestrict() clusters = merger.GetConstantMem()->ioPtrs.clustersNative;
194+
const o2::tpc::ClusterNativeAccess* GPUrestrict() clusters = merger.GetConstantMem() -> ioPtrs.clustersNative;
189195
for (uint32_t j = 0; j < track.NClusters(); j++) {
190196
if ((trackClusters[track.FirstClusterRef() + j].state & flagsReject)) {
191197
continue;
@@ -278,7 +284,7 @@ template <>
278284
GPUdii() void GPUTPCGMO2Output::Thread<GPUTPCGMO2Output::mc>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& GPUrestrict() merger)
279285
{
280286
#ifndef GPUCA_GPUCODE
281-
const o2::tpc::ClusterNativeAccess* GPUrestrict() clusters = merger.GetConstantMem()->ioPtrs.clustersNative;
287+
const o2::tpc::ClusterNativeAccess* GPUrestrict() clusters = merger.GetConstantMem() -> ioPtrs.clustersNative;
282288
if (clusters == nullptr || clusters->clustersMCTruth == nullptr) {
283289
return;
284290
}

‎GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger* GPUrestrict() merger, int32_
5252
constexpr float kDeg2Rad = M_PI / 180.f;
5353
CADEBUG(static constexpr float kSectAngle = 2 * M_PI / 18.f);
5454

55-
const GPUParam& GPUrestrict() param = merger->Param();
55+
const GPUParam& GPUrestrict() param = merger -> Param();
5656

5757
GPUdEdx dEdx, dEdxAlt;
5858
GPUTPCGMPropagator prop;
@@ -126,7 +126,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger* GPUrestrict() merger, int32_
126126
const float clAlpha = param.Alpha(clusters[ihit].sector);
127127
float xx, yy, zz;
128128
{
129-
const ClusterNative& GPUrestrict() cl = merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[clusters[ihit].num];
129+
const ClusterNative& GPUrestrict() cl = merger -> GetConstantMem()->ioPtrs.clustersNative->clustersLinear[clusters[ihit].num];
130130
merger->GetConstantMem()->calibObjects.fastTransform->Transform(clusters[ihit].sector, clusters[ihit].row, cl.getPad(), cl.getTime(), xx, yy, zz, mTOffset);
131131
}
132132
// clang-format off
@@ -304,11 +304,11 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger* GPUrestrict() merger, int32_
304304
relTime /= clusterCount;
305305
relTime = relTime - CAMath::Round(relTime);
306306
if (acc) {
307-
dEdx.fillCluster(qtot, qmax, cluster.row, cluster.sector, mP[2], mP[3], merger->GetConstantMem()->calibObjects, zz, pad, relTime);
307+
dEdx.fillCluster(qtot, qmax, cluster.row, cluster.sector, mP[2], mP[3], merger->GetConstantMem()->calibObjects, zz, pad, relTime GPUCA_DEBUG_STREAMER_CHECK(, iTrk, clusterState));
308308
}
309309
if GPUCA_RTC_CONSTEXPR (GPUCA_GET_CONSTEXPR(param.rec.tpc, dEdxClusterRejectionFlagMask) != GPUCA_GET_CONSTEXPR(param.rec.tpc, dEdxClusterRejectionFlagMaskAlt)) {
310310
if (accAlt) {
311-
dEdxAlt.fillCluster(qtot, qmax, cluster.row, cluster.sector, mP[2], mP[3], merger->GetConstantMem()->calibObjects, zz, pad, relTime);
311+
dEdxAlt.fillCluster(qtot, qmax, cluster.row, cluster.sector, mP[2], mP[3], merger->GetConstantMem()->calibObjects, zz, pad, relTime GPUCA_DEBUG_STREAMER_CHECK(, iTrk, clusterState));
312312
}
313313
}
314314
}
@@ -440,7 +440,7 @@ GPUd() int32_t GPUTPCGMTrackParam::MergeDoubleRowClusters(int32_t& ihit, int32_t
440440
xx = yy = zz = 0.f;
441441
clusterState = 0;
442442
while (true) {
443-
const ClusterNative& GPUrestrict() cl = merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[clusters[ihit].num];
443+
const ClusterNative& GPUrestrict() cl = merger -> GetConstantMem()->ioPtrs.clustersNative->clustersLinear[clusters[ihit].num];
444444
float clamp = cl.getQtot();
445445
float clx, cly, clz;
446446
merger->GetConstantMem()->calibObjects.fastTransform->Transform(clusters[ihit].sector, clusters[ihit].row, cl.getPad(), cl.getTime(), clx, cly, clz, mTOffset);
@@ -493,7 +493,7 @@ GPUd() float GPUTPCGMTrackParam::AttachClusters(const GPUTPCGMMerger* GPUrestric
493493
if (param.rec.tpc.disableRefitAttachment & 1) {
494494
return -1e6f;
495495
}
496-
const GPUTPCTracker& GPUrestrict() tracker = *(Merger->GetConstantMem()->tpcTrackers + sector);
496+
const GPUTPCTracker& GPUrestrict() tracker = *(Merger -> GetConstantMem()->tpcTrackers + sector);
497497
const GPUTPCRow& GPUrestrict() row = tracker.Row(iRow);
498498
GPUglobalref() const cahit2* hits = tracker.HitData(row);
499499
GPUglobalref() const calink* firsthit = tracker.FirstHitInBin(row);
@@ -803,7 +803,7 @@ GPUd() float GPUTPCGMTrackParam::ShiftZ(const GPUTPCGMMergedTrackHit* clusters,
803803
if (N == 0) {
804804
N = 1;
805805
}
806-
const auto& GPUrestrict() cls = merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear;
806+
const auto& GPUrestrict() cls = merger -> GetConstantMem()->ioPtrs.clustersNative->clustersLinear;
807807
float z0 = cls[clusters[0].num].getTime(), zn = cls[clusters[N - 1].num].getTime();
808808
const auto tmp = zn > z0 ? std::array<float, 3>{zn, z0, GPUTPCGeometry::Row2X(clusters[N - 1].row)} : std::array<float, 3>{z0, zn, GPUTPCGeometry::Row2X(clusters[0].row)};
809809
return ShiftZ(merger, clusters[0].sector, tmp[0], tmp[1], tmp[2]);

‎GPU/GPUTracking/Merger/GPUTPCGMTrackParam.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@ class GPUTPCGMTrackParam
214214
private:
215215
GPUd() int32_t initResetT0();
216216

217-
float mX; // x position
218-
float mTOffset; // Z offset with early transform, T offset otherwise
219-
float mP[5]; // 'active' track parameters: Y, Z, SinPhi, DzDs, q/Pt
220-
float mC[15]; // the covariance matrix for Y,Z,SinPhi,..
221-
float mChi2; // the chi^2 value
222-
int32_t mNDF; // the Number of Degrees of Freedom
217+
float mX; // x position
218+
float mTOffset; // Z offset with early transform, T offset otherwise
219+
float mP[5]; // 'active' track parameters: Y, Z, SinPhi, DzDs, q/Pt
220+
float mC[15]; // the covariance matrix for Y,Z,SinPhi,..
221+
float mChi2; // the chi^2 value
222+
int32_t mNDF; // the Number of Degrees of Freedom
223223
};
224224

225225
struct GPUTPCGMLoopData {

‎GPU/GPUTracking/dEdx/GPUdEdx.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class GPUdEdx
3535
public:
3636
// The driver must call clear(), fill clusters row by row outside-in, then run computedEdx() to get the result
3737
GPUd() void clear();
38-
GPUd() void fillCluster(float qtot, float qmax, int32_t padRow, uint8_t sector, float trackSnp, float trackTgl, const GPUCalibObjectsConst& calib, float z, float pad, float relTime);
38+
GPUd() void fillCluster(float qtot, float qmax, int32_t padRow, uint8_t sector, float trackSnp, float trackTgl, const GPUCalibObjectsConst& calib, float z, float pad, float relTime GPUCA_DEBUG_STREAMER_CHECK(, int32_t iTrk, uint8_t flags));
3939
GPUd() void fillSubThreshold(int32_t padRow);
4040
GPUd() void computedEdx(GPUdEdxInfo& output, const GPUParam& param);
4141

@@ -75,7 +75,7 @@ GPUdi() void GPUdEdx::checkSubThresh(int32_t roc)
7575
mLastROC = roc;
7676
}
7777

78-
GPUdnii() void GPUdEdx::fillCluster(float qtot, float qmax, int32_t padRow, uint8_t sector, float trackSnp, float trackTgl, const GPUCalibObjectsConst& calib, float z, float pad, float relTime)
78+
GPUdnii() void GPUdEdx::fillCluster(float qtot, float qmax, int32_t padRow, uint8_t sector, float trackSnp, float trackTgl, const GPUCalibObjectsConst& calib, float z, float pad, float relTime GPUCA_DEBUG_STREAMER_CHECK(, int32_t iTrk, uint8_t flags))
7979
{
8080
// container containing all the dE/dx corrections
8181
auto calibContainer = calib.dEdxCalibContainer;
@@ -86,6 +86,7 @@ GPUdnii() void GPUdEdx::fillCluster(float qtot, float qmax, int32_t padRow, uint
8686
if (mCount >= MAX_NCL) {
8787
return;
8888
}
89+
GPUCA_DEBUG_STREAMER_CHECK(const float clqTot = qtot; const float clqMax = qmax;)
8990
float snp2 = trackSnp * trackSnp;
9091
if (snp2 > constants::MAX_SIN_PHI_LOW) {
9192
snp2 = constants::MAX_SIN_PHI_LOW;
@@ -168,6 +169,10 @@ GPUdnii() void GPUdEdx::fillCluster(float qtot, float qmax, int32_t padRow, uint
168169
<< "qTotResidualCorr=" << qTotResidualCorr
169170
<< "residualGainMapGain=" << residualGainMapGain
170171
<< "fullGainMapGain=" << fullGainMapGain
172+
<< "iTrk=" << iTrk
173+
<< "flags=" << flags
174+
<< "clqTot=" << clqTot
175+
<< "clqMax=" << clqMax
171176
<< "\n";
172177
})
173178
}

0 commit comments

Comments
 (0)