CMS 3D CMS Logo

WSelector.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_FWLite_WSelector_h
2 #define PhysicsTools_FWLite_WSelector_h
6 
17 class WSelector : public EventSelector {
18 
19 public:
21  WSelector(edm::ParameterSet const& params) :
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  }
37  ~WSelector() override {}
39  pat::Muon const& wMuon() const { return *wMuon_;}
41  pat::MET const& met() const { return *met_; }
42 
44  bool operator()( edm::EventBase const & event, pat::strbitset & ret) override{
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  }
75 
76 protected:
82  pat::Muon const* wMuon_;
84  pat::MET const* met_;
85 };
86 #endif // PhysicsTools_FWLite_WSelector_h
Analysis-level MET class.
Definition: MET.h:40
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
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::Muon const & wMuon() const
return muon candidate of W boson
Definition: WSelector.h:39
WSelector(edm::ParameterSet const &params)
constructor
Definition: WSelector.h:21
pat::MET const & met() const
return MET of W boson
Definition: WSelector.h:41
~WSelector() override
destructor
Definition: WSelector.h:37
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
bool operator()(edm::EventBase const &event, pat::strbitset &ret) override
here is where the selection occurs
Definition: WSelector.h:44
A selector of events.
Definition: EventSelector.h:16
HLT enums.
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
Example class of an EventSelector to apply a simple W Boson selection.
Definition: WSelector.h:17
Analysis-level muon class.
Definition: Muon.h:51
Definition: event.py:1