Skip to content

Commit 797ab95

Browse files
committed
GPU QA: Add option to dump clusters and tracks to ROOT file
1 parent 51b9d84 commit 797ab95

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

GPU/GPUTracking/Benchmark/standalone.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ int ReadConfiguration(int argc, char** argv)
221221
if (configStandalone.QA.inputHistogramsOnly) {
222222
configStandalone.rundEdx = false;
223223
}
224+
if (configStandalone.QA.dumpToROOT) {
225+
configStandalone.proc.outputSharedClusterMap = true;
226+
}
224227
if (configStandalone.eventDisplay) {
225228
configStandalone.noprompt = 1;
226229
}

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ AddOption(filterCharge, int, 0, "", 0, "Filter for positive (+1) or negative (-1
317317
AddOption(filterPID, int, -1, "", 0, "Filter for Particle Type (0 Electron, 1 Muon, 2 Pion, 3 Kaon, 4 Proton)")
318318
AddOption(nativeFitResolutions, bool, false, "", 0, "Create resolution histograms in the native fit units (sin(phi), tan(lambda), Q/Pt)")
319319
AddOption(enableLocalOutput, bool, true, "", 0, "Enable normal output to local PDF files / console")
320+
AddOption(dumpToROOT, int, 0, "", 0, "Dump all clusters and tracks to a ROOT file, 1 = combined TNTUple dump, 2 = also individual cluster / track branch dump")
320321
AddOption(writeMCLabels, bool, false, "", 0, "Store mc labels to file for later matching")
321322
AddOption(writeRootFiles, bool, false, "", 0, "Create ROOT canvas files")
322323
AddOptionVec(matchMCLabels, std::string, "", 0, "Read labels from files and match them, only process tracks where labels differ")

GPU/GPUTracking/qa/GPUQA.cxx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "GPUTPCConvertImpl.h"
5151
#include "TPCFastTransform.h"
5252
#include "CorrectionMapsHelper.h"
53+
#include "GPUROOTDump.h"
5354
#ifdef GPUCA_HAVE_O2HEADERS
5455
#include "SimulationDataFormat/ConstMCTruthContainer.h"
5556
#include "SimulationDataFormat/MCCompLabel.h"
@@ -1708,6 +1709,52 @@ void GPUQA::RunQA(bool matchOnly, const std::vector<o2::tpc::TrackTPC>* tracksEx
17081709
GPUInfo("QA Time: Cluster Counts:\t%6.0f us", timer.GetCurrentElapsedTime(true) * 1e6);
17091710
}
17101711

1712+
if (mConfig.dumpToROOT) {
1713+
if (!clNative || !mTracking || !mTracking->mIOPtrs.mergedTrackHitAttachment || !mTracking->mIOPtrs.mergedTracks) {
1714+
throw std::runtime_error("Cannot dump non o2::tpc::clusterNative clusters, need also hit attachmend and GPU tracks");
1715+
}
1716+
static auto cldump = GPUROOTDump<o2::tpc::ClusterNative, GPUTPCGMMergedTrack, GPUTPCGMMergedTrackHit, unsigned int, unsigned int, float, float, float, unsigned int, unsigned int, unsigned int>::getNew("cluster", "track", "trackHit", "attach", "extState", "x", "y", "z", "sector", "row", "nEv", "clusterTree");
1717+
unsigned int clid = 0;
1718+
for (unsigned int i = 0; i < GPUChainTracking::NSLICES; i++) {
1719+
for (unsigned int j = 0; j < GPUCA_ROW_COUNT; j++) {
1720+
for (unsigned int k = 0; k < mClNative->nClusters[i][j]; k++) {
1721+
const auto& cl = mClNative->clusters[i][j][k];
1722+
unsigned int attach = mTracking->mIOPtrs.mergedTrackHitAttachment[clid];
1723+
GPUTPCGMMergedTrack trk;
1724+
GPUTPCGMMergedTrackHit trkHit;
1725+
memset((void*)&trk, 0, sizeof(trk));
1726+
memset((void*)&trkHit, 0, sizeof(trkHit));
1727+
float x = 0, y = 0, z = 0;
1728+
if (attach & gputpcgmmergertypes::attachFlagMask) {
1729+
unsigned int track = attach & gputpcgmmergertypes::attachTrackMask;
1730+
trk = mTracking->mIOPtrs.mergedTracks[track];
1731+
for (unsigned int l = 0; l < trk.NClusters(); l++) {
1732+
const auto& tmp = mTracking->mIOPtrs.mergedTrackHits[trk.FirstClusterRef() + l];
1733+
if (tmp.num == clid) {
1734+
trkHit = tmp;
1735+
break;
1736+
}
1737+
}
1738+
mTracking->GetTPCTransformHelper()->Transform(i, j, cl.getPad(), cl.getTime(), x, y, z, trk.GetParam().GetTZOffset());
1739+
mTracking->GetParam().Slice2Global(i, x, y, z, &x, &y, &z);
1740+
}
1741+
1742+
unsigned int extState = mTracking->mIOPtrs.mergedTrackHitStates ? mTracking->mIOPtrs.mergedTrackHitStates[clid] : 0;
1743+
1744+
cldump.Fill(cl, trk, trkHit, attach, extState, x, y, z, i, j, mNEvents - 1);
1745+
clid++;
1746+
}
1747+
}
1748+
}
1749+
}
1750+
1751+
static auto trkdump = GPUROOTDump<unsigned int, GPUTPCGMMergedTrack>::getNew("nEv", "tracks");
1752+
for (unsigned int i = 0; i < mTracking->mIOPtrs.nMergedTracks; i++) {
1753+
if (mTracking->mIOPtrs.mergedTracks[i].OK()) {
1754+
trkdump.Fill(mNEvents - 1, mTracking->mIOPtrs.mergedTracks[i]);
1755+
}
1756+
}
1757+
17111758
mTrackingScratchBuffer.clear();
17121759
}
17131760

0 commit comments

Comments
 (0)