Skip to content

Commit a7110bf

Browse files
committed
Adding MC mother information
A configurable has been added to the matching QA code that can be enabled to include mother PDG code information in the purity and efficiency histograms (making them TH2).
1 parent 38ec383 commit a7110bf

File tree

1 file changed

+104
-1
lines changed

1 file changed

+104
-1
lines changed

PWGDQ/Tasks/qaMatching.cxx

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ struct qaMatching {
151151
Configurable<std::string> fConfigGrpMagPath{"grpmagPath-", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
152152
} fConfigCCDB;
153153

154+
struct : ConfigurableGroup {
155+
Configurable<bool> fCreatePdgMomHistograms{"cfgCreatePdgMomHistograms", false, "create matching characteristics plots with particle mom PDG codes"};
156+
} fConfigQAs;
157+
154158
/// Variables for histograms configuration
155159
Configurable<int> fNCandidatesMax{"nCandidatesMax", 5, ""};
156160

@@ -297,12 +301,20 @@ struct qaMatching {
297301
struct EfficiencyPlotter {
298302
o2::framework::HistPtr p_num;
299303
o2::framework::HistPtr p_den;
304+
o2::framework::HistPtr p_pdg_num;
305+
o2::framework::HistPtr p_pdg_den;
300306
o2::framework::HistPtr pt_num;
301307
o2::framework::HistPtr pt_den;
308+
o2::framework::HistPtr pt_pdg_num;
309+
o2::framework::HistPtr pt_pdg_den;
302310
o2::framework::HistPtr phi_num;
303311
o2::framework::HistPtr phi_den;
312+
o2::framework::HistPtr phi_pdg_num;
313+
o2::framework::HistPtr phi_pdg_den;
304314
o2::framework::HistPtr eta_num;
305315
o2::framework::HistPtr eta_den;
316+
o2::framework::HistPtr eta_pdg_num;
317+
o2::framework::HistPtr eta_pdg_den;
306318

307319
EfficiencyPlotter(std::string path, std::string title,
308320
HistogramRegistry& registry)
@@ -311,6 +323,7 @@ struct qaMatching {
311323
AxisSpec pTAxis = {100, 0, 10, "p_{T} (GeV/c)"};
312324
AxisSpec etaAxis = {100, -4, -2, "#eta"};
313325
AxisSpec phiAxis = {90, -180, 180, "#phi (degrees)"};
326+
AxisSpec motherPDGAxis{1201, -600.5, 600.5, "Direct mother PDG"};
314327

315328
std::string histName;
316329
std::string histTitle;
@@ -324,6 +337,14 @@ struct qaMatching {
324337
histTitle = title + " vs. p - den";
325338
p_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {pAxis}});
326339

340+
histName = path + "p_pdg_num";
341+
histTitle = title + " vs. p vs pdg ID - num";
342+
p_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pAxis, motherPDGAxis}});
343+
344+
histName = path + "p_pdg_den";
345+
histTitle = title + " vs. p vs pdg ID - den";
346+
p_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pAxis, motherPDGAxis}});
347+
327348
// pT dependence
328349
histName = path + "pt_num";
329350
histTitle = title + " vs. p_{T} - num";
@@ -333,6 +354,14 @@ struct qaMatching {
333354
histTitle = title + " vs. p_{T} - den";
334355
pt_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {pTAxis}});
335356

357+
histName = path + "pt_pdg_num";
358+
histTitle = title + " vs. p_{T} vs pdg ID - num";
359+
pt_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pTAxis, motherPDGAxis}});
360+
361+
histName = path + "pt_pdg_den";
362+
histTitle = title + " vs. p_{T} vs pdg ID - den";
363+
pt_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pTAxis, motherPDGAxis}});
364+
336365
// eta dependence
337366
histName = path + "eta_num";
338367
histTitle = title + " vs. #eta - num";
@@ -342,6 +371,14 @@ struct qaMatching {
342371
histTitle = title + " vs. #eta - den";
343372
eta_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {etaAxis}});
344373

374+
histName = path + "eta_pdg_num";
375+
histTitle = title + " vs. #eta vs pdg ID - num";
376+
eta_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {etaAxis, motherPDGAxis}});
377+
378+
histName = path + "eta_pdg_den";
379+
histTitle = title + " vs. #eta vs pdg ID - den";
380+
eta_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {etaAxis, motherPDGAxis}});
381+
345382
// phi dependence
346383
histName = path + "phi_num";
347384
histTitle = title + " vs. #phi - num";
@@ -350,6 +387,14 @@ struct qaMatching {
350387
histName = path + "phi_den";
351388
histTitle = title + " vs. #phi - den";
352389
phi_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH1F, {phiAxis}});
390+
391+
histName = path + "phi_pdg_num";
392+
histTitle = title + " vs. #phi vs pdg ID - num";
393+
phi_pdg_num = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {phiAxis, motherPDGAxis}});
394+
395+
histName = path + "phi_pdg_den";
396+
histTitle = title + " vs. #phi vs pdg ID - den";
397+
phi_pdg_den = registry.add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {phiAxis, motherPDGAxis}});
353398
}
354399

355400
template <class T>
@@ -368,6 +413,24 @@ struct qaMatching {
368413
std::get<std::shared_ptr<TH1>>(phi_num)->Fill(phi);
369414
}
370415
}
416+
417+
// Study the PDG origin of particles and their effect on the purity score
418+
template <class T>
419+
void Fill(const T& track, int pdgCode, bool passed)
420+
{
421+
double phi = track.phi() * 180 / TMath::Pi();
422+
std::get<std::shared_ptr<TH2>>(p_pdg_den)->Fill(track.p(), pdgCode);
423+
std::get<std::shared_ptr<TH2>>(pt_pdg_den)->Fill(track.pt(), pdgCode);
424+
std::get<std::shared_ptr<TH2>>(eta_pdg_den)->Fill(track.eta(), pdgCode);
425+
std::get<std::shared_ptr<TH2>>(phi_pdg_den)->Fill(phi, pdgCode);
426+
427+
if (passed) {
428+
std::get<std::shared_ptr<TH2>>(p_pdg_num)->Fill(track.p(), pdgCode);
429+
std::get<std::shared_ptr<TH2>>(pt_pdg_num)->Fill(track.pt(), pdgCode);
430+
std::get<std::shared_ptr<TH2>>(eta_pdg_num)->Fill(track.eta(), pdgCode);
431+
std::get<std::shared_ptr<TH2>>(phi_pdg_num)->Fill(phi, pdgCode);
432+
}
433+
}
371434
};
372435

373436
struct MatchRankingHistos {
@@ -2066,10 +2129,26 @@ struct qaMatching {
20662129
// check if the matching candidate is a true one
20672130
bool isTrueMatch = IsTrueGlobalMatching(muonTrack, matchablePairs);
20682131

2069-
if (verbose)
2132+
// ---- MC ancestry ----
2133+
auto motherParticles = GetMotherParticles(muonTrack);
2134+
int motherPDG = 0;
2135+
if (motherParticles.size() > 1) {
2136+
motherPDG = motherParticles[1].first;
2137+
}
2138+
2139+
if (verbose) {
20702140
std::cout << std::format(" MCH track #{} -> Muon track #{}, isTrueMatch={}", mchIndex, globalTracksVector[0].globalTrackId, isTrueMatch) << std::endl;
2141+
std::cout << " MC ancestry (pdg): ";
2142+
for (auto const& [pdg, idx] : motherParticles) {
2143+
std::cout << "(" << pdg << ") ";
2144+
}
2145+
std::cout << std::endl;
2146+
}
20712147
// fill matching purity plots
20722148
plotter->fMatchingPurityPlotter.Fill(mchTrack, isTrueMatch);
2149+
if (fConfigQAs.fCreatePdgMomHistograms) {
2150+
plotter->fMatchingPurityPlotter.Fill(mchTrack, motherPDG, isTrueMatch);
2151+
}
20732152
}
20742153

20752154
// ====================================
@@ -2105,10 +2184,34 @@ struct qaMatching {
21052184
}
21062185
}
21072186

2187+
// ---- MC ancestry ----
2188+
auto motherParticles = GetMotherParticles(mchTrack);
2189+
int motherPDG = 0;
2190+
if (motherParticles.size() > 1) {
2191+
motherPDG = motherParticles[1].first;
2192+
}
2193+
2194+
if (verbose) {
2195+
std::cout << " MC ancestry (pdg): ";
2196+
for (auto const& [pdg, idx] : motherParticles) {
2197+
std::cout << "(" << pdg << ") ";
2198+
}
2199+
std::cout << std::endl;
2200+
}
2201+
21082202
// fill matching efficiency plots
21092203
plotter->fPairingEfficiencyPlotter.Fill(mchTrack, goodMatchFound);
2204+
if (fConfigQAs.fCreatePdgMomHistograms) {
2205+
plotter->fPairingEfficiencyPlotter.Fill(mchTrack, motherPDG, goodMatchFound);
2206+
}
21102207
plotter->fMatchingEfficiencyPlotter.Fill(mchTrack, (goodMatchFound && isTrueMatch));
2208+
if (fConfigQAs.fCreatePdgMomHistograms) {
2209+
plotter->fMatchingEfficiencyPlotter.Fill(mchTrack, motherPDG, (goodMatchFound && isTrueMatch));
2210+
}
21112211
plotter->fFakeMatchingEfficiencyPlotter.Fill(mchTrack, (goodMatchFound && !isTrueMatch));
2212+
if (fConfigQAs.fCreatePdgMomHistograms) {
2213+
plotter->fFakeMatchingEfficiencyPlotter.Fill(mchTrack, motherPDG, (goodMatchFound && !isTrueMatch));
2214+
}
21122215
}
21132216
}
21142217

0 commit comments

Comments
 (0)