48 return (& mu1 == & mu2) ||
49 (mu1.reco::Muon::innerTrack().isNonnull() ?
50 mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack() :
51 mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
80 srcToken_(consumes<edm::
View<
T> >(iConfig.getParameter<edm::
InputTag>(
"src"))),
81 preselection_(iConfig.existsAs<std::
string>(
"preselection") ? iConfig.getParameter<std::
string>(
"preselection") :
""),
82 passthrough_(iConfig.existsAs<std::
string>(
"passthrough") ? iConfig.getParameter<std::
string>(
"passthrough") :
"0"),
83 sharedFraction_(iConfig.getParameter<double>(
"fractionOfSharedSegments")),
84 defaultBestMuon_(!iConfig.existsAs<std::
string>(
"customArbitration")),
85 bestMuonSelector_(defaultBestMuon_ ? std::
string(
"") : iConfig.getParameter<std::
string>(
"customArbitration"))
88 produces<std::vector<T> >();
98 auto_ptr<vector<T> >
out(
new vector<T>());
101 unsigned int nsrc =
src->size();
103 std::vector<int> good(nsrc,
true);
104 for (
unsigned int i = 0;
i < nsrc; ++
i) {
105 const T &mu1 = (*src)[
i];
106 if (!preselection_(mu1)) good[
i] =
false;
107 if (!good[
i])
continue;
109 for (
unsigned int j = i+1;
j < nsrc; ++
j) {
110 const T &mu2 = (*src)[
j];
111 if (isSameMuon(mu1,mu2))
continue;
112 if (!good[
j] || !preselection_(mu2))
continue;
114 if (nSegments2 == 0 || nSegments1 == 0)
continue;
116 if (sf > sharedFraction_) {
117 if (isBetterMuon(mu1,mu2)) {
125 for (
unsigned int i = 0;
i < nsrc; ++
i) {
126 const T &mu1 = (*src)[
i];
127 if (good[
i] || passthrough_(mu1)) out->push_back(mu1);
135 if (!defaultBestMuon_) {
137 return bestMuonSelector_(pair);
139 if (mu2.track().isNull())
return true;
140 if (mu1.track().isNull())
return false;
141 if (mu1.isPFMuon() != mu2.isPFMuon())
return mu1.isPFMuon();
142 if (mu1.isGlobalMuon() != mu2.isGlobalMuon())
return mu1.isGlobalMuon();
143 if (mu1.charge() == mu2.charge() &&
deltaR2(mu1,mu2) < 0.0009) {
144 return mu1.track()->ptError()/mu1.track()->pt() < mu2.track()->ptError()/mu2.track()->pt();
148 return (nm1 != nm2 ? nm1 > nm2 : mu1.pt() > mu2.pt());
155 return (& mu1 == & mu2) ||
157 (mu1.reco::Muon::innerTrack().isNonnull() ?
158 mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack() :
159 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.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::pair< const reco::Muon *, const reco::Muon * > MuonPointerPair
Cut on the pair of objects together.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool isSameMuon(const T &mu1, const T &mu2) const
double deltaR2(const T1 &t1, const T2 &t2)
edm::EDGetTokenT< edm::View< T > > srcToken_
Tokens for input collections.
bool isBetterMuon(const T &mu1, const T &mu2) const
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
MuonCleanerBySegmentsT(const edm::ParameterSet &iConfig)
int sharedSegments(const reco::Muon &muon1, const reco::Muon &muon2, unsigned int segmentArbitrationMask=reco::MuonSegmentMatch::BestInChamberByDR)
virtual ~MuonCleanerBySegmentsT()
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.
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override