CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
heppy::CMGMuonCleanerBySegmentsAlgo Class Reference

#include <CMGMuonCleanerBySegmentsAlgo.h>

Public Member Functions

std::vector< bool > clean (const std::vector< pat::Muon > &muons) const
 Return a vector of boolean marking the muons to be considered clean. More...
 
 CMGMuonCleanerBySegmentsAlgo (double sharedFraction=0.499, const std::string &preselection="track.isNonnull", const std::string &passthrough="isGlobalMuon && numberOfMatches >= 2")
 
 ~CMGMuonCleanerBySegmentsAlgo ()
 

Private Member Functions

bool isBetterMuon (const pat::Muon &mu1, bool mu1PF, const pat::Muon &mu2, bool mu2PF) const
 
bool isSameMuon (const pat::Muon &mu1, const pat::Muon &mu2) const
 Methods. More...
 

Private Attributes

StringCutObjectSelector< pat::Muonpassthrough_
 Always-accept cut. More...
 
StringCutObjectSelector< pat::Muonpreselection_
 Preselection cut. More...
 
double sharedFraction_
 Fraction of shared segments. More...
 

Detailed Description

Definition at line 10 of file CMGMuonCleanerBySegmentsAlgo.h.

Constructor & Destructor Documentation

heppy::CMGMuonCleanerBySegmentsAlgo::CMGMuonCleanerBySegmentsAlgo ( double  sharedFraction = 0.499,
const std::string &  preselection = "track.isNonnull",
const std::string &  passthrough = "isGlobalMuon && numberOfMatches >= 2" 
)
inline

Definition at line 12 of file CMGMuonCleanerBySegmentsAlgo.h.

References clean(), electronCleaner_cfi::muons, and ~CMGMuonCleanerBySegmentsAlgo().

12  :
13  sharedFraction_(sharedFraction),
15  passthrough_(passthrough,true) {}
double sharedFraction_
Fraction of shared segments.
StringCutObjectSelector< pat::Muon > passthrough_
Always-accept cut.
StringCutObjectSelector< pat::Muon > preselection_
Preselection cut.
heppy::CMGMuonCleanerBySegmentsAlgo::~CMGMuonCleanerBySegmentsAlgo ( )

Definition at line 5 of file CMGMuonCleanerBySegmentsAlgo.cc.

Referenced by CMGMuonCleanerBySegmentsAlgo().

5  {
6 }

Member Function Documentation

std::vector< bool > heppy::CMGMuonCleanerBySegmentsAlgo::clean ( const std::vector< pat::Muon > &  muons) const

Return a vector of boolean marking the muons to be considered clean.

Definition at line 9 of file CMGMuonCleanerBySegmentsAlgo.cc.

References mps_fire::i, isBetterMuon(), reco::Muon::isPFMuon(), isSameMuon(), reco::Muon::numberOfMatches(), passthrough_, preselection_, reco::Muon::SegmentArbitration, sharedFraction_, and muon::sharedSegments().

Referenced by CMGMuonCleanerBySegmentsAlgo().

9  {
10  unsigned int nsrc = src.size();
11  std::vector<bool> good(nsrc, true);
12  for (unsigned int i = 0; i < nsrc; ++i) {
13  const pat::Muon &mu1 = src[i];
14  if (!preselection_(mu1)) good[i] = false;
15  if (!good[i]) continue;
16  int nSegments1 = mu1.numberOfMatches(reco::Muon::SegmentArbitration);
17  for (unsigned int j = i+1; j < nsrc; ++j) {
18  const pat::Muon &mu2 = src[j];
19  if (isSameMuon(mu1,mu2)) continue;
20  if (!good[j] || !preselection_(mu2)) continue;
21  int nSegments2 = mu2.numberOfMatches(reco::Muon::SegmentArbitration);
22  if (nSegments2 == 0 || nSegments1 == 0) continue;
23  double sf = muon::sharedSegments(mu1,mu2)/std::min<double>(nSegments1,nSegments2);
24  if (sf > sharedFraction_) {
25  if (isBetterMuon(mu1,mu1.isPFMuon(),mu2,mu2.isPFMuon())) {
26  good[j] = false;
27  } else {
28  good[i] = false;
29  }
30  }
31  }
32  }
33 
34  for (unsigned int i = 0; i < nsrc; ++i) {
35  const pat::Muon &mu1 = src[i];
36  if (passthrough_(mu1)) good[i] = true;
37  }
38 
39  return good;
40 }
double sharedFraction_
Fraction of shared segments.
bool isBetterMuon(const pat::Muon &mu1, bool mu1PF, const pat::Muon &mu2, bool mu2PF) const
StringCutObjectSelector< pat::Muon > passthrough_
Always-accept cut.
bool isSameMuon(const pat::Muon &mu1, const pat::Muon &mu2) const
Methods.
int sharedSegments(const reco::Muon &muon1, const reco::Muon &muon2, unsigned int segmentArbitrationMask=reco::MuonSegmentMatch::BestInChamberByDR)
StringCutObjectSelector< pat::Muon > preselection_
Preselection cut.
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
bool isPFMuon() const
Definition: Muon.h:229
Analysis-level muon class.
Definition: Muon.h:49
bool heppy::CMGMuonCleanerBySegmentsAlgo::isBetterMuon ( const pat::Muon mu1,
bool  mu1PF,
const pat::Muon mu2,
bool  mu2PF 
) const
private

Definition at line 52 of file CMGMuonCleanerBySegmentsAlgo.cc.

References reco::LeafCandidate::charge(), reco::deltaR2(), reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNull(), reco::Muon::numberOfMatches(), reco::LeafCandidate::pt(), reco::Muon::SegmentArbitration, and pat::Muon::track().

Referenced by clean().

52  {
53  if (mu2.track().isNull()) return true;
54  if (mu1.track().isNull()) return false;
55  if (mu1PF != mu2PF) return mu1PF;
56  if (mu1.isGlobalMuon() != mu2.isGlobalMuon()) return mu1.isGlobalMuon();
57  if (mu1.charge() == mu2.charge() && deltaR2(mu1,mu2) < 0.0009) {
58  return mu1.track()->ptError()/mu1.track()->pt() < mu2.track()->ptError()/mu2.track()->pt();
59  } else {
62  return (nm1 != nm2 ? nm1 > nm2 : mu1.pt() > mu2.pt());
63  }
64 }
virtual double pt() const final
transverse momentum
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
bool isGlobalMuon() const
Definition: Muon.h:225
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
bool isNull() const
Checks for null.
Definition: Ref.h:249
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
bool heppy::CMGMuonCleanerBySegmentsAlgo::isSameMuon ( const pat::Muon mu1,
const pat::Muon mu2 
) const
private

Methods.

Definition at line 43 of file CMGMuonCleanerBySegmentsAlgo.cc.

References pat::PATObject< ObjectType >::originalObjectRef().

Referenced by clean().

43  {
44  return (& mu1 == & mu2) ||
45  (mu1.originalObjectRef() == mu2.originalObjectRef()) ||
46  (mu1.reco::Muon::innerTrack().isNonnull() ?
47  mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack() :
48  mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
49 }
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:500

Member Data Documentation

StringCutObjectSelector<pat::Muon> heppy::CMGMuonCleanerBySegmentsAlgo::passthrough_
private

Always-accept cut.

Definition at line 28 of file CMGMuonCleanerBySegmentsAlgo.h.

Referenced by clean().

StringCutObjectSelector<pat::Muon> heppy::CMGMuonCleanerBySegmentsAlgo::preselection_
private

Preselection cut.

Definition at line 26 of file CMGMuonCleanerBySegmentsAlgo.h.

Referenced by clean().

double heppy::CMGMuonCleanerBySegmentsAlgo::sharedFraction_
private

Fraction of shared segments.

Definition at line 23 of file CMGMuonCleanerBySegmentsAlgo.h.

Referenced by clean().