Skip to content

Commit

Permalink
Merge pull request #45846 from stahlleiton/UParT_PtSort_CMSSW_13_2_X
Browse files Browse the repository at this point in the history
[13_2_X] Add option to sort candidates by pT in Unified Particle Transformer
  • Loading branch information
cmsbuild authored Sep 10, 2024
2 parents 3dd9b7b + 6b0858f commit 88fe605
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class UnifiedParticleTransformerAK4TagInfoProducer : public edm::stream::EDProdu
const double jet_radius_;
const double min_candidate_pt_;
const bool flip_;
const bool sort_cand_by_pt_;

const edm::EDGetTokenT<edm::View<reco::Jet>> jet_token_;
const edm::EDGetTokenT<VertexCollection> vtx_token_;
Expand Down Expand Up @@ -108,6 +109,7 @@ UnifiedParticleTransformerAK4TagInfoProducer::UnifiedParticleTransformerAK4TagIn
: jet_radius_(iConfig.getParameter<double>("jet_radius")),
min_candidate_pt_(iConfig.getParameter<double>("min_candidate_pt")),
flip_(iConfig.getParameter<bool>("flip")),
sort_cand_by_pt_(iConfig.getParameter<bool>("sort_cand_by_pt")),
jet_token_(consumes<edm::View<reco::Jet>>(iConfig.getParameter<edm::InputTag>("jets"))),
vtx_token_(consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
lt_token_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("losttracks"))),
Expand Down Expand Up @@ -154,6 +156,7 @@ void UnifiedParticleTransformerAK4TagInfoProducer::fillDescriptions(edm::Configu
desc.add<double>("jet_radius", 0.4);
desc.add<double>("min_candidate_pt", 0.10);
desc.add<bool>("flip", false);
desc.add<bool>("sort_cand_by_pt", false);
desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
desc.add<edm::InputTag>("losttracks", edm::InputTag("lostTracks"));
desc.add<edm::InputTag>("puppi_value_map", edm::InputTag("puppi"));
Expand Down Expand Up @@ -275,10 +278,16 @@ void UnifiedParticleTransformerAK4TagInfoProducer::produce(edm::Event& iEvent, c
auto& trackinfo = lt_trackinfos.emplace(i, track_builder).first->second;
trackinfo.buildTrackInfo(PackedCandidate_, jet_dir, jet_ref_track_dir, pv);

lt_sorted.emplace_back(i,
trackinfo.getTrackSip2dSig(),
-btagbtvdeep::mindrsvpfcand(svs_unsorted, PackedCandidate_),
PackedCandidate_->pt() / jet.pt());
if (sort_cand_by_pt_)
lt_sorted.emplace_back(i,
PackedCandidate_->pt() / jet.pt(),
trackinfo.getTrackSip2dSig(),
-btagbtvdeep::mindrsvpfcand(svs_unsorted, PackedCandidate_));
else
lt_sorted.emplace_back(i,
trackinfo.getTrackSip2dSig(),
-btagbtvdeep::mindrsvpfcand(svs_unsorted, PackedCandidate_),
PackedCandidate_->pt() / jet.pt());

ltPtrs.push_back(cand);
}
Expand Down Expand Up @@ -353,12 +362,21 @@ void UnifiedParticleTransformerAK4TagInfoProducer::produce(edm::Event& iEvent, c
auto& trackinfo = trackinfos.emplace(i, track_builder).first->second;
trackinfo.buildTrackInfo(cand, jet_dir, jet_ref_track_dir, pv);

c_sorted.emplace_back(i,
trackinfo.getTrackSip2dSig(),
-btagbtvdeep::mindrsvpfcand(svs_unsorted, cand),
cand->pt() / jet.pt());
if (sort_cand_by_pt_)
c_sorted.emplace_back(i,
cand->pt() / jet.pt(),
trackinfo.getTrackSip2dSig(),
-btagbtvdeep::mindrsvpfcand(svs_unsorted, cand));
else
c_sorted.emplace_back(i,
trackinfo.getTrackSip2dSig(),
-btagbtvdeep::mindrsvpfcand(svs_unsorted, cand),
cand->pt() / jet.pt());
} else {
n_sorted.emplace_back(i, -1, -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet.pt());
if (sort_cand_by_pt_)
n_sorted.emplace_back(i, cand->pt() / jet.pt(), -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), -1);
else
n_sorted.emplace_back(i, -1, -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet.pt());
}
}
}
Expand Down

0 comments on commit 88fe605

Please sign in to comment.