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

◆ CMGMuonCleanerBySegmentsAlgo()

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.

15  : sharedFraction_(sharedFraction), preselection_(preselection, true), passthrough_(passthrough, true) {}

◆ ~CMGMuonCleanerBySegmentsAlgo()

heppy::CMGMuonCleanerBySegmentsAlgo::~CMGMuonCleanerBySegmentsAlgo ( )

Definition at line 5 of file CMGMuonCleanerBySegmentsAlgo.cc.

5 {}

Member Function Documentation

◆ clean()

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 7 of file CMGMuonCleanerBySegmentsAlgo.cc.

7  {
8  unsigned int nsrc = src.size();
9  std::vector<bool> good(nsrc, true);
10  for (unsigned int i = 0; i < nsrc; ++i) {
11  const pat::Muon &mu1 = src[i];
12  if (!preselection_(mu1))
13  good[i] = false;
14  if (!good[i])
15  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))
20  continue;
21  if (!good[j] || !preselection_(mu2))
22  continue;
23  int nSegments2 = mu2.numberOfMatches(reco::Muon::SegmentArbitration);
24  if (nSegments2 == 0 || nSegments1 == 0)
25  continue;
26  double sf = muon::sharedSegments(mu1, mu2) / std::min<double>(nSegments1, nSegments2);
27  if (sf > sharedFraction_) {
28  if (isBetterMuon(mu1, mu1.isPFMuon(), mu2, mu2.isPFMuon())) {
29  good[j] = false;
30  } else {
31  good[i] = false;
32  }
33  }
34  }
35  }
36 
37  for (unsigned int i = 0; i < nsrc; ++i) {
38  const pat::Muon &mu1 = src[i];
39  if (passthrough_(mu1))
40  good[i] = true;
41  }
42 
43  return good;
44  }

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

◆ isBetterMuon()

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.

55  {
56  if (mu2.track().isNull())
57  return true;
58  if (mu1.track().isNull())
59  return false;
60  if (mu1PF != mu2PF)
61  return mu1PF;
62  if (mu1.isGlobalMuon() != mu2.isGlobalMuon())
63  return mu1.isGlobalMuon();
64  if (mu1.charge() == mu2.charge() && deltaR2(mu1, mu2) < 0.0009) {
65  return mu1.track()->ptError() / mu1.track()->pt() < mu2.track()->ptError() / mu2.track()->pt();
66  } else {
69  return (nm1 != nm2 ? nm1 > nm2 : mu1.pt() > mu2.pt());
70  }
71  }

References reco::LeafCandidate::charge(), HLTMuonOfflineAnalyzer_cfi::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().

◆ isSameMuon()

bool heppy::CMGMuonCleanerBySegmentsAlgo::isSameMuon ( const pat::Muon mu1,
const pat::Muon mu2 
) const
private

Methods.

Definition at line 46 of file CMGMuonCleanerBySegmentsAlgo.cc.

46  {
47  return (&mu1 == &mu2) || (mu1.originalObjectRef() == mu2.originalObjectRef()) ||
48  (mu1.reco::Muon::innerTrack().isNonnull() ? mu1.reco::Muon::innerTrack() == mu2.reco::Muon::innerTrack()
49  : mu1.reco::Muon::outerTrack() == mu2.reco::Muon::outerTrack());
50  }

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

Referenced by clean().

Member Data Documentation

◆ passthrough_

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

Always-accept cut.

Definition at line 28 of file CMGMuonCleanerBySegmentsAlgo.h.

Referenced by clean().

◆ preselection_

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

Preselection cut.

Definition at line 26 of file CMGMuonCleanerBySegmentsAlgo.h.

Referenced by clean().

◆ sharedFraction_

double heppy::CMGMuonCleanerBySegmentsAlgo::sharedFraction_
private

Fraction of shared segments.

Definition at line 23 of file CMGMuonCleanerBySegmentsAlgo.h.

Referenced by clean().

mps_fire.i
i
Definition: mps_fire.py:355
reco::Muon::SegmentArbitration
Definition: Muon.h:189
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
heppy::CMGMuonCleanerBySegmentsAlgo::isSameMuon
bool isSameMuon(const pat::Muon &mu1, const pat::Muon &mu2) const
Methods.
Definition: CMGMuonCleanerBySegmentsAlgo.cc:46
heppy::CMGMuonCleanerBySegmentsAlgo::passthrough_
StringCutObjectSelector< pat::Muon > passthrough_
Always-accept cut.
Definition: CMGMuonCleanerBySegmentsAlgo.h:28
singleTopDQM_cfi.preselection
preselection
Definition: singleTopDQM_cfi.py:78
heppy::CMGMuonCleanerBySegmentsAlgo::preselection_
StringCutObjectSelector< pat::Muon > preselection_
Preselection cut.
Definition: CMGMuonCleanerBySegmentsAlgo.h:26
reco::Muon::isGlobalMuon
bool isGlobalMuon() const override
Definition: Muon.h:299
pat::PATObject::originalObjectRef
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:542
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
heppy::CMGMuonCleanerBySegmentsAlgo::isBetterMuon
bool isBetterMuon(const pat::Muon &mu1, bool mu1PF, const pat::Muon &mu2, bool mu2PF) const
Definition: CMGMuonCleanerBySegmentsAlgo.cc:52
heppy::CMGMuonCleanerBySegmentsAlgo::sharedFraction_
double sharedFraction_
Fraction of shared segments.
Definition: CMGMuonCleanerBySegmentsAlgo.h:23
pat::Muon::track
reco::TrackRef track() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon)
reco::LeafCandidate::charge
int charge() const final
electric charge
Definition: LeafCandidate.h:106
reco::Muon::isPFMuon
bool isPFMuon() const
Definition: Muon.h:303
muon::sharedSegments
int sharedSegments(const reco::Muon &muon1, const reco::Muon &muon2, unsigned int segmentArbitrationMask=reco::MuonSegmentMatch::BestInChamberByDR)
Definition: MuonSelectors.cc:990
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
reco::Muon::numberOfMatches
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66