CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonPOGStandardCut.cc
Go to the documentation of this file.
5 
7 {
8 public:
10 
11  result_type operator()(const reco::MuonPtr&) const override final;
12  CandidateType candidateType() const override final { return MUON; }
13 
14  void setConsumes(edm::ConsumesCollector&) override final;
15  void getEventContent(const edm::EventBase&) override final;
16 
17  double value(const reco::CandidatePtr& cand) const override 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
60 CutApplicatorBase::result_type MuonPOGStandardCut::operator()(const reco::MuonPtr& cand) const
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 
86 double MuonPOGStandardCut::value(const reco::CandidatePtr& cand) const {
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 false;
106  break;
107  }
108  return 1.0;
109  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
void getEventContent(const edm::EventBase &) overridefinal
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
enum MuonPOGStandardCut::CutType cutType_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool ev
CandidateType candidateType() const overridefinal
bool isMediumMuon(const reco::Muon &)
std::unordered_map< std::string, edm::InputTag > contentTags_
bool isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
MuonPOGStandardCut(const edm::ParameterSet &c)
const int mu
Definition: Constants.h:22
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
double value(const reco::CandidatePtr &cand) const overridefinal
string const
Definition: compareJSON.py:14
edm::Handle< reco::VertexCollection > vtxs_
#define private
Definition: FWFileEntry.h:17
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
result_type operator()(const reco::MuonPtr &) const overridefinal
#define DEFINE_EDM_PLUGIN(factory, type, name)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
void setConsumes(edm::ConsumesCollector &) overridefinal