Skip to content

Commit

Permalink
Match clusters/tracks in a common bin by pt
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed Sep 30, 2020
1 parent de7874c commit 94322db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion RecoHGCal/GraphReco/plugins/HGCClusterTrackLinker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ void HGCClusterTrackLinker::produce(edm::Event& iEvent, const edm::EventSetup& i
if (trackIndices.size()) {
// Find best match (just set to the first one for now)
// Can do closest in pt or mix of closest in pt and eta/phi
int tidx = 0;
std::vector<float> ptdiffs;
ptdiffs.reserve(trackIndices.size());
for (size_t entry : trackIndices) {
edm::RefToBase<reco::Track> t(tracks, entry);
ptdiffs.push_back(std::abs(t->pt()-cand.pt()));
}

size_t tidx = std::distance(ptdiffs.begin(), std::min_element(ptdiffs.begin(), ptdiffs.end()));
edm::RefToBase<reco::Track> matchingTrack(tracks, trackIndices.at(tidx));
trackIndices.erase(trackIndices.begin()+tidx);

Expand Down

0 comments on commit 94322db

Please sign in to comment.