CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
WSelector Class Reference

Example class of an EventSelector to apply a simple W Boson selection. More...

#include "PhysicsTools/FWLite/interface/WSelector.h"

Inheritance diagram for WSelector:
EventSelector EventSelector

Public Member Functions

pat::MET const & met () const
 return MET of W boson More...
 
pat::MET const & met () const
 return MET of W boson More...
 
bool operator() (edm::EventBase const &event, pat::strbitset &ret) override
 here is where the selection occurs More...
 
virtual bool operator() (edm::EventBase const &event, pat::strbitset &ret)
 here is where the selection occurs More...
 
pat::Muon const & wMuon () const
 return muon candidate of W boson More...
 
pat::Muon const & wMuon () const
 return muon candidate of W boson More...
 
 WSelector (edm::ParameterSet const &params)
 constructor More...
 
 WSelector (edm::ParameterSet const &params)
 constructor More...
 
 ~WSelector () override
 destructor More...
 
virtual ~WSelector ()
 destructor More...
 
- Public Member Functions inherited from EventSelector
const std::vector< std::string > & description ()
 
 EventSelector ()
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
const std::string & name () const
 name of the module (from configuration) More...
 
virtual bool select (const edm::Event &) const =0
 decision of the selector module More...
 
virtual ~EventSelector ()
 

Protected Attributes

pat::MET const * met_
 MET from W boson. More...
 
index_type metIndex_
 index for MET cut More...
 
edm::InputTag metSrc_
 met input More...
 
index_type muonPtIndex_
 index for muon Pt cut More...
 
edm::InputTag muonSrc_
 muon input More...
 
pat::Muon const * wMuon_
 muon candidate from W boson More...
 
- Protected Attributes inherited from EventSelector
std::vector< std::string > description_
 
std::string name_
 

Detailed Description

Example class of an EventSelector to apply a simple W Boson selection.

Example class for of an EventSelector as defined in the SelectorUtils package. EventSelectors may be used to facilitate cutflows and to implement selections independent from the event loop in FWLite or full framework.

Definition at line 17 of file WSelector.h.

Constructor & Destructor Documentation

WSelector::WSelector ( edm::ParameterSet const &  params)
inline

constructor

Definition at line 21 of file WSelector.h.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), met_, wplusjetsAnalysis_cfi::metMin, mhtProducer_cfi::muonPtMin, and wMuon_.

21  :
22  muonSrc_(params.getParameter<edm::InputTag>("muonSrc")),
23  metSrc_ (params.getParameter<edm::InputTag>("metSrc"))
24  {
25  double muonPtMin = params.getParameter<double>("muonPtMin");
26  double metMin = params.getParameter<double>("metMin");
27  push_back("Muon Pt", muonPtMin );
28  push_back("MET" , metMin );
29  set("Muon Pt"); set("MET");
30  wMuon_ = nullptr; met_ = nullptr;
31  if ( params.exists("cutsToIgnore") ){
32  setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );
33  }
34  retInternal_ = getBitTemplate();
35  }
edm::InputTag muonSrc_
muon input
Definition: WSelector.h:78
edm::InputTag metSrc_
met input
Definition: WSelector.h:80
pat::MET const * met_
MET from W boson.
Definition: WSelector.h:84
pat::Muon const * wMuon_
muon candidate from W boson
Definition: WSelector.h:82
WSelector::~WSelector ( )
inlineoverride

destructor

Definition at line 37 of file WSelector.h.

37 {}
WSelector::WSelector ( edm::ParameterSet const &  params)
inline

constructor

Definition at line 21 of file WSelectorFast.h.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), met_, wplusjetsAnalysis_cfi::metMin, mhtProducer_cfi::muonPtMin, and wMuon_.

21  :
22  muonSrc_(params.getParameter<edm::InputTag>("muonSrc")),
23  metSrc_ (params.getParameter<edm::InputTag>("metSrc"))
24  {
25  double muonPtMin = params.getParameter<double>("muonPtMin");
26  double metMin = params.getParameter<double>("metMin");
27  push_back("Muon Pt", muonPtMin );
28  push_back("MET" , metMin );
29  set("Muon Pt"); set("MET");
30  wMuon_ = 0; met_ = 0;
31  if ( params.exists("cutsToIgnore") ){
32  setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );
33  }
34  retInternal_ = getBitTemplate();
35  }
edm::InputTag muonSrc_
muon input
Definition: WSelector.h:78
edm::InputTag metSrc_
met input
Definition: WSelector.h:80
pat::MET const * met_
MET from W boson.
Definition: WSelector.h:84
pat::Muon const * wMuon_
muon candidate from W boson
Definition: WSelector.h:82
virtual WSelector::~WSelector ( )
inlinevirtual

destructor

Definition at line 37 of file WSelectorFast.h.

37 {}

Member Function Documentation

pat::MET const& WSelector::met ( ) const
inline

return MET of W boson

Definition at line 41 of file WSelector.h.

References met_.

Referenced by operator()().

41 { return *met_; }
pat::MET const * met_
MET from W boson.
Definition: WSelector.h:84
pat::MET const& WSelector::met ( ) const
inline

return MET of W boson

Definition at line 41 of file WSelectorFast.h.

References met_.

41 { return *met_; }
pat::MET const * met_
MET from W boson.
Definition: WSelector.h:84
virtual bool WSelector::operator() ( edm::EventBase const &  event,
pat::strbitset ret 
)
inlinevirtual

here is where the selection occurs

Definition at line 44 of file WSelectorFast.h.

References TkAlMuonSelectors_cfi::cut, met(), met_, metIndex_, metSrc_, muonPtIndex_, nano_cff::muons, muonSrc_, reco::LeafCandidate::pt(), pat::strbitset::set(), and wMuon_.

44  {
45  ret.set(false);
46  // Handle to the muon collection
48  // Handle to the MET collection
50  // get the objects from the event
51  bool gotMuons = event.getByLabel(muonSrc_, muons);
52  bool gotMET = event.getByLabel(metSrc_, met );
53  // get the MET, require to be > minimum
54  if( gotMET ){
55  met_ = &met->at(0);
56  if( met_->pt() > cut(metIndex_, double()) || ignoreCut(metIndex_) )
57  passCut(ret, metIndex_);
58  }
59  // get the highest pt muon, require to have pt > minimum
60  if( gotMuons ){
61  if( !ignoreCut(muonPtIndex_) ){
62  if( muons->size() > 0 ){
63  wMuon_ = &muons->at(0);
64  if ( wMuon_->pt() > cut(muonPtIndex_, double()) || ignoreCut(muonPtIndex_) )
65  passCut(ret, muonPtIndex_);
66  }
67  }
68  else{
69  passCut( ret, muonPtIndex_);
70  }
71  }
72  setIgnored(ret);
73  return (bool)ret;
74  }
index_type metIndex_
index for MET cut
Definition: WSelectorFast.h:88
edm::InputTag muonSrc_
muon input
Definition: WSelector.h:78
double pt() const final
transverse momentum
edm::InputTag metSrc_
met input
Definition: WSelector.h:80
pat::MET const & met() const
return MET of W boson
Definition: WSelector.h:41
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
pat::MET const * met_
MET from W boson.
Definition: WSelector.h:84
index_type muonPtIndex_
index for muon Pt cut
Definition: WSelectorFast.h:86
pat::Muon const * wMuon_
muon candidate from W boson
Definition: WSelector.h:82
bool WSelector::operator() ( edm::EventBase const &  event,
pat::strbitset ret 
)
inlineoverride

here is where the selection occurs

Definition at line 44 of file WSelector.h.

References TkAlMuonSelectors_cfi::cut, met(), met_, metSrc_, nano_cff::muons, muonSrc_, reco::LeafCandidate::pt(), pat::strbitset::set(), and wMuon_.

44  {
45  ret.set(false);
46  // Handle to the muon collection
48  // Handle to the MET collection
50  // get the objects from the event
51  bool gotMuons = event.getByLabel(muonSrc_, muons);
52  bool gotMET = event.getByLabel(metSrc_, met );
53  // get the MET, require to be > minimum
54  if( gotMET ){
55  met_ = &met->at(0);
56  if( met_->pt() > cut("MET", double()) || ignoreCut("MET") )
57  passCut(ret, "MET");
58  }
59  // get the highest pt muon, require to have pt > minimum
60  if( gotMuons ){
61  if( !ignoreCut("Muon Pt") ){
62  if( !muons->empty() ){
63  wMuon_ = &muons->at(0);
64  if( wMuon_->pt() > cut("Muon Pt", double()) || ignoreCut("Muon Pt") )
65  passCut(ret, "Muon Pt");
66  }
67  }
68  else{
69  passCut( ret, "Muon Pt");
70  }
71  }
72  setIgnored(ret);
73  return (bool)ret;
74  }
edm::InputTag muonSrc_
muon input
Definition: WSelector.h:78
double pt() const final
transverse momentum
edm::InputTag metSrc_
met input
Definition: WSelector.h:80
pat::MET const & met() const
return MET of W boson
Definition: WSelector.h:41
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
pat::MET const * met_
MET from W boson.
Definition: WSelector.h:84
pat::Muon const * wMuon_
muon candidate from W boson
Definition: WSelector.h:82
pat::Muon const& WSelector::wMuon ( ) const
inline

return muon candidate of W boson

Definition at line 39 of file WSelectorFast.h.

References wMuon_.

39 { return *wMuon_;}
pat::Muon const * wMuon_
muon candidate from W boson
Definition: WSelector.h:82
pat::Muon const& WSelector::wMuon ( ) const
inline

return muon candidate of W boson

Definition at line 39 of file WSelector.h.

References wMuon_.

39 { return *wMuon_;}
pat::Muon const * wMuon_
muon candidate from W boson
Definition: WSelector.h:82

Member Data Documentation

pat::MET const * WSelector::met_
protected

MET from W boson.

Definition at line 84 of file WSelector.h.

Referenced by met(), operator()(), and WSelector().

index_type WSelector::metIndex_
protected

index for MET cut

Definition at line 88 of file WSelectorFast.h.

Referenced by operator()().

edm::InputTag WSelector::metSrc_
protected

met input

Definition at line 80 of file WSelector.h.

Referenced by operator()().

index_type WSelector::muonPtIndex_
protected

index for muon Pt cut

Definition at line 86 of file WSelectorFast.h.

Referenced by operator()().

edm::InputTag WSelector::muonSrc_
protected

muon input

Definition at line 78 of file WSelector.h.

Referenced by operator()().

pat::Muon const * WSelector::wMuon_
protected

muon candidate from W boson

Definition at line 82 of file WSelector.h.

Referenced by operator()(), wMuon(), and WSelector().