CMS 3D CMS Logo

MuonPOGStandardCut.cc
Go to the documentation of this file.
5 
7 {
8 public:
10 
11  result_type operator()(const reco::MuonPtr&) const final;
12  CandidateType candidateType() const final { return MUON; }
13 
15  void getEventContent(const edm::EventBase&) final;
16 
17  double value(const reco::CandidatePtr& cand) const final;
18 
19 private:
20  enum CutType {
23  } cutType_;
25 };
27  MuonPOGStandardCut, "MuonPOGStandardCut");
28 
29 // Define constructors and initialization routines
32 {
33  const auto cutTypeName = c.getParameter<std::string>("idName");
34  if ( cutTypeName == "loose") cutType_ = LOOSE;
35  else if ( cutTypeName == "tight") cutType_ = TIGHT;
36  else if ( cutTypeName == "medium") cutType_ = MEDIUM;
37  else if ( cutTypeName == "soft" ) cutType_ = SOFT;
38  else if ( cutTypeName == "highpt" ) cutType_ = HIGHPT;
39  else
40  {
41  edm::LogError("MuonPOGStandardCut") << "Wrong cut id name, " << cutTypeName;
42  cutType_ = NONE;
43  }
44 
45  contentTags_.emplace("vertices", c.getParameter<edm::InputTag>("vertexSrc"));
46 }
47 
49 {
50  auto vtcs = cc.consumes<reco::VertexCollection>(contentTags_["vertices"]);
51  contentTokens_.emplace("vertices", vtcs);
52 }
53 
55 {
56  ev.getByLabel(contentTags_["vertices"], vtxs_);
57 }
58 
59 // Functors for evaluation
61 {
62  switch( cutType_ ){
63  case LOOSE:
64  return muon::isLooseMuon(*cand);
65  break;
66  case TIGHT:
67  return muon::isTightMuon(*cand, vtxs_->at(0));
68  break;
69  case MEDIUM:
70  return muon::isMediumMuon(*cand);
71  break;
72  case SOFT:
73  return muon::isSoftMuon(*cand, vtxs_->at(0));
74  break;
75  case HIGHPT:
76  return muon::isHighPtMuon(*cand, vtxs_->at(0));
77  break;
78  case NONE:
79  return false;
80  break;
81  }
82 
83  return true;
84 }
85 
88  switch( cutType_ ){
89  case LOOSE:
90  return muon::isLooseMuon(*mu);
91  break;
92  case TIGHT:
93  return muon::isTightMuon(*mu, vtxs_->at(0));
94  break;
95  case MEDIUM:
96  return muon::isMediumMuon(*mu);
97  break;
98  case SOFT:
99  return muon::isSoftMuon(*mu, vtxs_->at(0));
100  break;
101  case HIGHPT:
102  return muon::isHighPtMuon(*mu, vtxs_->at(0));
103  break;
104  case NONE:
105  return 0.0;
106  break;
107  }
108  return 1.0;
109  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
void setConsumes(edm::ConsumesCollector &) final
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
double value(const reco::CandidatePtr &cand) const final
CandidateType candidateType() const final
enum MuonPOGStandardCut::CutType cutType_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool ev
std::unordered_map< std::string, edm::InputTag > contentTags_
bool isLooseMuon(const reco::Muon &)
MuonPOGStandardCut(const edm::ParameterSet &c)
const int mu
Definition: Constants.h:22
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
result_type operator()(const reco::MuonPtr &) const final
edm::Handle< reco::VertexCollection > vtxs_
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
void getEventContent(const edm::EventBase &) final
#define DEFINE_EDM_PLUGIN(factory, type, name)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)