CMS 3D CMS Logo

MuonDzCut.cc
Go to the documentation of this file.
5 
7 public:
9 
10  result_type operator()(const reco::MuonPtr&) const final;
11  CandidateType candidateType() const final { return MUON; }
12  double value(const reco::CandidatePtr&) const final;
13 
15  void getEventContent(const edm::EventBase&) final;
16 
17 private:
19  const double maxDz_;
21 };
23 
24 // Define constructors and initialization routines
26  : CutApplicatorWithEventContentBase(c), maxDz_(c.getParameter<double>("maxDz")) {
27  const std::string trackTypeName = c.getParameter<std::string>("trackType");
28  trackType_ = NONE;
29  if (trackTypeName == "muonBestTrack")
31  else if (trackTypeName == "innerTrack")
33  else {
34  edm::LogError("MuonDzCut") << "Wrong cut id name, " << trackTypeName
35  << "Choose among \"muonBestTrack\", \"innerTrack\"";
36  trackType_ = NONE;
37  }
38 
39  contentTags_.emplace("vertices", c.getParameter<edm::InputTag>("vertexSrc"));
40  contentTags_.emplace("verticesMiniAOD", c.getParameter<edm::InputTag>("vertexSrcMiniAOD"));
41 }
42 
44  contentTokens_.emplace("vertices", cc.consumes<reco::VertexCollection>(contentTags_["vertices"]));
45  contentTokens_.emplace("verticesMiniAOD", cc.consumes<reco::VertexCollection>(contentTags_["verticesMiniAOD"]));
46 }
47 
49  ev.getByLabel(contentTags_["vertices"], vtxs_);
50  if (!vtxs_.isValid())
51  ev.getByLabel(contentTags_["verticesMiniAOD"], vtxs_);
52 }
53 
54 // Functors for evaluation
56  const auto& vtxPos = vtxs_->at(0).position();
57 
58  reco::TrackRef trackRef;
59  if (trackType_ == INNERTRACK)
60  trackRef = cand->innerTrack();
61  else if (trackType_ == MUONBESTTRACK)
62  trackRef = cand->muonBestTrack();
63 
64  return trackRef.isNonnull() and std::abs(trackRef->dz(vtxPos)) <= maxDz_;
65 }
66 
68  const reco::MuonPtr muon(cand);
69  reco::TrackRef trackRef;
70  if (trackType_ == INNERTRACK)
71  trackRef = muon->innerTrack();
72  else if (trackType_ == MUONBESTTRACK)
73  trackRef = muon->muonBestTrack();
74  if (trackRef.isNull())
75  return -1;
76 
77  const auto& vtxPos = vtxs_->at(0).position();
78  return std::abs(trackRef->dz(vtxPos));
79 }
MuonDzCut::MUONBESTTRACK
Definition: MuonDzCut.cc:20
MuonDzCut::MuonDzCut
MuonDzCut(const edm::ParameterSet &c)
Definition: MuonDzCut.cc:25
Muon.h
MuonDzCut::trackType_
enum MuonDzCut::BestTrackType trackType_
MuonDzCut::candidateType
CandidateType candidateType() const final
Definition: MuonDzCut.cc:11
muon
Definition: MuonCocktails.h:17
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
MuonDzCut::value
double value(const reco::CandidatePtr &) const final
Definition: MuonDzCut.cc:67
MuonDzCut::getEventContent
void getEventContent(const edm::EventBase &) final
Definition: MuonDzCut.cc:48
watchdog.const
const
Definition: watchdog.py:83
edm::Handle< reco::VertexCollection >
edm::Ref< TrackCollection >
CutApplicatorWithEventContentBase::contentTags_
std::unordered_map< std::string, edm::InputTag > contentTags_
Definition: CutApplicatorWithEventContentBase.h:35
candidate_functions::CandidateCut::result_type
bool result_type
Definition: CandidateCut.h:11
MuonDzCut::operator()
result_type operator()(const reco::MuonPtr &) const final
Definition: MuonDzCut.cc:55
MuonDzCut::maxDz_
const double maxDz_
Definition: MuonDzCut.cc:19
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
MuonSelectors.h
MuonDzCut
Definition: MuonDzCut.cc:6
CutApplicatorWithEventContentBase.h
MuonDzCut::vtxs_
edm::Handle< reco::VertexCollection > vtxs_
Definition: MuonDzCut.cc:18
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
CutApplicatorBase::MUON
Definition: CutApplicatorBase.h:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
CutApplicatorBase::CandidateType
CandidateType
Definition: CutApplicatorBase.h:47
edmplugin::PluginFactory
Definition: PluginFactory.h:34
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
cand
Definition: decayParser.h:32
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
cc
edm::Ptr< reco::Muon >
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
CutApplicatorWithEventContentBase::contentTokens_
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
Definition: CutApplicatorWithEventContentBase.h:40
edm::EventBase
Definition: EventBase.h:46
MuonDzCut::NONE
Definition: MuonDzCut.cc:20
MuonDzCut::BestTrackType
BestTrackType
Definition: MuonDzCut.cc:20
MuonDzCut::setConsumes
void setConsumes(edm::ConsumesCollector &) final
Definition: MuonDzCut.cc:43
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CutApplicatorBase.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
MuonDzCut::INNERTRACK
Definition: MuonDzCut.cc:20
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
CutApplicatorWithEventContentBase
Definition: CutApplicatorWithEventContentBase.h:19