From bddb6d01a723d560e21b05835c6fafda2f746621 Mon Sep 17 00:00:00 2001 From: MaolinZH <109225729+MaolinZH@users.noreply.github.com> Date: Wed, 8 Apr 2026 15:42:58 +0200 Subject: [PATCH 1/5] Update taskSingleMuonSource.cxx Add new classification for the like-sign pairs --- PWGHF/HFL/Tasks/taskSingleMuonSource.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx index aea4ee26bea..4acbace69be 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx @@ -125,9 +125,11 @@ struct HfTaskSingleMuonSource { registry.add("h1MuBeforeCuts", "", h1Pt); registry.add("h1MuonMass", "", h1Mass); registry.add("h1BeautyMass", "", h1Mass); + registry.add("h1CorrBeautyMass", "", h1Mass); registry.add("h1OtherMass", "", h1Mass); registry.add("h1MuonMassGen", "", h1Mass); registry.add("h1BeautyMassGen", "", h1Mass); + registry.add("h1CorrBeautyMassGen", "", h1Mass); registry.add("h1OtherMassGen", "", h1Mass); for (const auto& src : muonSources) { registry.add(Form("h1%sPt", src.Data()), "", h1Pt); @@ -436,9 +438,13 @@ struct HfTaskSingleMuonSource { registry.fill(HIST("h1MuonMass"), InvM); registry.fill(HIST("h1MuonMassGen"), InvMGen); } - if (Corr(muon, muon2, mcParts) && isBeautyMu(mask1) && isBeautyMu(mask2)) { + if (isBeautyMu(mask1) && isBeautyMu(mask2)) { registry.fill(HIST("h1BeautyMass"), InvM); registry.fill(HIST("h1BeautyMassGen"), InvMGen); + if (Corr(muon, muon2, mcParts)) { + registry.fill(HIST("h1CorrBeautyMass"), InvM); + registry.fill(HIST("h1CorrBeautyMassGen"), InvMGen); + } } else { registry.fill(HIST("h1OtherMass"), InvM); registry.fill(HIST("h1OtherMassGen"), InvMGen); From 97a764aa83d2e5cece544dd227a908b1c8858e95 Mon Sep 17 00:00:00 2001 From: MaolinZH <109225729+MaolinZH@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:19:56 +0200 Subject: [PATCH 2/5] Fix the O2linter errors --- PWGHF/HFL/Tasks/taskSingleMuonSource.cxx | 68 ++++++++++++++---------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx index 4acbace69be..70e6f2a70b6 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx @@ -26,9 +26,9 @@ #include #include #include +#include #include -#include #include #include @@ -78,6 +78,8 @@ struct HfTaskSingleMuonSource { Configurable charge{"charge", 0, "Muon track charge, validated values are 0, 1 and -1, 0 represents both 1 and -1"}; Configurable pairSource{"pairSource", true, "check also the source of like-sign muon pairs"}; + Service pdgDB; + double pDcaMax = 594.0; // p*DCA maximum value for small Rab double pDcaMax2 = 324.0; // p*DCA maximum value for large Rabs double rAbsMid = 26.5; // R at absorber end minimum value @@ -87,6 +89,9 @@ struct HfTaskSingleMuonSource { double etaUp = -2.5; // up edge of eta acceptance double edgeZ = 10.0; // edge of event position Z double ptLow = 1.0; // low edge of pT for muon pairs + int pdgLow = 10; // low edge of pdgCode for particle separation + int pdgMid = 1000; // intermediate edge of pdgCode for particle separation + int pdgHigh = 10000; // up edge of pdgCode for particle separation HistogramRegistry registry{ "registry", @@ -116,7 +121,7 @@ struct HfTaskSingleMuonSource { HistogramConfigSpec const h1ColNumber{HistType::kTH1F, {axisColNumber}}; HistogramConfigSpec const h1Pt{HistType::kTH1F, {axisPt}}; - HistogramConfigSpec h1Mass{HistType::kTH1F, {axisMass}}; + HistogramConfigSpec const h1Mass{HistType::kTH1F, {axisMass}}; HistogramConfigSpec const h2PtDCA{HistType::kTH2F, {axisPt, axisDCA}}; HistogramConfigSpec const h2PtChi2{HistType::kTH2F, {axisPt, axisChi2}}; HistogramConfigSpec const h2PtDeltaPt{HistType::kTH2F, {axisPt, axisDeltaPt}}; @@ -161,7 +166,7 @@ struct HfTaskSingleMuonSource { mcPart = *(mcPart.mothers_first_as()); const auto pdgAbs(std::abs(mcPart.pdgCode())); - if (pdgAbs < 10 || pdgAbs == 21) { + if (pdgAbs < kElectron || pdgAbs == kGluon) { break; // Quark and gluon } @@ -170,8 +175,7 @@ struct HfTaskSingleMuonSource { continue; } - if (pdgAbs == kTauMinus) { - // Tau + if (pdgAbs == kTauMinus) { // Tau SETBIT(mask, HasTauParent); continue; } @@ -182,28 +186,27 @@ struct HfTaskSingleMuonSource { continue; } // Beam particle - if ((pdgRem < 100) || (pdgRem >= 10000)) { + if ((pdgRem < pdgLow) || (pdgRem >= pdgHigh)) { continue; } - if ((pdgRem % 100 == 1 || pdgRem % 100 == 3) && pdgRem > 1000) { // diquarks + if ((pdgRem % 100 == kDown || pdgRem % 100 == kStrange) && pdgRem > pdgMid) { // diquarks continue; } // compute the flavor of constituent quark const int flv(pdgRem / std::pow(10, static_cast(std::log10(pdgRem)))); - if (flv > 6) { + if (flv > kTop) { // no more than 6 flavors continue; } - if (flv < 4) { + if (flv < kCharm) { // light flavor SETBIT(mask, HasLightParent); continue; } - - auto* pdgData(TDatabasePDG::Instance()->GetParticle(mcPart.pdgCode())); + auto* pdgData = pdgDB->GetParticle(mcPart.pdgCode()); if ((pdgData != nullptr) && (pdgData->AntiParticle() == nullptr)) { SETBIT(mask, HasQuarkoniumParent); - } else if (flv == 4) { + } else if (flv == kCharm) { SETBIT(mask, HasCharmParent); } else { SETBIT(mask, HasBeautyParent); @@ -276,11 +279,13 @@ struct HfTaskSingleMuonSource { // fill the histograms of each particle types void fillHistograms(const McMuons::iterator& muon) { + const int type0 = 0; + const int type2 = 2; const auto mask(getMask(muon)); const auto pt(muon.pt()), chi2(muon.chi2MatchMCHMFT()); const auto dca(RecoDecay::sqrtSumOfSquares(muon.fwdDcaX(), muon.fwdDcaY())); - if (trackType == 0 || trackType == 2) { + if (trackType == type0 || trackType == type2) { if (!muon.has_matchMCHTrack()) { return; } @@ -346,6 +351,7 @@ struct HfTaskSingleMuonSource { int traceAncestor(const McMuons::iterator& muon, aod::McParticles const& mctracks) { int mcNum = 0; + const int hadronStatus = 80; if (!muon.has_mcParticle()) { return 0; } @@ -355,30 +361,32 @@ struct HfTaskSingleMuonSource { } while (mcPart.has_mothers()) { // the first hadron after hadronization auto mother = mcPart.mothers_first_as(); - if (std::abs(mother.getGenStatusCode()) < 80) { + if (std::abs(mother.getGenStatusCode()) < hadronStatus) { break; } mcPart = mother; } int flv = mcPart.pdgCode() / std::pow(10, static_cast(std::log10(std::abs(mcPart.pdgCode())))); - if (abs(flv) == 5 && mcPart.pdgCode() < 1000) + if (std::abs(flv) == kBottom && mcPart.pdgCode() < pdgMid) { flv = -flv; + } for (int i = (mcPart.mothers_first_as()).globalIndex(); i <= (mcPart.mothers_last_as()).globalIndex(); i++) { // loop over the lund string - for (auto mctrack : mctracks) { + for (const auto& mctrack : mctracks) { if (mctrack.globalIndex() != i) { continue; } - if ((mctrack.pdgCode() != flv) && (abs(mctrack.pdgCode()) < abs(flv) * 1000)) { + if ((mctrack.pdgCode() != flv) && (std::abs(mctrack.pdgCode()) < std::abs(flv) * 1000)) { continue; } - while (mctrack.has_mothers()) { - int motherflv = (mctrack.mothers_first_as()).pdgCode() / std::pow(10, static_cast(std::log10(abs((mctrack.mothers_first_as()).pdgCode())))); // find the mother with same flavor - auto mother = (abs(motherflv) == abs(flv)) ? (mctrack.mothers_first_as()) : (mctrack.mothers_last_as()); - if ((mother.pdgCode() != mctrack.pdgCode()) && (abs(mctrack.pdgCode()) < 10)) { // both mother is not the the quark with same flavor - mcNum = mctrack.globalIndex(); + auto currentTrk = mctrack; + while (currentTrk.has_mothers()) { + int motherflv = (currentTrk.mothers_first_as()).pdgCode() / std::pow(10, static_cast(std::log10(std::abs((currentTrk.mothers_first_as()).pdgCode())))); // find the mother with same flavor + auto mother = (std::abs(motherflv) == std::abs(flv)) ? (currentTrk.mothers_first_as()) : (currentTrk.mothers_last_as()); + if ((mother.pdgCode() != currentTrk.pdgCode()) && (std::abs(currentTrk.pdgCode()) < kElectron)) { // both mother is not the the quark with same flavor + mcNum = currentTrk.globalIndex(); return mcNum; } - mctrack = mother; + currentTrk = mother; } } } @@ -393,7 +401,7 @@ struct HfTaskSingleMuonSource { if (anc1 == 0 || anc2 == 0) { return false; } - for (auto mcPart : mcParts) { + for (const auto& mcPart : mcParts) { if (mcPart.globalIndex() == anc1) { moth11 = (mcPart.mothers_first_as()).globalIndex(); moth12 = (mcPart.mothers_last_as()).globalIndex(); @@ -410,7 +418,8 @@ struct HfTaskSingleMuonSource { } void fillPairs(const McMuons::iterator& muon, const McMuons::iterator& muon2, aod::McParticles const& mcParts) { - if (trackType != 3) { + const int type3 = 3; + if (trackType != type3) { return; } float mm = o2::constants::physics::MassMuon; @@ -483,7 +492,10 @@ struct HfTaskSingleMuonSource { continue; } } - if ((muon.chi2() >= 1e6) || (muon.chi2() < 0)) { + if (muon.chi2() < 0) { + continue; + } + if (muon.chi2MatchMCHMID() < 0) { continue; } if (charge != 0 && muon.sign() != charge) { @@ -523,10 +535,10 @@ struct HfTaskSingleMuonSource { } } - if ((muon2.chi2() >= 1e6) || (muon2.chi2() < 0)) { + if (muon2.chi2() < 0) { continue; } - if ((muon2.chi2MatchMCHMID() >= 1e6) || (muon2.chi2MatchMCHMID() < 0)) { + if (muon2.chi2MatchMCHMID() < 0) { continue; } fillPairs(muon, muon2, mcParts); From 857c66c0ea699592ce6caa451312b3dd0e0d5850 Mon Sep 17 00:00:00 2001 From: MaolinZH <109225729+MaolinZH@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:47:08 +0200 Subject: [PATCH 3/5] Remove magic numbers to fix the O2Linter --- PWGHF/HFL/Tasks/taskSingleMuonSource.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx index 70e6f2a70b6..62710329c04 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx @@ -89,9 +89,6 @@ struct HfTaskSingleMuonSource { double etaUp = -2.5; // up edge of eta acceptance double edgeZ = 10.0; // edge of event position Z double ptLow = 1.0; // low edge of pT for muon pairs - int pdgLow = 10; // low edge of pdgCode for particle separation - int pdgMid = 1000; // intermediate edge of pdgCode for particle separation - int pdgHigh = 10000; // up edge of pdgCode for particle separation HistogramRegistry registry{ "registry", @@ -148,6 +145,8 @@ struct HfTaskSingleMuonSource { uint8_t getMask(const McMuons::iterator& muon) { uint8_t mask(0); + const int diquarkEdge = 1000; + const int hadronEdge = 10000; if (muon.has_mcParticle()) { SETBIT(mask, IsIdentified); } else { @@ -186,10 +185,10 @@ struct HfTaskSingleMuonSource { continue; } // Beam particle - if ((pdgRem < pdgLow) || (pdgRem >= pdgHigh)) { + if ((pdgRem < kPi0) || (pdgRem >= hadronEdge)) { continue; } - if ((pdgRem % 100 == kDown || pdgRem % 100 == kStrange) && pdgRem > pdgMid) { // diquarks + if ((pdgRem % 100 == kDown || pdgRem % 100 == kStrange) && pdgRem > diquarkEdge) { // diquarks continue; } // compute the flavor of constituent quark @@ -352,6 +351,7 @@ struct HfTaskSingleMuonSource { { int mcNum = 0; const int hadronStatus = 80; + const int diquarkEdge = 1000; if (!muon.has_mcParticle()) { return 0; } @@ -367,7 +367,7 @@ struct HfTaskSingleMuonSource { mcPart = mother; } int flv = mcPart.pdgCode() / std::pow(10, static_cast(std::log10(std::abs(mcPart.pdgCode())))); - if (std::abs(flv) == kBottom && mcPart.pdgCode() < pdgMid) { + if (std::abs(flv) == kBottom && mcPart.pdgCode() < diquarkEdge) { flv = -flv; } for (int i = (mcPart.mothers_first_as()).globalIndex(); i <= (mcPart.mothers_last_as()).globalIndex(); i++) { // loop over the lund string From aa94fd93eb530447cb6592aec077bf5f40784eb6 Mon Sep 17 00:00:00 2001 From: MaolinZH <109225729+MaolinZH@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:53:07 +0200 Subject: [PATCH 4/5] Fix the headerfile format and last magic number --- PWGHF/HFL/Tasks/taskSingleMuonSource.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx index 62710329c04..10b6ea52a23 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx @@ -24,9 +24,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -180,6 +180,7 @@ struct HfTaskSingleMuonSource { } const int pdgRem(pdgAbs % 100000); + const int pdgRemRem(pdgRem % 100); if (pdgRem == kProton) { continue; @@ -188,7 +189,7 @@ struct HfTaskSingleMuonSource { if ((pdgRem < kPi0) || (pdgRem >= hadronEdge)) { continue; } - if ((pdgRem % 100 == kDown || pdgRem % 100 == kStrange) && pdgRem > diquarkEdge) { // diquarks + if ((pdgRemRem == kDown || pdgRemRem == kStrange) && pdgRem > diquarkEdge) { // diquarks continue; } // compute the flavor of constituent quark From 69edf1e97588534ab1d91b228116b2593ab6db27 Mon Sep 17 00:00:00 2001 From: MaolinZH <109225729+MaolinZH@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:42:55 +0200 Subject: [PATCH 5/5] Fix the O2linter warnings --- PWGHF/HFL/Tasks/taskSingleMuonSource.cxx | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx index 10b6ea52a23..e2d209966dc 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuonSource.cxx @@ -8,10 +8,10 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// -// \file taskSingleMuonSource.cxx -// \brief Task used to seperate single muons source in Monte Carlo simulation. -// \author Maolin Zhang , CCNU +/// +/// \file taskSingleMuonSource.cxx +/// \brief Task used to seperate single muons source in Monte Carlo simulation. +/// \author Maolin Zhang , CCNU #include "Common/Core/RecoDecay.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -393,7 +393,7 @@ struct HfTaskSingleMuonSource { } return 0; } - bool Corr(const McMuons::iterator& muon1, const McMuons::iterator& muon2, aod::McParticles const& mcParts) + bool isCorr(const McMuons::iterator& muon1, const McMuons::iterator& muon2, aod::McParticles const& mcParts) { int moth11(0), moth12(0), moth21(1), moth22(1); @@ -431,7 +431,7 @@ struct HfTaskSingleMuonSource { ROOT::Math::PtEtaPhiMVector mu1Vec(muon.pt(), muon.eta(), muon.phi(), mm); ROOT::Math::PtEtaPhiMVector mu2Vec(muon2.pt(), muon2.eta(), muon2.phi(), mm); ROOT::Math::PtEtaPhiMVector dimuVec = mu1Vec + mu2Vec; - auto InvM = dimuVec.M(); + auto invMass = dimuVec.M(); if (!muon.has_mcParticle() || !muon2.has_mcParticle()) { return; @@ -442,22 +442,22 @@ struct HfTaskSingleMuonSource { ROOT::Math::PtEtaPhiMVector mu1VecGen(mcPart1.pt(), mcPart1.eta(), mcPart1.phi(), mm); ROOT::Math::PtEtaPhiMVector mu2VecGen(mcPart2.pt(), mcPart2.eta(), mcPart2.phi(), mm); ROOT::Math::PtEtaPhiMVector dimuVecGen = mu1VecGen + mu2VecGen; - auto InvMGen = dimuVecGen.M(); + auto invMassGen = dimuVecGen.M(); if (isMuon(mask1) && isMuon(mask2)) { - registry.fill(HIST("h1MuonMass"), InvM); - registry.fill(HIST("h1MuonMassGen"), InvMGen); + registry.fill(HIST("h1MuonMass"), invMass); + registry.fill(HIST("h1MuonMassGen"), invMassGen); } if (isBeautyMu(mask1) && isBeautyMu(mask2)) { - registry.fill(HIST("h1BeautyMass"), InvM); - registry.fill(HIST("h1BeautyMassGen"), InvMGen); - if (Corr(muon, muon2, mcParts)) { - registry.fill(HIST("h1CorrBeautyMass"), InvM); - registry.fill(HIST("h1CorrBeautyMassGen"), InvMGen); + registry.fill(HIST("h1BeautyMass"), invMass); + registry.fill(HIST("h1BeautyMassGen"), invMassGen); + if (isCorr(muon, muon2, mcParts)) { + registry.fill(HIST("h1CorrBeautyMass"), invMass); + registry.fill(HIST("h1CorrBeautyMassGen"), invMassGen); } } else { - registry.fill(HIST("h1OtherMass"), InvM); - registry.fill(HIST("h1OtherMassGen"), InvMGen); + registry.fill(HIST("h1OtherMass"), invMass); + registry.fill(HIST("h1OtherMassGen"), invMassGen); } }