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 | Private Attributes
PFJetIDSelectionFunctor Class Reference

PF Jet selector for pat::Jets. More...

#include "PhysicsTools/Utilities/interface/PFJetIDSelectionFunctor.h"

Inheritance diagram for PFJetIDSelectionFunctor:
Selector< pat::Jet >

Public Types

enum  Quality_t { LOOSE, TIGHT, N_QUALITY }
 
enum  Version_t { FIRSTDATA, N_VERSIONS }
 
- Public Types inherited from Selector< pat::Jet >
typedef std::binary_function
< pat::Jet, 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::Jet 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

bool firstDataCuts (reco::Jet const &jet, pat::strbitset &ret)
 
bool operator() (const pat::Jet &jet, pat::strbitset &ret)
 This provides the interface for base classes to select objects. More...
 
bool operator() (reco::PFJet const &jet, pat::strbitset &ret)
 
 PFJetIDSelectionFunctor ()
 
 PFJetIDSelectionFunctor (edm::ParameterSet const &params)
 
 PFJetIDSelectionFunctor (Version_t version, Quality_t quality)
 
- Public Member Functions inherited from Selector< pat::Jet >
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::Jetconst &t)
 This provides an alternative signature without the second ret. More...
 
virtual bool operator() (pat::Jetconst &t, edm::EventBase const &e, pat::strbitset &ret)
 This provides an alternative signature that includes extra information. More...
 
virtual bool operator() (pat::Jetconst &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 ()
 

Private Attributes

index_type indexCEF_
 
index_type indexCHF_
 
index_type indexNCH_
 
index_type indexNConstituents_
 
index_type indexNEF_
 
index_type indexNHF_
 
Quality_t quality_
 
Version_t version_
 

Additional Inherited Members

- Protected Attributes inherited from Selector< pat::Jet >
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

PF Jet selector for pat::Jets.

Selector functor for pat::Jets that implements quality cuts based on studies of noise patterns.

Please see https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePATSelectors for a general overview of the selectors.

Author
Salvatore Rappoccio
Version
Id:
PFJetIDSelectionFunctor.h,v 1.20 2011/04/27 20:39:42 srappocc Exp

Definition at line 28 of file PFJetIDSelectionFunctor.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

PFJetIDSelectionFunctor::PFJetIDSelectionFunctor ( )
inline

Definition at line 35 of file PFJetIDSelectionFunctor.h.

35 {}
PFJetIDSelectionFunctor::PFJetIDSelectionFunctor ( edm::ParameterSet const &  params)
inline

will have other options eventually, most likely

Definition at line 37 of file PFJetIDSelectionFunctor.h.

References Selector< pat::Jet >::bits_, edm::ParameterSet::exists(), FIRSTDATA, Selector< pat::Jet >::getBitTemplate(), edm::ParameterSet::getParameter(), indexCEF_, indexCHF_, indexNCH_, indexNConstituents_, indexNEF_, indexNHF_, LOOSE, Selector< pat::Jet >::push_back(), quality_, Selector< pat::Jet >::retInternal_, Selector< pat::Jet >::set(), Selector< pat::Jet >::setIgnoredCuts(), AlCaHLTBitMon_QueryRunRegistry::string, TIGHT, and version_.

38  {
39  std::string versionStr = params.getParameter<std::string>("version");
40  std::string qualityStr = params.getParameter<std::string>("quality");
41 
42  if ( versionStr == "FIRSTDATA" )
44  else
46 
47  if ( qualityStr == "LOOSE") quality_ = LOOSE;
48  else if ( qualityStr == "TIGHT") quality_ = TIGHT;
49  else quality_ = LOOSE;
50 
51  push_back("CHF" );
52  push_back("NHF" );
53  push_back("CEF" );
54  push_back("NEF" );
55  push_back("NCH" );
56  push_back("nConstituents");
57 
58 
59  // Set some default cuts for LOOSE, TIGHT
60  if ( quality_ == LOOSE ) {
61  set("CHF", 0.0);
62  set("NHF", 0.99);
63  set("CEF", 0.99);
64  set("NEF", 0.99);
65  set("NCH", 0);
66  set("nConstituents", 1);
67  } else if ( quality_ == TIGHT ) {
68  set("CHF", 0.0);
69  set("NHF", 0.9);
70  set("CEF", 0.99);
71  set("NEF", 0.9);
72  set("NCH", 0);
73  set("nConstituents", 1);
74  }
75 
76 
77  // Now check the configuration to see if the user changed anything
78  if ( params.exists("CHF") ) set("CHF", params.getParameter<double>("CHF") );
79  if ( params.exists("NHF") ) set("NHF", params.getParameter<double>("NHF") );
80  if ( params.exists("CEF") ) set("CEF", params.getParameter<double>("CEF") );
81  if ( params.exists("NEF") ) set("NEF", params.getParameter<double>("NEF") );
82  if ( params.exists("NCH") ) set("NCH", params.getParameter<int> ("NCH") );
83  if ( params.exists("nConstuents") ) set("nConstituents", params.getParameter<int> ("nConstituents") );
84 
85  if ( params.exists("cutsToIgnore") )
86  setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );
87 
88 
89  indexNConstituents_ = index_type (&bits_, "nConstituents");
90  indexNEF_ = index_type (&bits_, "NEF");
91  indexNHF_ = index_type (&bits_, "NHF");
92  indexCEF_ = index_type (&bits_, "CEF");
93  indexCHF_ = index_type (&bits_, "CHF");
94  indexNCH_ = index_type (&bits_, "NCH");
95 
97 
98  }
void set(std::string const &s, bool val=true)
Set a given selection cut, on or off.
Definition: Selector.h:106
pat::strbitset::index_type index_type
Definition: Selector.h:30
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:288
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:287
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:47
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
PFJetIDSelectionFunctor::PFJetIDSelectionFunctor ( Version_t  version,
Quality_t  quality 
)
inline

Definition at line 101 of file PFJetIDSelectionFunctor.h.

References Selector< pat::Jet >::bits_, Selector< pat::Jet >::getBitTemplate(), indexCEF_, indexCHF_, indexNCH_, indexNConstituents_, indexNEF_, indexNHF_, LOOSE, Selector< pat::Jet >::push_back(), quality_, Selector< pat::Jet >::retInternal_, Selector< pat::Jet >::set(), and TIGHT.

102  :
103  version_(version), quality_(quality)
104  {
105 
106  push_back("CHF" );
107  push_back("NHF" );
108  push_back("CEF" );
109  push_back("NEF" );
110  push_back("NCH" );
111  push_back("nConstituents");
112 
113 
114  // Set some default cuts for LOOSE, TIGHT
115  if ( quality_ == LOOSE ) {
116  set("CHF", 0.0);
117  set("NHF", 0.99);
118  set("CEF", 0.99);
119  set("NEF", 0.99);
120  set("NCH", 0);
121  set("nConstituents", 1);
122  } else if ( quality_ == TIGHT ) {
123  set("CHF", 0.0);
124  set("NHF", 0.9);
125  set("CEF", 0.99);
126  set("NEF", 0.9);
127  set("NCH", 0);
128  set("nConstituents", 1);
129  }
130 
131 
132  indexNConstituents_ = index_type (&bits_, "nConstituents");
133  indexNEF_ = index_type (&bits_, "NEF");
134  indexNHF_ = index_type (&bits_, "NHF");
135  indexCEF_ = index_type (&bits_, "CEF");
136  indexCHF_ = index_type (&bits_, "CHF");
137  indexNCH_ = index_type (&bits_, "NCH");
138 
140  }
void set(std::string const &s, bool val=true)
Set a given selection cut, on or off.
Definition: Selector.h:106
pat::strbitset::index_type index_type
Definition: Selector.h:30
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:288
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:287
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:47
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:213

Member Function Documentation

bool PFJetIDSelectionFunctor::firstDataCuts ( reco::Jet const &  jet,
pat::strbitset ret 
)
inline

Definition at line 176 of file PFJetIDSelectionFunctor.h.

References abs, reco::CompositePtrCandidate::begin(), reco::PFJet::chargedEmEnergy(), reco::PFJet::chargedEmEnergyFraction(), pat::Jet::chargedEmEnergyFraction(), reco::PFJet::chargedHadronEnergy(), reco::PFJet::chargedHadronEnergyFraction(), pat::Jet::chargedHadronEnergyFraction(), reco::PFJet::chargedMultiplicity(), pat::Jet::chargedMultiplicity(), Selector< pat::Jet >::cut(), alignCSCRings::e, reco::CompositePtrCandidate::end(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), reco::PFJet::HFHadronEnergy(), pat::Jet::HFHadronEnergy(), Selector< pat::Jet >::ignoreCut(), indexCEF_, indexCHF_, indexNCH_, indexNConstituents_, indexNEF_, indexNHF_, pat::Jet::isBasicJet(), pat::Jet::isPFJet(), metsig::jet, reco::PFJet::neutralEmEnergy(), reco::PFJet::neutralEmEnergyFraction(), pat::Jet::neutralEmEnergyFraction(), reco::PFJet::neutralHadronEnergy(), pat::Jet::neutralHadronEnergy(), reco::CompositePtrCandidate::numberOfDaughters(), pat::Jet::numberOfDaughters(), Selector< pat::Jet >::passCut(), run_regression::ret, pat::strbitset::set(), and Selector< pat::Jet >::setIgnored().

Referenced by operator()().

178  {
179 
180  ret.set(false);
181 
182  // cache some variables
183  double chf = 0.0;
184  double nhf = 0.0;
185  double cef = 0.0;
186  double nef = 0.0;
187  int nch = 0;
188  int nconstituents = 0;
189 
190  // Have to do this because pat::Jet inherits from reco::Jet but not reco::PFJet
191  reco::PFJet const * pfJet = dynamic_cast<reco::PFJet const *>(&jet);
192  pat::Jet const * patJet = dynamic_cast<pat::Jet const *>(&jet);
193  reco::BasicJet const * basicJet = dynamic_cast<reco::BasicJet const *>(&jet);
194 
195  if ( patJet != 0 ) {
196 
197  if ( patJet->isPFJet() ) {
198  chf = patJet->chargedHadronEnergyFraction();
199  nhf = ( patJet->neutralHadronEnergy() + patJet->HFHadronEnergy() ) / patJet->energy();
200  cef = patJet->chargedEmEnergyFraction();
201  nef = patJet->neutralEmEnergyFraction();
202  nch = patJet->chargedMultiplicity();
203  nconstituents = patJet->numberOfDaughters();
204  }
205  // Handle the special case where this is a composed jet for
206  // subjet analyses
207  else if ( patJet->isBasicJet() ) {
208  double e_chf = 0.0;
209  double e_nhf = 0.0;
210  double e_cef = 0.0;
211  double e_nef = 0.0;
212  nch = 0;
213  nconstituents = 0;
214 
215  for ( reco::Jet::const_iterator ibegin = patJet->begin(),
216  iend = patJet->end(), isub = ibegin;
217  isub != iend; ++isub ) {
218  reco::PFJet const * pfsub = dynamic_cast<reco::PFJet const *>( &*isub );
219  e_chf += pfsub->chargedHadronEnergy();
220  e_nhf += (pfsub->neutralHadronEnergy() + pfsub->HFHadronEnergy());
221  e_cef += pfsub->chargedEmEnergy();
222  e_nef += pfsub->neutralEmEnergy();
223  nch += pfsub->chargedMultiplicity();
224  nconstituents += pfsub->numberOfDaughters();
225  }
226  double e = patJet->energy();
227  if ( e > 0.000001 ) {
228  chf = e_chf / e;
229  nhf = e_nhf / e;
230  cef = e_cef / e;
231  nef = e_nef / e;
232  } else {
233  chf = nhf = cef = nef = 0.0;
234  }
235  }
236  } // end if pat jet
237  else if ( pfJet != 0 ) {
238  chf = pfJet->chargedHadronEnergyFraction();
239  nhf = ( pfJet->neutralHadronEnergy() + pfJet->HFHadronEnergy() ) / pfJet->energy();
240  cef = pfJet->chargedEmEnergyFraction();
241  nef = pfJet->neutralEmEnergyFraction();
242  nch = pfJet->chargedMultiplicity();
243  nconstituents = pfJet->numberOfDaughters();
244  } // end if PF jet
245  // Handle the special case where this is a composed jet for
246  // subjet analyses
247  else if ( basicJet != 0 ) {
248  double e_chf = 0.0;
249  double e_nhf = 0.0;
250  double e_cef = 0.0;
251  double e_nef = 0.0;
252  nch = 0;
253  nconstituents = 0;
254 
255  for ( reco::Jet::const_iterator ibegin = basicJet->begin(),
256  iend = patJet->end(), isub = ibegin;
257  isub != iend; ++isub ) {
258  reco::PFJet const * pfsub = dynamic_cast<reco::PFJet const *>( &*isub );
259  e_chf += pfsub->chargedHadronEnergy();
260  e_nhf += (pfsub->neutralHadronEnergy() + pfsub->HFHadronEnergy());
261  e_cef += pfsub->chargedEmEnergy();
262  e_nef += pfsub->neutralEmEnergy();
263  nch += pfsub->chargedMultiplicity();
264  nconstituents += pfsub->numberOfDaughters();
265  }
266  double e = basicJet->energy();
267  if ( e > 0.000001 ) {
268  chf = e_chf / e;
269  nhf = e_nhf / e;
270  cef = e_cef / e;
271  nef = e_nef / e;
272  }
273  } // end if basic jet
274 
275 
276  // Cuts for all |eta|:
277  if ( ignoreCut(indexNConstituents_) || nconstituents > cut(indexNConstituents_, int() ) ) passCut( ret, indexNConstituents_);
278  if ( ignoreCut(indexNEF_) || ( nef < cut(indexNEF_, double()) ) ) passCut( ret, indexNEF_);
279  if ( ignoreCut(indexNHF_) || ( nhf < cut(indexNHF_, double()) ) ) passCut( ret, indexNHF_);
280  // Cuts for |eta| < 2.4:
281  if ( ignoreCut(indexCEF_) || ( cef < cut(indexCEF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCEF_);
282  if ( ignoreCut(indexCHF_) || ( chf > cut(indexCHF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCHF_);
283  if ( ignoreCut(indexNCH_) || ( nch > cut(indexNCH_, int()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexNCH_);
284 
285  setIgnored( ret );
286  return (bool)ret;
287  }
virtual double energy() const GCC11_FINAL
energy
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:139
float chargedHadronEnergyFraction() const
chargedHadronEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:341
float chargedHadronEnergyFraction() const
chargedHadronEnergyFraction
Definition: PFJet.h:97
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: Jet.h:581
float chargedEmEnergyFraction() const
chargedEmEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:345
#define abs(x)
Definition: mlp_lapack.h:159
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:225
float HFHadronEnergy() const
HFHadronEnergy.
Definition: PFJet.h:115
Jets made from CaloTowers.
Definition: BasicJet.h:21
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:152
Jets made from PFObjects.
Definition: PFJet.h:22
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:147
float neutralEmEnergyFraction() const
neutralEmEnergyFraction
Definition: PFJet.h:149
virtual size_t numberOfDaughters() const
number of daughters
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Definition: Selector.h:177
float HFHadronEnergy() const
HFHadronEnergy.
Definition: Jet.h:363
bool ignoreCut(std::string const &s) const
ignore the cut at index &quot;s&quot;
Definition: Selector.h:160
bool isPFJet() const
check to see if the jet is a reco::PFJet
Definition: Jet.h:226
float chargedEmEnergyFraction() const
chargedEmEnergyFraction
Definition: PFJet.h:141
virtual size_t numberOfDaughters() const
Definition: Jet.h:430
virtual const_iterator begin() const
first daughter const_iterator
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
Analysis-level calorimeter jet class.
Definition: Jet.h:71
virtual const_iterator end() const
last daughter const_iterator
bool isBasicJet() const
check to see if the jet is no more than a reco::BasicJet
Definition: Jet.h:228
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:99
float neutralEmEnergyFraction() const
neutralEmEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:347
int chargedMultiplicity() const
chargedMultiplicity
Definition: Jet.h:609
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:95
int cut(index_type const &i, int val) const
Access the int cut values at index &quot;s&quot;.
Definition: Selector.h:195
bool PFJetIDSelectionFunctor::operator() ( const pat::Jet t,
pat::strbitset ret 
)
inlinevirtual

This provides the interface for base classes to select objects.

Implements Selector< pat::Jet >.

Definition at line 146 of file PFJetIDSelectionFunctor.h.

References pat::Jet::correctedJet(), pat::Jet::currentJECLevel(), FIRSTDATA, firstDataCuts(), run_regression::ret, and version_.

147  {
148  if ( version_ == FIRSTDATA ) {
149  if ( jet.currentJECLevel() == "Uncorrected" )
150  return firstDataCuts( jet, ret );
151  else
152  return firstDataCuts( jet.correctedJet("Uncorrected"), ret );
153  }
154  else {
155  return false;
156  }
157  }
bool firstDataCuts(reco::Jet const &jet, pat::strbitset &ret)
bool PFJetIDSelectionFunctor::operator() ( reco::PFJet const &  jet,
pat::strbitset ret 
)
inline

Definition at line 164 of file PFJetIDSelectionFunctor.h.

References FIRSTDATA, firstDataCuts(), and version_.

166  {
167  if ( version_ == FIRSTDATA ) return firstDataCuts( jet, ret );
168  else {
169  return false;
170  }
171  }
bool firstDataCuts(reco::Jet const &jet, pat::strbitset &ret)

Member Data Documentation

index_type PFJetIDSelectionFunctor::indexCEF_
private

Definition at line 297 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

index_type PFJetIDSelectionFunctor::indexCHF_
private

Definition at line 298 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

index_type PFJetIDSelectionFunctor::indexNCH_
private

Definition at line 299 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

index_type PFJetIDSelectionFunctor::indexNConstituents_
private

Definition at line 294 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

index_type PFJetIDSelectionFunctor::indexNEF_
private

Definition at line 295 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

index_type PFJetIDSelectionFunctor::indexNHF_
private

Definition at line 296 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

Quality_t PFJetIDSelectionFunctor::quality_
private

Definition at line 292 of file PFJetIDSelectionFunctor.h.

Referenced by PFJetIDSelectionFunctor().

Version_t PFJetIDSelectionFunctor::version_
private

Definition at line 291 of file PFJetIDSelectionFunctor.h.

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