Skip to content
Merged
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
35 changes: 32 additions & 3 deletions Modules/MUON/Common/src/TrackPlotter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,41 @@ void TrackPlotter::fillHistograms(const o2::globaltracking::RecoContainer& recoC
}
if (mSrc == GID::MFTMCH || mSrc == GID::MFTMCHMID) {
auto tracksFwd = recoCont.getGlobalFwdTracks();
for (auto& t : tracksFwd) {
MuonTrack mt(&t, recoCont, mFirstTForbit);
std::map<int64_t, std::vector<std::pair<int64_t, double>>> matchingCandidates;
// loop over the global forward tracks and collect the matching candidates
for (size_t ti = 0; ti < tracksFwd.size(); ti++) {
auto& t = tracksFwd[ti];
// skip tracks without MID if full matching is requested
if (mSrc == GID::MFTMCHMID && !mt.hasMID()) {
if (mSrc == GID::MFTMCHMID && t.getMIDTrackID() < 0) {
continue;
}

// associate the matching candidate to the corresponding MCH standalone track, and store the matching chi2
int64_t mchTrackIndex = t.getMCHTrackID();
double matchingChi2 = t.getMFTMCHMatchingChi2();
auto matchingCandidateIterator = matchingCandidates.find(mchTrackIndex);
if (matchingCandidateIterator != matchingCandidates.end()) {
matchingCandidateIterator->second.push_back(std::make_pair(ti, matchingChi2));
} else {
matchingCandidates[mchTrackIndex].push_back(std::make_pair(ti, matchingChi2));
}
}

// loop over the matching candidate for each standalone MCH track, sort the candidates according to the matching chi2,
// and for each MCH track pick the leading candidate for further processing
for (auto& [mchTrackIndex, matchingCandidatesVector] : matchingCandidates) {
if (matchingCandidates.empty()) {
continue;
}
Comment on lines +491 to +493
Copy link
Collaborator

@knopers8 knopers8 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not even reachable, but it looks harmless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this should never happen, but since below I am accessing the first element I prefer to be extra-safe.


// sort the vector of matching candidates in ascending order of the matching chi2
std::sort(matchingCandidatesVector.begin(), matchingCandidatesVector.end(),
[](const std::pair<int64_t, double>& t1, const std::pair<int64_t, double>& t2) -> bool {
return (t1.second < t2.second);
});

// store the leading candidate
auto& t = tracksFwd[matchingCandidatesVector[0].first];
mMuonTracks.emplace_back(std::make_pair<MuonTrack, bool>({ &t, recoCont, mFirstTForbit }, true));
}
}
Expand Down