CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes | Private Attributes
PFMuonSelector Class Reference

#include <PFMuonSelector.h>

Inheritance diagram for PFMuonSelector:
Selector< pat::Muon >

Public Types

enum  Version_t { SPRING11, N_VERSIONS }
 
- Public Types inherited from Selector< pat::Muon >
typedef std::binary_function
< pat::Muon, pat::strbitset,
bool > 
base_type
 
typedef std::pair< index_type,
size_t > 
cut_flow_item
 
typedef std::vector
< cut_flow_item
cut_flow_map
 
typedef pat::Muon data_type
 
typedef std::map< index_type,
double > 
double_map
 
typedef pat::strbitset::index_type index_type
 
typedef std::map< index_type, int > int_map
 

Public Member Functions

void initialize (Version_t version, double chi2=10.0, double d0=0.02, int nhits=11, int nValidMuonHits=0, double pfiso=0.15, int minPixelHits=1, int minNMatches=1)
 
bool operator() (const pat::Muon &muon, pat::strbitset &ret)
 This provides the interface for base classes to select objects. More...
 
 PFMuonSelector ()
 
 PFMuonSelector (edm::ParameterSet const &parameters)
 
bool spring11Cuts (const pat::Muon &muon, pat::strbitset &ret)
 
- Public Member Functions inherited from Selector< pat::Muon >
void clear (std::string const &s)
 Turn off a given selection cut. More...
 
void clear (index_type const &i)
 
bool considerCut (std::string const &s) const
 consider the cut at index "s" More...
 
bool considerCut (index_type const &i) const
 
int cut (index_type const &i, int val) const
 Access the int cut values at index "s". More...
 
double cut (index_type const &i, double val) const
 Access the double cut values at index "s". More...
 
int cut (std::string s, int val) const
 Access the int cut values at index "s". More...
 
double cut (std::string s, double val) const
 Access the double cut values at index "s". More...
 
pat::strbitset getBitTemplate () const
 Get an empty bitset with the proper names. More...
 
double getPasses (std::string const &s) const
 Return the number of passing cases. More...
 
double getPasses (index_type const &i) const
 
bool ignoreCut (std::string const &s) const
 ignore the cut at index "s" More...
 
bool ignoreCut (index_type const &i) const
 
virtual bool operator() (pat::Muonconst &t)
 This provides an alternative signature without the second ret. More...
 
virtual bool operator() (pat::Muonconst &t, edm::EventBase const &e, pat::strbitset &ret)
 This provides an alternative signature that includes extra information. More...
 
virtual bool operator() (pat::Muonconst &t, edm::EventBase const &e)
 This provides an alternative signature that includes extra information. More...
 
bool operator[] (std::string const &s) const
 
bool operator[] (index_type const &i) const
 
void passCut (pat::strbitset &ret, std::string const &s)
 Passing cuts. More...
 
void passCut (pat::strbitset &ret, index_type const &i)
 
void print (std::ostream &out) const
 Print the cut flow. More...
 
void printActiveCuts (std::ostream &out) const
 Print the cuts being considered. More...
 
virtual void push_back (std::string const &s)
 This is the registration of an individual cut string. More...
 
virtual void push_back (std::string const &s, int cut)
 This is the registration of an individual cut string, with an int cut value. More...
 
virtual void push_back (std::string const &s, double cut)
 This is the registration of an individual cut string, with a double cut value. More...
 
 Selector ()
 Constructor clears the bits. More...
 
void set (std::string const &s, bool val=true)
 Set a given selection cut, on or off. More...
 
void set (index_type const &i, bool val=true)
 
void set (std::string const &s, int cut, bool val=true)
 Set a given selection cut, on or off, and reset int cut value. More...
 
void set (index_type const &i, int cut, bool val=true)
 
void set (std::string const &s, double cut, bool val=true)
 Set a given selection cut, on or off, and reset int cut value. More...
 
void set (index_type const &i, double cut, bool val=true)
 
void setIgnored (pat::strbitset &ret)
 set ignored bits More...
 
void setIgnoredCuts (std::vector< std::string > const &bitsToIgnore)
 set the bits to ignore from a vector More...
 
virtual ~Selector ()
 

Public Attributes

bool verbose_
 

Private Attributes

index_type indexChi2_
 
index_type indexD0_
 
index_type indexNHits_
 
index_type indexNValMuHits_
 
index_type indexPFIso_
 
index_type indexPixHits_
 
index_type indexStations_
 
Version_t version_
 

Additional Inherited Members

- Protected Attributes inherited from Selector< pat::Muon >
pat::strbitset bits_
 the bitset indexed by strings More...
 
cut_flow_map cutFlow_
 map of cut flows in "human" order More...
 
double_map doubleCuts_
 the double-value cut map More...
 
int_map intCuts_
 the int-value cut map More...
 
pat::strbitset retInternal_
 internal ret if users don't care about return bits More...
 

Detailed Description

Definition at line 13 of file PFMuonSelector.h.

Member Enumeration Documentation

Enumerator
SPRING11 
N_VERSIONS 

Definition at line 19 of file PFMuonSelector.h.

Constructor & Destructor Documentation

PFMuonSelector::PFMuonSelector ( )
inline

Definition at line 21 of file PFMuonSelector.h.

21 {}
PFMuonSelector::PFMuonSelector ( edm::ParameterSet const &  parameters)
inline

Definition at line 23 of file PFMuonSelector.h.

References edm::hlt::Exception, edm::ParameterSet::exists(), Selector< pat::Muon >::getBitTemplate(), edm::ParameterSet::getParameter(), initialize(), N_VERSIONS, Selector< pat::Muon >::retInternal_, Selector< pat::Muon >::setIgnoredCuts(), SPRING11, AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and BeamSplash_cfg::version.

23  {
24 
25  verbose_ = false;
26 
27  std::string versionStr = parameters.getParameter<std::string>("version");
28 
30 
31  if ( versionStr == "SPRING11" ) {
32  version = SPRING11;
33  }
34  else {
35  throw cms::Exception("InvalidInput") << "Expect version to be one of SPRING11" << std::endl;
36  }
37 
38  initialize( version,
39  parameters.getParameter<double>("Chi2"),
40  parameters.getParameter<double>("D0") ,
41  parameters.getParameter<int> ("NHits") ,
42  parameters.getParameter<int> ("NValMuHits"),
43  parameters.getParameter<double>("PFIso"),
44  parameters.getParameter<int> ("nPixelHits"),
45  parameters.getParameter<int> ("nMatchedStations")
46  );
47  if ( parameters.exists("cutsToIgnore") )
48  setIgnoredCuts( parameters.getParameter<std::vector<std::string> >("cutsToIgnore") );
49 
51 
52  }
dictionary parameters
Definition: Parameters.py:2
void initialize(Version_t version, double chi2=10.0, double d0=0.02, int nhits=11, int nValidMuonHits=0, double pfiso=0.15, int minPixelHits=1, int minNMatches=1)
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:288
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:213
void setIgnoredCuts(std::vector< std::string > const &bitsToIgnore)
set the bits to ignore from a vector
Definition: Selector.h:168

Member Function Documentation

void PFMuonSelector::initialize ( Version_t  version,
double  chi2 = 10.0,
double  d0 = 0.02,
int  nhits = 11,
int  nValidMuonHits = 0,
double  pfiso = 0.15,
int  minPixelHits = 1,
int  minNMatches = 1 
)
inline

Definition at line 54 of file PFMuonSelector.h.

References Selector< pat::Muon >::bits_, indexChi2_, indexD0_, indexNHits_, indexNValMuHits_, indexPFIso_, indexPixHits_, indexStations_, Selector< pat::Muon >::push_back(), Selector< pat::Muon >::set(), BeamSplash_cfg::version, and version_.

Referenced by PFMuonSelector().

62  {
63  version_ = version;
64 
65  push_back("Chi2", chi2 );
66  push_back("D0", d0 );
67  push_back("NHits", nhits );
68  push_back("NValMuHits",nValidMuonHits );
69  push_back("PFIso", pfiso );
70  push_back("nPixelHits",minPixelHits);
71  push_back("nMatchedStations", minNMatches);
72 
73  set("Chi2");
74  set("D0");
75  set("NHits");
76  set("NValMuHits");
77  set("PFIso");
78  set("nPixelHits");
79  set("nMatchedStations");
80 
81  indexChi2_ = index_type(&bits_, "Chi2" );
82  indexD0_ = index_type(&bits_, "D0" );
83  indexNHits_ = index_type(&bits_, "NHits" );
84  indexNValMuHits_ = index_type(&bits_, "NValMuHits" );
85  indexPFIso_ = index_type(&bits_, "PFIso" );
86  indexPixHits_ = index_type(&bits_, "nPixelHits");
87  indexStations_ = index_type(&bits_, "nMatchedStations");
88 
89  }
void set(std::string const &s, bool val=true)
Set a given selection cut, on or off.
Definition: Selector.h:106
index_type indexPixHits_
Version_t version_
pat::strbitset::index_type index_type
Definition: Selector.h:30
index_type indexNHits_
index_type indexStations_
index_type indexNValMuHits_
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:287
index_type indexPFIso_
index_type indexD0_
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:47
index_type indexChi2_
bool PFMuonSelector::operator() ( const pat::Muon t,
pat::strbitset ret 
)
inlinevirtual

This provides the interface for base classes to select objects.

Implements Selector< pat::Muon >.

Definition at line 92 of file PFMuonSelector.h.

References SPRING11, spring11Cuts(), and version_.

93  {
94  if (version_ == SPRING11 ) return spring11Cuts(muon, ret);
95  else {
96  return false;
97  }
98  }
Version_t version_
bool spring11Cuts(const pat::Muon &muon, pat::strbitset &ret)
bool PFMuonSelector::spring11Cuts ( const pat::Muon muon,
pat::strbitset ret 
)
inline

Definition at line 103 of file PFMuonSelector.h.

References Selector< pat::Muon >::cut(), pat::Muon::dB(), pat::Muon::globalTrack(), Selector< pat::Muon >::ignoreCut(), indexChi2_, indexD0_, indexNHits_, indexNValMuHits_, indexPFIso_, indexPixHits_, indexStations_, pat::Muon::innerTrack(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), pat::Muon::normChi2(), reco::Muon::numberOfMatches(), pat::Muon::numberOfValidHits(), Selector< pat::Muon >::passCut(), pat::PfChargedHadronIso, pat::PfGammaIso, pat::PfNeutralHadronIso, reco::LeafCandidate::pt(), run_regression::ret, pat::strbitset::set(), Selector< pat::Muon >::setIgnored(), and pat::Lepton< LeptonType >::userIsolation().

Referenced by operator()().

104  {
105  ret.set(false);
106 
107  double norm_chi2 = 9999999.0;
108  if ( muon.globalTrack().isNonnull() && muon.globalTrack().isAvailable() )
109  norm_chi2 = muon.normChi2();
110  double corr_d0 = 999999.0;
111  if ( muon.globalTrack().isNonnull() && muon.globalTrack().isAvailable() )
112  corr_d0 = muon.dB();
113 
114  int nhits = static_cast<int>( muon.numberOfValidHits() );
115  int nValidMuonHits = 0;
116  if ( muon.globalTrack().isNonnull() && muon.globalTrack().isAvailable() )
117  nValidMuonHits = static_cast<int> (muon.globalTrack()->hitPattern().numberOfValidMuonHits());
118 
119  double chIso = muon.userIsolation(pat::PfChargedHadronIso);
120  double nhIso = muon.userIsolation(pat::PfNeutralHadronIso);
121  double gIso = muon.userIsolation(pat::PfGammaIso);
122  double pt = muon.pt() ;
123 
124  double pfIso = (chIso + nhIso + gIso) / pt;
125 
126  int nPixelHits = 0;
127  if ( muon.innerTrack().isNonnull() && muon.innerTrack().isAvailable() )
128  nPixelHits = muon.innerTrack()->hitPattern().pixelLayersWithMeasurement();
129 
130  int nMatchedStations = muon.numberOfMatches();
131 
132  if ( norm_chi2 < cut(indexChi2_, double()) || ignoreCut(indexChi2_) ) passCut(ret, indexChi2_ );
133  if ( fabs(corr_d0) < cut(indexD0_, double()) || ignoreCut(indexD0_) ) passCut(ret, indexD0_ );
134  if ( nhits >= cut(indexNHits_, int() ) || ignoreCut(indexNHits_) ) passCut(ret, indexNHits_ );
135  if ( nValidMuonHits> cut(indexNValMuHits_,int()) || ignoreCut(indexNValMuHits_)) passCut(ret, indexNValMuHits_ );
136  if ( pfIso < cut(indexPFIso_, double()) || ignoreCut(indexPFIso_) ) passCut(ret, indexPFIso_ );
137  if ( nPixelHits > cut(indexPixHits_,int()) || ignoreCut(indexPixHits_)) passCut(ret, indexPixHits_);
138  if ( nMatchedStations> cut(indexStations_,int()) || ignoreCut(indexStations_)) passCut(ret, indexStations_);
139 
140  setIgnored(ret);
141 
142  return (bool)ret;
143  }
double normChi2() const
Norm chi2 gives the normalized chi2 of the global track.
Definition: Muon.cc:318
unsigned int numberOfValidHits() const
numberOfValidHits returns the number of valid hits on the global track.
Definition: Muon.cc:331
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:74
index_type indexPixHits_
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:225
index_type indexNHits_
bool isAvailable() const
Definition: Ref.h:276
index_type indexStations_
index_type indexNValMuHits_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Definition: Selector.h:177
index_type indexPFIso_
bool ignoreCut(std::string const &s) const
ignore the cut at index &quot;s&quot;
Definition: Selector.h:160
index_type indexD0_
double dB(IpType type=None) const
Definition: Muon.cc:344
reco::TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:82
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
Definition: Muon.cc:60
float userIsolation(IsolationKeys key) const
Definition: Lepton.h:51
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
index_type indexChi2_
virtual float pt() const GCC11_FINAL
transverse momentum
int cut(index_type const &i, int val) const
Access the int cut values at index &quot;s&quot;.
Definition: Selector.h:195

Member Data Documentation

index_type PFMuonSelector::indexChi2_
private

Definition at line 151 of file PFMuonSelector.h.

Referenced by initialize(), and spring11Cuts().

index_type PFMuonSelector::indexD0_
private

Definition at line 152 of file PFMuonSelector.h.

Referenced by initialize(), and spring11Cuts().

index_type PFMuonSelector::indexNHits_
private

Definition at line 153 of file PFMuonSelector.h.

Referenced by initialize(), and spring11Cuts().

index_type PFMuonSelector::indexNValMuHits_
private

Definition at line 154 of file PFMuonSelector.h.

Referenced by initialize(), and spring11Cuts().

index_type PFMuonSelector::indexPFIso_
private

Definition at line 155 of file PFMuonSelector.h.

Referenced by initialize(), and spring11Cuts().

index_type PFMuonSelector::indexPixHits_
private

Definition at line 156 of file PFMuonSelector.h.

Referenced by initialize(), and spring11Cuts().

index_type PFMuonSelector::indexStations_
private

Definition at line 157 of file PFMuonSelector.h.

Referenced by initialize(), and spring11Cuts().

bool PFMuonSelector::verbose_

Definition at line 17 of file PFMuonSelector.h.

Referenced by PFMuonSelector().

Version_t PFMuonSelector::version_
private

Definition at line 149 of file PFMuonSelector.h.

Referenced by initialize(), and operator()().