Skip to content

Commit ab4e116

Browse files
committed
GPU QA: Add option compareTrackStatus
1 parent f2ffe50 commit ab4e116

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,10 @@ AddOption(filterPID, int32_t, -1, "", 0, "Filter for Particle Type (0 Electron,
512512
AddOption(nativeFitResolutions, bool, false, "", 0, "Create resolution histograms in the native fit units (sin(phi), tan(lambda), Q/Pt)")
513513
AddOption(enableLocalOutput, bool, true, "", 0, "Enable normal output to local PDF files / console")
514514
AddOption(dumpToROOT, int32_t, 0, "", 0, "Dump all clusters and tracks to a ROOT file, 1 = combined TNTUple dump, 2 = also individual cluster / track branch dump")
515-
AddOption(writeMCLabels, bool, false, "", 0, "Store mc labels to file for later matching")
516515
AddOption(writeRootFiles, bool, false, "", 0, "Create ROOT canvas files")
516+
AddOption(writeMCLabels, bool, false, "", 0, "Store mc labels to file for later matching")
517517
AddOptionVec(matchMCLabels, std::string, "", 0, "Read labels from files and match them, only process tracks where labels differ")
518+
AddOption(compareTrackStatus, uint32_t, 0, "", 0, "0 = disabled, 1 = write status file, 2 = read status file and compare with current tracks")
518519
AddOption(matchDisplayMinPt, float, 0, "", 0, "Minimum Pt of a matched track to be displayed")
519520
AddOption(noMC, bool, false, "", 0, "Force running QA without MC labels even if present")
520521
AddOption(shipToQC, bool, false, "", 0, "Do not write output files but ship histograms for QC")

GPU/GPUTracking/qa/GPUQA.cxx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include <algorithm>
7474
#include <cstdio>
7575
#include <cinttypes>
76+
#include <fstream>
7677

7778
#include "utils/timer.h"
7879

@@ -1899,6 +1900,56 @@ void GPUQA::RunQA(bool matchOnly, const std::vector<o2::tpc::TrackTPC>* tracksEx
18991900
}
19001901
}
19011902
}
1903+
1904+
if (mConfig.compareTrackStatus) {
1905+
#ifdef GPUCA_DETERMINISTIC_MODE
1906+
if (!mTracking || !mTracking->GetProcessingSettings().deterministicGPUReconstruction)
1907+
#endif
1908+
{
1909+
throw std::runtime_error("Need deterministic processing to compare track status");
1910+
}
1911+
std::vector<uint8_t> status(mTracking->mIOPtrs.nMergedTracks);
1912+
for (uint32_t i = 0; i < mTracking->mIOPtrs.nMergedTracks; i++) {
1913+
const auto& trk = mTracking->mIOPtrs.mergedTracks[i];
1914+
status[i] = trk.OK() && trk.NClusters() && trk.GetParam().GetNDF() > 0;
1915+
}
1916+
if (mConfig.compareTrackStatus == 1) {
1917+
std::ofstream("track.status", std::ios::binary).write((char*)status.data(), status.size() * sizeof(status[0]));
1918+
} else if (mConfig.compareTrackStatus == 2) {
1919+
std::ifstream f("track.status", std::ios::binary | std::ios::ate);
1920+
std::vector<uint8_t> comp(f.tellg());
1921+
f.seekg(0);
1922+
f.read((char*)comp.data(), comp.size());
1923+
1924+
if (comp.size() != status.size()) {
1925+
throw std::runtime_error("Number of tracks candidates in track fit in track.status and in current reconstruction differ");
1926+
}
1927+
std::vector<uint32_t> missing, missingComp;
1928+
for (uint32_t i = 0; i < status.size(); i++) {
1929+
if (status[i] && !comp[i]) {
1930+
missingComp.emplace_back(i);
1931+
}
1932+
if (comp[i] && !status[i]) {
1933+
missing.emplace_back(i);
1934+
}
1935+
}
1936+
auto printer = [](std::vector<uint32_t> m, const char* name) {
1937+
if (m.size()) {
1938+
printf("Missing in %s reconstruction: (%zu)\n", name, m.size());
1939+
for (uint32_t i = 0; i < m.size(); i++) {
1940+
if (i) {
1941+
printf(", ");
1942+
}
1943+
printf("%d", m[i]);
1944+
}
1945+
printf("\n");
1946+
}
1947+
};
1948+
printer(missing, "current");
1949+
printer(missingComp, "comparison");
1950+
}
1951+
}
1952+
19021953
mTrackingScratchBuffer.clear();
19031954
mTrackingScratchBuffer.shrink_to_fit();
19041955
}

0 commit comments

Comments
 (0)