Skip to content

Commit 04066d6

Browse files
committed
GPU QA: Fix some task number inconsistencies
1 parent da5f704 commit 04066d6

File tree

4 files changed

+127
-114
lines changed

4 files changed

+127
-114
lines changed

GPU/GPUTracking/Global/GPUChainTracking.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ int32_t GPUChainTracking::ForceInitQA()
475475
qa.reset(new GPUQA(this));
476476
}
477477
if (!GetQA()->IsInitialized()) {
478-
return GetQA()->InitQA();
478+
return GetQA()->InitQA(GetProcessingSettings().runQA <= 0 ? -GetProcessingSettings().runQA : GPUQA::tasksAutomatic);
479479
}
480480
return 0;
481481
}
@@ -690,7 +690,7 @@ int32_t GPUChainTracking::RunChain()
690690
}
691691
const bool needQA = GPUQA::QAAvailable() && (GetProcessingSettings().runQA || (GetProcessingSettings().eventDisplay && (mIOPtrs.nMCInfosTPC || GetProcessingSettings().runMC)));
692692
if (needQA && GetQA()->IsInitialized() == false) {
693-
if (GetQA()->InitQA(GetProcessingSettings().runQA ? -GetProcessingSettings().runQA : -1)) {
693+
if (GetQA()->InitQA(GetProcessingSettings().runQA <= 0 ? -GetProcessingSettings().runQA : GPUQA::tasksAutomatic)) {
694694
return 1;
695695
}
696696
}

GPU/GPUTracking/qa/GPUQA.cxx

Lines changed: 116 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ int32_t GPUQA::InitQACreateHistograms()
544544
createHist(mT0[0], "tracks_t0", "tracks_t0", (maxTime + 1) / 10, 0, maxTime);
545545
createHist(mT0[1], "tracks_t0_res", "tracks_t0_res", 1000, -100, 100);
546546
createHist(mClXY, "clXY", "clXY", 1000, -250, 250, 1000, -250, 250); // TODO: Pass name only once
547-
547+
}
548+
if (mQATasks & taskClusterRejection) {
548549
const int padCount = GPUTPCGeometry::NPads(GPUCA_ROW_COUNT - 1);
549550
for (int32_t i = 0; i < 3; i++) {
550551
snprintf(name, 2048, "clrej_%d", i);
@@ -577,8 +578,8 @@ int32_t GPUQA::InitQACreateHistograms()
577578

578579
int32_t GPUQA::loadHistograms(std::vector<TH1F>& i1, std::vector<TH2F>& i2, std::vector<TH1D>& i3, std::vector<TGraphAsymmErrors>& i4, int32_t tasks)
579580
{
580-
if (tasks == -1) {
581-
tasks = taskDefaultPostprocess;
581+
if (tasks == tasksAutomatic) {
582+
tasks = tasksDefaultPostprocess;
582583
}
583584
if (mQAInitialized && (!mHaveExternalHists || tasks != mQATasks)) {
584585
throw std::runtime_error("QA not initialized or initialized with different task array");
@@ -593,7 +594,7 @@ int32_t GPUQA::loadHistograms(std::vector<TH1F>& i1, std::vector<TH2F>& i2, std:
593594
mHistGraph_pos.clear();
594595
mHaveExternalHists = true;
595596
if (mConfig.noMC) {
596-
tasks &= tasksNoQC;
597+
tasks &= tasksAllNoQC;
597598
}
598599
mQATasks = tasks;
599600
if (InitQACreateHistograms()) {
@@ -806,16 +807,16 @@ int32_t GPUQA::InitQA(int32_t tasks)
806807
if (mQAInitialized) {
807808
throw std::runtime_error("QA already initialized");
808809
}
809-
if (tasks == -1) {
810-
tasks = taskDefault;
810+
if (tasks == tasksAutomatic) {
811+
tasks = tasksDefault;
811812
}
812813

813814
mHist1D = new std::vector<TH1F>;
814815
mHist2D = new std::vector<TH2F>;
815816
mHist1Dd = new std::vector<TH1D>;
816817
mHistGraph = new std::vector<TGraphAsymmErrors>;
817818
if (mConfig.noMC) {
818-
tasks &= tasksNoQC;
819+
tasks &= tasksAllNoQC;
819820
}
820821
mQATasks = tasks;
821822

@@ -1823,72 +1824,76 @@ void GPUQA::RunQA(bool matchOnly, const std::vector<o2::tpc::TrackTPC>* tracksEx
18231824

18241825
uint32_t nCl = clNative ? clNative->nClustersTotal : mTracking->GetProcessors()->tpcMerger.NMaxClusters();
18251826
mClusterCounts.nTotal += nCl;
1826-
if (mQATasks & taskClusterCounts) {
1827+
if (mQATasks & (taskClusterCounts | taskClusterRejection)) {
18271828
for (uint32_t iSector = 0; iSector < GPUCA_NSECTORS; iSector++) {
18281829
for (uint32_t iRow = 0; iRow < GPUCA_ROW_COUNT; iRow++) {
18291830
for (uint32_t iCl = 0; iCl < clNative->nClusters[iSector][iRow]; iCl++) {
18301831
uint32_t i = clNative->clusterOffset[iSector][iRow] + iCl;
18311832
int32_t attach = mTracking->mIOPtrs.mergedTrackHitAttachment[i];
18321833
const auto& r = checkClusterState<true>(attach, &mClusterCounts);
18331834

1834-
if (mcAvail) {
1835-
float totalWeight = 0, weight400 = 0, weight40 = 0;
1836-
for (int32_t j = 0; j < GetMCLabelNID(i); j++) {
1837-
const auto& label = GetMCLabel(i, j);
1838-
if (GetMCLabelID(label) >= 0) {
1839-
totalWeight += GetMCLabelWeight(label);
1840-
if (GetMCTrackObj(mMCParam, label).pt >= 0.4) {
1841-
weight400 += GetMCLabelWeight(label);
1842-
}
1843-
if (GetMCTrackObj(mMCParam, label).pt <= 0.04) {
1844-
weight40 += GetMCLabelWeight(label);
1835+
if (mQATasks & taskClusterRejection) {
1836+
if (mcAvail) {
1837+
float totalWeight = 0, weight400 = 0, weight40 = 0;
1838+
for (int32_t j = 0; j < GetMCLabelNID(i); j++) {
1839+
const auto& label = GetMCLabel(i, j);
1840+
if (GetMCLabelID(label) >= 0) {
1841+
totalWeight += GetMCLabelWeight(label);
1842+
if (GetMCTrackObj(mMCParam, label).pt >= 0.4) {
1843+
weight400 += GetMCLabelWeight(label);
1844+
}
1845+
if (GetMCTrackObj(mMCParam, label).pt <= 0.04) {
1846+
weight40 += GetMCLabelWeight(label);
1847+
}
18451848
}
18461849
}
1847-
}
1848-
if (totalWeight > 0 && 10.f * weight400 >= totalWeight) {
1849-
if (!r.unattached && !r.protect && !r.physics) {
1850-
mClusterCounts.nFakeRemove400++;
1851-
int32_t totalFake = weight400 < 0.9f * totalWeight;
1852-
if (totalFake) {
1853-
mClusterCounts.nFullFakeRemove400++;
1854-
}
1855-
/*printf("Fake removal (%d): Hit %7d, attached %d lowPt %d looper %d tube200 %d highIncl %d tube %d bad %d recPt %7.2f recLabel %6d", totalFake, i, (int32_t) (mClusterParam[i].attached || mClusterParam[i].fakeAttached),
1856-
(int32_t) lowPt, (int32_t) ((attach & gputpcgmmergertypes::attachGoodLeg) == 0), (int32_t) ((attach & gputpcgmmergertypes::attachTube) && mev200),
1857-
(int32_t) ((attach & gputpcgmmergertypes::attachHighIncl) != 0), (int32_t) ((attach & gputpcgmmergertypes::attachTube) != 0), (int32_t) ((attach & gputpcgmmergertypes::attachGood) == 0),
1858-
fabsf(qpt) > 0 ? 1.f / qpt : 0.f, id);
1859-
for (int32_t j = 0;j < GetMCLabelNID(i);j++)
1860-
{
1861-
//if (GetMCLabelID(i, j) < 0) break;
1862-
printf(" - label%d %6d weight %5d", j, GetMCLabelID(i, j), (int32_t) GetMCLabelWeight(i, j));
1863-
if (GetMCLabelID(i, j) >= 0) printf(" - pt %7.2f", mMCParam[GetMCLabelID(i, j)].pt);
1864-
else printf(" ");
1850+
if (totalWeight > 0 && 10.f * weight400 >= totalWeight) {
1851+
if (!r.unattached && !r.protect && !r.physics) {
1852+
mClusterCounts.nFakeRemove400++;
1853+
int32_t totalFake = weight400 < 0.9f * totalWeight;
1854+
if (totalFake) {
1855+
mClusterCounts.nFullFakeRemove400++;
1856+
}
1857+
/*printf("Fake removal (%d): Hit %7d, attached %d lowPt %d looper %d tube200 %d highIncl %d tube %d bad %d recPt %7.2f recLabel %6d", totalFake, i, (int32_t) (mClusterParam[i].attached || mClusterParam[i].fakeAttached),
1858+
(int32_t) lowPt, (int32_t) ((attach & gputpcgmmergertypes::attachGoodLeg) == 0), (int32_t) ((attach & gputpcgmmergertypes::attachTube) && mev200),
1859+
(int32_t) ((attach & gputpcgmmergertypes::attachHighIncl) != 0), (int32_t) ((attach & gputpcgmmergertypes::attachTube) != 0), (int32_t) ((attach & gputpcgmmergertypes::attachGood) == 0),
1860+
fabsf(qpt) > 0 ? 1.f / qpt : 0.f, id);
1861+
for (int32_t j = 0;j < GetMCLabelNID(i);j++)
1862+
{
1863+
//if (GetMCLabelID(i, j) < 0) break;
1864+
printf(" - label%d %6d weight %5d", j, GetMCLabelID(i, j), (int32_t) GetMCLabelWeight(i, j));
1865+
if (GetMCLabelID(i, j) >= 0) printf(" - pt %7.2f", mMCParam[GetMCLabelID(i, j)].pt);
1866+
else printf(" ");
1867+
}
1868+
printf("\n");*/
18651869
}
1866-
printf("\n");*/
1870+
mClusterCounts.nAbove400++;
18671871
}
1868-
mClusterCounts.nAbove400++;
1869-
}
1870-
if (totalWeight > 0 && weight40 >= 0.9 * totalWeight) {
1871-
mClusterCounts.nBelow40++;
1872-
if (r.protect || r.physics) {
1873-
mClusterCounts.nFakeProtect40++;
1872+
if (totalWeight > 0 && weight40 >= 0.9 * totalWeight) {
1873+
mClusterCounts.nBelow40++;
1874+
if (r.protect || r.physics) {
1875+
mClusterCounts.nFakeProtect40++;
1876+
}
18741877
}
18751878
}
1876-
}
18771879

1878-
if (r.physics) {
1879-
mClusterCounts.nPhysics++;
1880-
}
1881-
if (r.protect) {
1882-
mClusterCounts.nProt++;
1883-
}
1884-
if (r.unattached) {
1885-
mClusterCounts.nUnattached++;
1880+
if (r.physics) {
1881+
mClusterCounts.nPhysics++;
1882+
}
1883+
if (r.protect) {
1884+
mClusterCounts.nProt++;
1885+
}
1886+
if (r.unattached) {
1887+
mClusterCounts.nUnattached++;
1888+
}
18861889
}
1887-
if (mTracking && clNative) {
1888-
const auto& cl = clNative->clustersLinear[i];
1889-
mClRej[0]->Fill(cl.getPad() - GPUTPCGeometry::NPads(iRow) / 2 + 0.5, iRow, 1.f);
1890-
if (!r.unattached && !r.protect) {
1891-
mClRej[1]->Fill(cl.getPad() - GPUTPCGeometry::NPads(iRow) / 2 + 0.5, iRow, 1.f);
1890+
if (mQATasks & taskClusterRejection) {
1891+
if (mTracking && clNative) {
1892+
const auto& cl = clNative->clustersLinear[i];
1893+
mClRej[0]->Fill(cl.getPad() - GPUTPCGeometry::NPads(iRow) / 2 + 0.5, iRow, 1.f);
1894+
if (!r.unattached && !r.protect) {
1895+
mClRej[1]->Fill(cl.getPad() - GPUTPCGeometry::NPads(iRow) / 2 + 0.5, iRow, 1.f);
1896+
}
18921897
}
18931898
}
18941899
}
@@ -2271,7 +2276,9 @@ int32_t GPUQA::DrawQAHistograms(TObjArray* qcout)
22712276
mCClXY->cd();
22722277
mPClXY = createGarbageCollected<TPad>("p0", "", 0.0, 0.0, 1.0, 1.0);
22732278
mPClXY->Draw();
2279+
}
22742280

2281+
if (mQATasks & taskClusterRejection) {
22752282
for (int32_t i = 0; i < 3; i++) {
22762283
snprintf(name, 2048, "cnclrej%d", i);
22772284
mCClRej[i] = createGarbageCollected<TCanvas>(name, name, 0, 0, 700, 700. * 2. / 3.);
@@ -2283,7 +2290,9 @@ int32_t GPUQA::DrawQAHistograms(TObjArray* qcout)
22832290
mCClRejP->cd();
22842291
mPClRejP = createGarbageCollected<TPad>("p0", "", 0.0, 0.0, 1.0, 1.0);
22852292
mPClRejP->Draw();
2293+
}
22862294

2295+
if (mQATasks & taskClusterAttach) {
22872296
for (int32_t i = 0; i < 4; i++) {
22882297
snprintf(name, 2048, "cpadrow%d", i);
22892298
mCPadRow[i] = createGarbageCollected<TCanvas>(name, name, 0, 0, 700, 700. * 2. / 3.);
@@ -3034,69 +3043,69 @@ int32_t GPUQA::DrawQAHistograms(TObjArray* qcout)
30343043
}
30353044
}
30363045

3037-
mPClXY->cd();
3046+
mPClXY->cd(); // TODO: This should become a separate task category
30383047
mClXY->SetOption("colz");
30393048
mClXY->Draw();
30403049
mCClXY->cd();
30413050
mCClXY->Print(Form("%s/clustersXY.pdf", mConfig.plotsDir.c_str()));
30423051
if (mConfig.writeFileExt != "") {
30433052
mCClXY->Print(Form("%s/clustersXY.%s", mConfig.plotsDir.c_str(), mConfig.writeFileExt.c_str()));
30443053
}
3054+
}
30453055

3046-
if (mQATasks & taskClusterCounts) {
3047-
mClRej[2]->Divide(mClRej[1], mClRej[0]);
3056+
if (mQATasks & taskClusterRejection) {
3057+
mClRej[2]->Divide(mClRej[1], mClRej[0]);
30483058

3049-
for (int32_t i = 0; i < 3; i++) {
3050-
if (tout && !mConfig.inputHistogramsOnly) {
3051-
mClRej[i]->Write();
3052-
}
3053-
mPClRej[i]->cd();
3054-
mClRej[i]->SetTitle(REJECTED_NAMES[i]);
3055-
mClRej[i]->SetOption("colz");
3056-
mClRej[i]->Draw();
3057-
mCClRej[i]->cd();
3058-
mCClRej[i]->Print(Form("%s/clustersRej%d%s.pdf", mConfig.plotsDir.c_str(), i, REJECTED_NAMES[i]));
3059-
if (mConfig.writeFileExt != "") {
3060-
mCClRej[i]->Print(Form("%s/clustersRej%d%s.%s", mConfig.plotsDir.c_str(), i, REJECTED_NAMES[i], mConfig.writeFileExt.c_str()));
3061-
}
3059+
for (int32_t i = 0; i < 3; i++) {
3060+
if (tout && !mConfig.inputHistogramsOnly) {
3061+
mClRej[i]->Write();
3062+
}
3063+
mPClRej[i]->cd();
3064+
mClRej[i]->SetTitle(REJECTED_NAMES[i]);
3065+
mClRej[i]->SetOption("colz");
3066+
mClRej[i]->Draw();
3067+
mCClRej[i]->cd();
3068+
mCClRej[i]->Print(Form("%s/clustersRej%d%s.pdf", mConfig.plotsDir.c_str(), i, REJECTED_NAMES[i]));
3069+
if (mConfig.writeFileExt != "") {
3070+
mCClRej[i]->Print(Form("%s/clustersRej%d%s.%s", mConfig.plotsDir.c_str(), i, REJECTED_NAMES[i], mConfig.writeFileExt.c_str()));
30623071
}
3072+
}
30633073

3064-
mPClRejP->cd();
3065-
for (int32_t k = 0; k < ConfigNumInputs; k++) {
3066-
auto* tmp = mClRej[0];
3067-
if (GetHist(tmp, tin, k, nNewInput) == nullptr) {
3068-
continue;
3069-
}
3070-
TH1D* proj1 = tmp->ProjectionY(Form("clrejptmp1%d", k)); // TODO: Clean up names
3071-
proj1->SetDirectory(nullptr);
3072-
tmp = mClRej[1];
3073-
if (GetHist(tmp, tin, k, nNewInput) == nullptr) {
3074-
continue;
3075-
}
3076-
TH1D* proj2 = tmp->ProjectionY(Form("clrejptmp2%d", k));
3077-
proj2->SetDirectory(nullptr);
3074+
mPClRejP->cd();
3075+
for (int32_t k = 0; k < ConfigNumInputs; k++) {
3076+
auto* tmp = mClRej[0];
3077+
if (GetHist(tmp, tin, k, nNewInput) == nullptr) {
3078+
continue;
3079+
}
3080+
TH1D* proj1 = tmp->ProjectionY(Form("clrejptmp1%d", k)); // TODO: Clean up names
3081+
proj1->SetDirectory(nullptr);
3082+
tmp = mClRej[1];
3083+
if (GetHist(tmp, tin, k, nNewInput) == nullptr) {
3084+
continue;
3085+
}
3086+
TH1D* proj2 = tmp->ProjectionY(Form("clrejptmp2%d", k));
3087+
proj2->SetDirectory(nullptr);
30783088

3079-
auto* e = mClRejP;
3080-
if (GetHist(e, tin, k, nNewInput) == nullptr) {
3081-
continue;
3082-
}
3083-
e->Divide(proj2, proj1);
3084-
if (tout && !mConfig.inputHistogramsOnly && k == 0) {
3085-
e->Write();
3086-
}
3087-
delete proj1;
3088-
delete proj2;
3089-
e->SetMinimum(-0.02);
3090-
e->SetMaximum(0.22);
3091-
e->SetTitle("Rejected Clusters");
3092-
e->GetXaxis()->SetTitle("Pad Row");
3093-
e->GetYaxis()->SetTitle("Rejected Clusters (fraction)");
3094-
e->Draw(k == 0 ? "" : "same");
3089+
auto* e = mClRejP;
3090+
if (GetHist(e, tin, k, nNewInput) == nullptr) {
3091+
continue;
30953092
}
3096-
mPClRejP->Print(Form("%s/clustersRejProjected.pdf", mConfig.plotsDir.c_str()));
3097-
if (mConfig.writeFileExt != "") {
3098-
mPClRejP->Print(Form("%s/clustersRejProjected.%s", mConfig.plotsDir.c_str(), mConfig.writeFileExt.c_str()));
3093+
e->Divide(proj2, proj1);
3094+
if (tout && !mConfig.inputHistogramsOnly && k == 0) {
3095+
e->Write();
30993096
}
3097+
delete proj1;
3098+
delete proj2;
3099+
e->SetMinimum(-0.02);
3100+
e->SetMaximum(0.22);
3101+
e->SetTitle("Rejected Clusters");
3102+
e->GetXaxis()->SetTitle("Pad Row");
3103+
e->GetYaxis()->SetTitle("Rejected Clusters (fraction)");
3104+
e->Draw(k == 0 ? "" : "same");
3105+
}
3106+
mPClRejP->Print(Form("%s/clustersRejProjected.pdf", mConfig.plotsDir.c_str()));
3107+
if (mConfig.writeFileExt != "") {
3108+
mPClRejP->Print(Form("%s/clustersRejProjected.%s", mConfig.plotsDir.c_str(), mConfig.writeFileExt.c_str()));
31003109
}
31013110
}
31023111

GPU/GPUTracking/qa/GPUQA.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,20 @@ class GPUQA
146146

147147
static constexpr int32_t MC_LABEL_INVALID = -1e9;
148148

149-
enum QA_TASKS {
149+
enum QA_TASKS { // TODO: make this in32_t typed
150150
taskTrackingEff = 1,
151151
taskTrackingRes = 2,
152152
taskTrackingResPull = 4,
153+
tasksAllMC = 8 - 1,
153154
taskClusterAttach = 8,
154155
taskTrackStatistics = 16,
155156
taskClusterCounts = 32,
156-
taskDefault = 63,
157-
taskDefaultPostprocess = 31,
158-
tasksNoQC = 56
157+
taskClusterRejection = 64,
158+
tasksAll = 128 - 1,
159+
tasksDefault = tasksAll,
160+
tasksDefaultPostprocess = tasksDefault & ~taskClusterCounts,
161+
tasksAllNoQC = tasksAll & ~tasksAllMC,
162+
tasksAutomatic = -1
159163
};
160164

161165
private:

GPU/Workflow/src/GPUWorkflowSpec.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void GPURecoWorkflowSpec::init(InitContext& ic)
180180
mConfig->configQA.shipToQC = true;
181181
if (!mConfig->configProcessing.runQA) {
182182
mConfig->configQA.enableLocalOutput = false;
183-
mQATaskMask = (mSpecConfig.processMC ? 15 : 0) | (mConfig->configQA.clusterRejectionHistograms ? 32 : 0);
183+
mQATaskMask = (mSpecConfig.processMC ? 15 : 0) | (mConfig->configQA.clusterRejectionHistograms ? 32 : 0); // TODO: Clean up using numeric flags!
184184
mConfig->configProcessing.runQA = -mQATaskMask;
185185
}
186186
}

0 commit comments

Comments
 (0)