49 return (& mu1 == & mu2) ||
50 (mu1.reco::Muon::innerTrack().isNonnull() ?
51 mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack() :
52 mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
81 src_(iConfig.getParameter<edm::InputTag>(
"src")),
82 preselection_(iConfig.existsAs<std::
string>(
"preselection") ? iConfig.getParameter<std::
string>(
"preselection") :
""),
83 passthrough_(iConfig.existsAs<std::
string>(
"passthrough") ? iConfig.getParameter<std::
string>(
"passthrough") :
"0"),
84 sharedFraction_(iConfig.getParameter<double>(
"fractionOfSharedSegments")),
85 defaultBestMuon_(!iConfig.existsAs<std::
string>(
"customArbitration")),
86 bestMuonSelector_(defaultBestMuon_ ? std::
string(
"") : iConfig.getParameter<std::
string>(
"customArbitration"))
89 produces<std::vector<T> >();
99 auto_ptr<vector<T> >
out(
new vector<T>());
102 unsigned int nsrc =
src->size();
104 std::vector<int> good(nsrc,
true);
105 for (
unsigned int i = 0;
i < nsrc; ++
i) {
106 const T &mu1 = (*src)[
i];
107 if (!preselection_(mu1)) good[
i] =
false;
108 if (!good[
i])
continue;
110 for (
unsigned int j = i+1;
j < nsrc; ++
j) {
111 const T &mu2 = (*src)[
j];
112 if (isSameMuon(mu1,mu2))
continue;
113 if (!good[
j] || !preselection_(mu2))
continue;
115 if (nSegments2 == 0 || nSegments1 == 0)
continue;
117 if (sf > sharedFraction_) {
118 if (isBetterMuon(mu1,mu2)) {
126 for (
unsigned int i = 0;
i < nsrc; ++
i) {
127 const T &mu1 = (*src)[
i];
128 if (good[
i] || passthrough_(mu1)) out->push_back(mu1);
136 if (!defaultBestMuon_) {
138 return bestMuonSelector_(pair);
140 if (mu2.track().isNull())
return true;
141 if (mu1.track().isNull())
return false;
142 if (mu1.isPFMuon() != mu2.isPFMuon())
return mu1.isPFMuon();
143 if (mu1.isGlobalMuon() != mu2.isGlobalMuon())
return mu1.isGlobalMuon();
144 if (mu1.charge() == mu2.charge() &&
deltaR2(mu1,mu2) < 0.0009) {
145 return mu1.track()->ptError()/mu1.track()->pt() < mu2.track()->ptError()/mu2.track()->pt();
149 return (nm1 != nm2 ? nm1 > nm2 : mu1.pt() > mu2.pt());
156 return (& mu1 == & mu2) ||
158 (mu1.reco::Muon::innerTrack().isNonnull() ?
159 mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack() :
160 mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
169 using namespace modules;
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.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool isSameMuon(const T &mu1, const T &mu2) const
edm::InputTag src_
Labels 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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double deltaR2(const Vector1 &v1, const Vector2 &v2)
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