46 return (&mu1 == &mu2) ||
47 (mu1.reco::Muon::innerTrack().isNonnull() ? mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack()
48 : mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
78 preselection_(iConfig.existsAs<
std::
string>(
"preselection") ? iConfig.getParameter<
std::
string>(
"preselection")
80 passthrough_(iConfig.existsAs<
std::
string>(
"passthrough") ? iConfig.getParameter<
std::
string>(
"passthrough")
82 sharedFraction_(iConfig.getParameter<double>(
"fractionOfSharedSegments")),
83 defaultBestMuon_(!iConfig.existsAs<
std::
string>(
"customArbitration")),
84 bestMuonSelector_(defaultBestMuon_ ?
std::
string(
"") : iConfig.getParameter<
std::
string>(
"customArbitration")) {
86 produces<std::vector<T> >();
95 unique_ptr<vector<T> >
out(
new vector<T>());
98 unsigned int nsrc =
src->size();
100 std::vector<int>
good(nsrc,
true);
101 for (
unsigned int i = 0;
i < nsrc; ++
i) {
102 const T &mu1 = (*src)[
i];
103 if (!preselection_(mu1))
108 for (
unsigned int j =
i + 1;
j < nsrc; ++
j) {
109 const T &mu2 = (*src)[
j];
110 if (isSameMuon(mu1, mu2))
112 if (!
good[
j] || !preselection_(mu2))
115 if (nSegments2 == 0 || nSegments1 == 0)
118 if (sf > sharedFraction_) {
119 if (isBetterMuon(mu1, mu2)) {
127 for (
unsigned int i = 0;
i < nsrc; ++
i) {
128 const T &mu1 = (*src)[
i];
129 if (
good[
i] || passthrough_(mu1))
135 template <
typename T>
137 if (!defaultBestMuon_) {
139 return bestMuonSelector_(pair);
141 if (mu2.track().isNull())
143 if (mu1.track().isNull())
145 if (mu1.isPFMuon() != mu2.isPFMuon())
146 return mu1.isPFMuon();
147 if (mu1.isGlobalMuon() != mu2.isGlobalMuon())
148 return mu1.isGlobalMuon();
149 if (mu1.charge() == mu2.charge() &&
deltaR2(mu1, mu2) < 0.0009) {
150 return mu1.track()->ptError() / mu1.track()->pt() < mu2.track()->ptError() / mu2.track()->pt();
154 return (nm1 != nm2 ? nm1 > nm2 : mu1.pt() > mu2.pt());
161 (mu1.reco::Muon::innerTrack().isNonnull() ? mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack()
162 : mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
modules::MuonCleanerBySegmentsT< reco::Muon > MuonCleanerBySegments
double sharedFraction_
Fraction of shared segments.
StringCutObjectSelector< T > preselection_
Preselection cut.
modules::MuonCleanerBySegmentsT< pat::Muon > PATMuonCleanerBySegments
StringCutObjectSelector< T > passthrough_
Always-accept cut.
#define DEFINE_FWK_MODULE(type)
std::pair< const reco::Muon *, const reco::Muon * > MuonPointerPair
Cut on the pair of objects together.
bool isBetterMuon(const T &mu1, const T &mu2) const
bool isSameMuon(const T &mu1, const T &mu2) const
~MuonCleanerBySegmentsT() override
edm::EDGetTokenT< edm::View< T > > srcToken_
Tokens for input collections.
MuonCleanerBySegmentsT(const edm::ParameterSet &iConfig)
int sharedSegments(const reco::Muon &muon1, const reco::Muon &muon2, unsigned int segmentArbitrationMask=reco::MuonSegmentMatch::BestInChamberByDR)
auto const good
min quality of good
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Removes duplicates from a muon collection using segment references.
StringCutObjectSelector< MuonPointerPair, true > bestMuonSelector_
Analysis-level muon class.
bool defaultBestMuon_
Use default criteria to choose the best muon.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override