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 
16 class WSelector : public EventSelector {
17 public:
20  : muonSrc_(params.getParameter<edm::InputTag>("muonSrc")), metSrc_(params.getParameter<edm::InputTag>("metSrc")) {
21  double muonPtMin = params.getParameter<double>("muonPtMin");
22  double metMin = params.getParameter<double>("metMin");
23  push_back("Muon Pt", muonPtMin);
24  push_back("MET", metMin);
25  set("Muon Pt");
26  set("MET");
27  wMuon_ = nullptr;
28  met_ = nullptr;
29  if (params.exists("cutsToIgnore")) {
30  setIgnoredCuts(params.getParameter<std::vector<std::string> >("cutsToIgnore"));
31  }
32  retInternal_ = getBitTemplate();
33  }
35  ~WSelector() override {}
37  pat::Muon const& wMuon() const { return *wMuon_; }
39  pat::MET const& met() const { return *met_; }
40 
42  bool operator()(edm::EventBase const& event, pat::strbitset& ret) override {
43  ret.set(false);
44  // Handle to the muon collection
46  // Handle to the MET collection
48  // get the objects from the event
49  bool gotMuons = event.getByLabel(muonSrc_, muons);
50  bool gotMET = event.getByLabel(metSrc_, met);
51  // get the MET, require to be > minimum
52  if (gotMET) {
53  met_ = &met->at(0);
54  if (met_->pt() > cut("MET", double()) || ignoreCut("MET"))
55  passCut(ret, "MET");
56  }
57  // get the highest pt muon, require to have pt > minimum
58  if (gotMuons) {
59  if (!ignoreCut("Muon Pt")) {
60  if (!muons->empty()) {
61  wMuon_ = &muons->at(0);
62  if (wMuon_->pt() > cut("Muon Pt", double()) || ignoreCut("Muon Pt"))
63  passCut(ret, "Muon Pt");
64  }
65  } else {
66  passCut(ret, "Muon Pt");
67  }
68  }
69  setIgnored(ret);
70  return (bool)ret;
71  }
72 
73 protected:
79  pat::Muon const* wMuon_;
81  pat::MET const* met_;
82 };
83 #endif // PhysicsTools_FWLite_WSelector_h
Analysis-level MET class.
Definition: MET.h:40
double pt() const final
transverse momentum
ret
prodAgent to be discontinued
pat::Muon const & wMuon() const
return muon candidate of W boson
Definition: WSelector.h:37
edm::InputTag muonSrc_
muon input
Definition: WSelector.h:75
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:212
edm::InputTag metSrc_
met input
Definition: WSelector.h:77
WSelector(edm::ParameterSet const &params)
constructor
Definition: WSelector.h:19
~WSelector() override
destructor
Definition: WSelector.h:35
pat::MET const * met_
MET from W boson.
Definition: WSelector.h:81
bool operator()(edm::EventBase const &event, pat::strbitset &ret) override
here is where the selection occurs
Definition: WSelector.h:42
A selector of events.
Definition: EventSelector.h:16
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
pat::MET const & met() const
return MET of W boson
Definition: WSelector.h:39
HLT enums.
pat::Muon const * wMuon_
muon candidate from W boson
Definition: WSelector.h:79
Example class of an EventSelector to apply a simple W Boson selection.
Definition: WSelector.h:16
Analysis-level muon class.
Definition: Muon.h:51
Definition: event.py:1