Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions PWGDQ/Tasks/mftMchMatcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@
DECLARE_SOA_COLUMN(Chi2Glob, chi2Glob, float);
DECLARE_SOA_COLUMN(Chi2Match, chi2Match, float);
DECLARE_SOA_COLUMN(IsAmbig, isAmbig, bool);
DECLARE_SOA_COLUMN(MFTMult, mftMult, int);

Check failure on line 145 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(DCAX, dcaX, float);

Check failure on line 146 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(DCAY, dcaY, float);

Check failure on line 147 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(McMaskGlob, mcMaskGlob, int);
DECLARE_SOA_COLUMN(MatchLabel, matchLabel, int);
DECLARE_SOA_COLUMN(IsSignal, isSignal, bool);
Expand Down Expand Up @@ -302,7 +302,7 @@
double p = mchTrackAtVertex.p();

double pDCA = mchTrack.pDca();
double sigmaPDCA = (thetaAbs < 3) ? sigmaPDCA23 : sigmaPDCA310;

Check failure on line 305 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
double nrp = nSigmaPDCA * relPRes * p;
double pResEffect = sigmaPDCA / (1. - nrp / (1. + nrp));
double slopeResEffect = 535. * slopeRes * p;
Expand Down Expand Up @@ -438,7 +438,7 @@
fBestMatch.clear();
std::unordered_map<int, std::pair<float, int>> mCandidates;
for (const auto& muon : muons) {
if (static_cast<int>(muon.trackType()) < 2) {

Check failure on line 441 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
auto muonID = muon.matchMCHTrackId();
auto chi2 = muon.chi2MatchMCHMFT();
if (mCandidates.find(muonID) == mCandidates.end()) {
Expand All @@ -450,7 +450,7 @@
}
}
}
for (auto& pairCand : mCandidates) {

Check failure on line 453 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
fBestMatch[pairCand.second.second] = true;
}
}
Expand All @@ -460,12 +460,10 @@
TMFT const& mftTracks,
std::vector<std::pair<int64_t, int64_t>>& matchablePairs)
{
static constexpr int muonPdgCode = 13;

// outer loop on muon tracks
for (const auto& muonTrack : muonTracks) {
// only consider MCH standalone or MCH-MID matches
if (static_cast<int>(muonTrack.trackType()) <= 2) {

Check failure on line 466 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
continue;
}

Expand All @@ -473,31 +471,18 @@
if (!muonTrack.has_collision()) {
continue;
}
auto muonCollisionId = muonTrack.collisionId();

// skip tracks that do not have an associated MC particle
if (!muonTrack.has_mcParticle()) {
continue;
}
// get the index associated to the MC particle
auto muonMcParticle = muonTrack.mcParticle();
if (std::abs(muonMcParticle.pdgCode()) != muonPdgCode) {
continue;
}

int64_t muonMcTrackIndex = muonMcParticle.globalIndex();

// inner loop on MFT tracks
for (const auto& mftTrack : mftTracks) {
// only consider MFT tracks associated to the same collision as the muon track
if (!mftTrack.has_collision()) {
continue;
}
auto mftCollisionId = mftTrack.collisionId();
if (mftCollisionId != muonCollisionId) {
continue;
}

// skip tracks that do not have an associated MC particle
if (!mftTrack.has_mcParticle()) {
continue;
Expand Down Expand Up @@ -557,7 +542,7 @@
{
MuonMatchType result{kMatchTypeUndefined};

if (static_cast<int>(muonTrack.trackType()) > 2) {

Check failure on line 545 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return result;
}

Expand Down Expand Up @@ -618,13 +603,13 @@
fillMatchablePairs(muonTracks, mftTracks, matchablePairs);

mftCovIndexes.clear();
for (auto& mftTrackCov : mftCovs) {

Check failure on line 606 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
mftCovIndexes[mftTrackCov.matchMFTTrackId()] = mftTrackCov.globalIndex();
}

fwdMatchMLCandidates.reserve(muonTracks.size());

for (auto muon : muonTracks) {

Check failure on line 612 in PWGDQ/Tasks/mftMchMatcher.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
// only consider global MFT-MCH-MID matches
if (static_cast<int>(muon.trackType()) != 0) {
continue;
Expand Down
34 changes: 20 additions & 14 deletions PWGDQ/Tasks/qaMatching.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ struct QaMatching {
//-
AxisSpec chi2Axis = {100, 0, 100, "matching #chi^{2}/NDF"};
AxisSpec scoreAxis = {100, 0, 1, "matching score"};
int matchTypeMax = static_cast<int>(kMatchTypeUndefined);
int matchTypeMax = static_cast<int>(kMatchTypeUndefined) + 1;
AxisSpec matchTypeAxis = {matchTypeMax, 0, static_cast<double>(matchTypeMax), "match type"};
histName = path + "matchType";
histTitle = "Match type";
Expand All @@ -786,6 +786,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH1>>(fMatchType)->GetXaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH1>>(fMatchType)->GetXaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH1>>(fMatchType)->GetXaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH1>>(fMatchType)->GetXaxis()->SetBinLabel(9, "undefined");
histName = path + "matchTypeVsP";
histTitle = "Match type vs. p";
fMatchTypeVsP = registry->add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {pAxis, matchTypeAxis}});
Expand All @@ -797,6 +798,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH2>>(fMatchTypeVsP)->GetYaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchTypeVsP)->GetYaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchTypeVsP)->GetYaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchTypeVsP)->GetYaxis()->SetBinLabel(9, "undefined");
histName = path + "matchTypeVsPt";
histTitle = "Match type vs. p_{T}";
fMatchTypeVsPt = registry->add(histName.c_str(), histTitle.c_str(), {HistType::kTH2F, {ptAxis, matchTypeAxis}});
Expand All @@ -808,6 +810,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH2>>(fMatchTypeVsPt)->GetYaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchTypeVsPt)->GetYaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchTypeVsPt)->GetYaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchTypeVsPt)->GetYaxis()->SetBinLabel(9, "undefined");

histName = path + "matchChi2VsType";
histTitle = "Match #chi^{2} vs. match type";
Expand All @@ -820,6 +823,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH2>>(fMatchChi2VsType)->GetXaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchChi2VsType)->GetXaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchChi2VsType)->GetXaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchChi2VsType)->GetXaxis()->SetBinLabel(9, "undefined");
histName = path + "matchChi2VsTypeVsP";
histTitle = "Match #chi^{2} vs. match type vs. p";
fMatchChi2VsTypeVsP = registry->add(histName.c_str(), histTitle.c_str(), {HistType::kTH3F, {pAxis, matchTypeAxis, chi2Axis}});
Expand All @@ -831,6 +835,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsP)->GetYaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsP)->GetYaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsP)->GetYaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsP)->GetYaxis()->SetBinLabel(9, "undefined");
histName = path + "matchChi2VsTypeVsPt";
histTitle = "Match #chi^{2} vs. match type vs. p_{T}";
fMatchChi2VsTypeVsPt = registry->add(histName.c_str(), histTitle.c_str(), {HistType::kTH3F, {ptAxis, matchTypeAxis, chi2Axis}});
Expand All @@ -842,6 +847,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsPt)->GetYaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsPt)->GetYaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsPt)->GetYaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchChi2VsTypeVsPt)->GetYaxis()->SetBinLabel(9, "undefined");
//-
histName = path + "matchScoreVsType";
histTitle = "Match score vs. match type";
Expand All @@ -854,6 +860,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH2>>(fMatchScoreVsType)->GetXaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchScoreVsType)->GetXaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchScoreVsType)->GetXaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH2>>(fMatchScoreVsType)->GetXaxis()->SetBinLabel(9, "undefined");
histName = path + "matchScoreVsTypeVsP";
histTitle = "Match score vs. match type vs. p";
fMatchScoreVsTypeVsP = registry->add(histName.c_str(), histTitle.c_str(), {HistType::kTH3F, {pAxis, matchTypeAxis, scoreAxis}});
Expand All @@ -865,6 +872,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsP)->GetYaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsP)->GetYaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsP)->GetYaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsP)->GetYaxis()->SetBinLabel(9, "undefined");
histName = path + "matchScoreVsTypeVsPt";
histTitle = "Match score vs. match type vs. p_{T}";
fMatchScoreVsTypeVsPt = registry->add(histName.c_str(), histTitle.c_str(), {HistType::kTH3F, {ptAxis, matchTypeAxis, scoreAxis}});
Expand All @@ -876,6 +884,7 @@ struct QaMatching {
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsPt)->GetYaxis()->SetBinLabel(6, "wrong (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsPt)->GetYaxis()->SetBinLabel(7, "decay (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsPt)->GetYaxis()->SetBinLabel(8, "fake (non leading)");
std::get<std::shared_ptr<TH3>>(fMatchScoreVsTypeVsPt)->GetYaxis()->SetBinLabel(9, "undefined");

AxisSpec prodScoreAxis = {100, 0, 1, "matching score (prod)"};
histName = path + "matchScoreVsProd";
Expand Down Expand Up @@ -1673,8 +1682,6 @@ struct QaMatching {
continue;
// get the index associated to the MC particle
auto muonMcParticle = muonTrack.mcParticle();
if (std::abs(muonMcParticle.pdgCode()) != kMuonMinus)
continue;

int64_t muonMcTrackIndex = muonMcParticle.globalIndex();

Expand Down Expand Up @@ -1741,8 +1748,7 @@ struct QaMatching {
TMUONS const& /*muonTracks*/,
TMFTS const& /*mftTracks*/)
{
static constexpr int maxGlobalFwdTrackType = 2;
if (static_cast<int>(muonTrack.trackType()) >= maxGlobalFwdTrackType)
if (static_cast<int>(muonTrack.trackType()) >= GlobalTrackTypeMax)
return false;

auto const& mchTrack = muonTrack.template matchMCHTrack_as<TMUONS>();
Expand Down Expand Up @@ -1995,7 +2001,7 @@ struct QaMatching {
if (collisionIds.empty())
return;

for (size_t cid = 1; cid < collisionIds.size() - 1; cid++) {
for (size_t cid = 0; cid < collisionIds.size(); cid++) {
const auto& collision = collisions.rawIteratorAt(collisionIds[cid]);
int64_t collisionIndex = collision.globalIndex();
auto bc = bcs.rawIteratorAt(collision.bcId());
Expand Down Expand Up @@ -2088,17 +2094,17 @@ struct QaMatching {
}
}

// sort the vectors of matching candidates in ascending order based on the matching score value
auto compareMatchingScore = [](const MatchingCandidate& track1, const MatchingCandidate& track2) -> bool {
return (track1.matchScore > track2.matchScore);
// sort the vectors of matching candidates in ascending order based on the matching chi2 value
auto compareMatchingChi2 = [](const MatchingCandidate& track1, const MatchingCandidate& track2) -> bool {
return (track1.matchChi2 < track2.matchChi2);
};

for (auto collisionInfoIt = collisionInfos.begin(); collisionInfoIt != collisionInfos.end(); ++collisionInfoIt) {
auto& collisionInfo = collisionInfoIt->second;
for (auto matchingCandidatesIt = collisionInfo.matchingCandidates.begin(); matchingCandidatesIt != collisionInfo.matchingCandidates.end(); ++matchingCandidatesIt) {
auto& mchIndex = matchingCandidatesIt->first;
auto& globalTracksVector = matchingCandidatesIt->second;
std::sort(globalTracksVector.begin(), globalTracksVector.end(), compareMatchingScore);
std::sort(globalTracksVector.begin(), globalTracksVector.end(), compareMatchingChi2);

const auto& mchTrack = muonTracks.rawIteratorAt(mchIndex);
auto mftMchMatchAttempts = getMftMchMatchAttempts(collisions, bcs, mchTrack, mftTracks);
Expand Down Expand Up @@ -2620,15 +2626,15 @@ struct QaMatching {
}
}

// sort the vectors of matching candidates in ascending order based on the matching score value
auto compareMatchingScore = [](const MatchingCandidate& track1, const MatchingCandidate& track2) -> bool {
return (track1.matchScore > track2.matchScore);
// sort the vectors of matching candidates in ascending order based on the matching chi2 value
auto compareMatchingChi2 = [](const MatchingCandidate& track1, const MatchingCandidate& track2) -> bool {
return (track1.matchChi2 < track2.matchChi2);
};

for (auto matchingCandidatesIt = newMatchingCandidates.begin(); matchingCandidatesIt != newMatchingCandidates.end(); ++matchingCandidatesIt) {
auto& mchIndex = matchingCandidatesIt->first;
auto& globalTracksVector = matchingCandidatesIt->second;
std::sort(globalTracksVector.begin(), globalTracksVector.end(), compareMatchingScore);
std::sort(globalTracksVector.begin(), globalTracksVector.end(), compareMatchingChi2);

const auto& mchTrack = muonTracks.rawIteratorAt(mchIndex);
auto mftMchMatchAttempts = getMftMchMatchAttempts(collisions, bcs, mchTrack, mftTracks);
Expand Down
Loading