Main Page
Namespaces
Classes
Package Documentation
RecoMuon
MuonIdentification
plugins
cuts
MuonDxyCut.cc
Go to the documentation of this file.
1
#include "
PhysicsTools/SelectorUtils/interface/CutApplicatorBase.h
"
2
#include "
PhysicsTools/SelectorUtils/interface/CutApplicatorWithEventContentBase.h
"
3
#include "
DataFormats/MuonReco/interface/Muon.h
"
4
#include "
DataFormats/MuonReco/interface/MuonSelectors.h
"
5
6
class
MuonDxyCut
:
public
CutApplicatorWithEventContentBase
{
7
public
:
8
MuonDxyCut
(
const
edm::ParameterSet
&
c
);
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
14
void
setConsumes
(
edm::ConsumesCollector
&)
final
;
15
void
getEventContent
(
const
edm::EventBase
&)
final
;
16
17
private
:
18
edm::Handle<reco::VertexCollection>
vtxs_
;
19
const
double
maxDxy_
;
20
enum
BestTrackType
{
INNERTRACK
,
MUONBESTTRACK
,
NONE
}
trackType_
;
21
};
22
DEFINE_EDM_PLUGIN
(
CutApplicatorFactory
,
MuonDxyCut
,
"MuonDxyCut"
);
23
24
// Define constructors and initialization routines
25
MuonDxyCut::MuonDxyCut
(
const
edm::ParameterSet
&
c
)
26
:
CutApplicatorWithEventContentBase
(c),
maxDxy_
(c.getParameter<double>(
"maxDxy"
)) {
27
const
std::string
trackTypeName = c.
getParameter
<
std::string
>(
"trackType"
);
28
trackType_
=
NONE
;
29
if
(trackTypeName ==
"muonBestTrack"
)
30
trackType_ =
MUONBESTTRACK
;
31
else
if
(trackTypeName ==
"innerTrack"
)
32
trackType_ =
INNERTRACK
;
33
else
{
34
edm::LogError
(
"MuonDxyCut"
) <<
"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
43
void
MuonDxyCut::setConsumes
(
edm::ConsumesCollector
& cc) {
44
contentTokens_
.emplace(
"vertices"
, cc.
consumes
<
reco::VertexCollection
>(
contentTags_
[
"vertices"
]));
45
contentTokens_
.emplace(
"verticesMiniAOD"
, cc.
consumes
<
reco::VertexCollection
>(
contentTags_
[
"verticesMiniAOD"
]));
46
}
47
48
void
MuonDxyCut::getEventContent
(
const
edm::EventBase
&
ev
) {
49
ev.
getByLabel
(
contentTags_
[
"vertices"
],
vtxs_
);
50
if
(!
vtxs_
.
isValid
())
51
ev.
getByLabel
(
contentTags_
[
"verticesMiniAOD"
],
vtxs_
);
52
}
53
54
// Functors for evaluation
55
CutApplicatorBase::result_type
MuonDxyCut::operator()
(
const
reco::MuonPtr
&
cand
)
const
{
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->dxy(vtxPos)) <=
maxDxy_
;
65
}
66
67
double
MuonDxyCut::value
(
const
reco::CandidatePtr
&
cand
)
const
{
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->dxy(vtxPos));
79
}
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
ConsumesCollector.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CutApplicatorWithEventContentBase
Definition:
CutApplicatorWithEventContentBase.h:19
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition:
Ref.h:238
MuonDxyCut::INNERTRACK
Definition:
MuonDxyCut.cc:20
CutApplicatorWithEventContentBase::contentTags_
std::unordered_map< std::string, edm::InputTag > contentTags_
Definition:
CutApplicatorWithEventContentBase.h:35
reco::Muon::innerTrack
virtual TrackRef innerTrack() const
Definition:
Muon.h:45
edm::Ref< TrackCollection >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Handle< reco::VertexCollection >
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition:
VertexFwd.h:9
ev
bool ev
Definition:
Hydjet2Hadronizer.cc:95
MuonDxyCut::MuonDxyCut
MuonDxyCut(const edm::ParameterSet &c)
Definition:
MuonDxyCut.cc:25
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:31
MuonDxyCut::operator()
result_type operator()(const reco::MuonPtr &) const final
Definition:
MuonDxyCut.cc:55
MuonDxyCut::trackType_
enum MuonDxyCut::BestTrackType trackType_
MuonDxyCut::getEventContent
void getEventContent(const edm::EventBase &) final
Definition:
MuonDxyCut.cc:48
MuonDxyCut::vtxs_
edm::Handle< reco::VertexCollection > vtxs_
Definition:
MuonDxyCut.cc:18
edm::LogError
Definition:
MessageLogger.h:183
reco::Muon::muonBestTrack
virtual TrackRef muonBestTrack() const
Definition:
Muon.h:60
watchdog.const
const
Definition:
watchdog.py:83
edmplugin::PluginFactory
Definition:
PluginFactory.h:34
MuonDxyCut::MUONBESTTRACK
Definition:
MuonDxyCut.cc:20
candidate_functions::CandidateCut::result_type
bool result_type
Definition:
CandidateCut.h:11
funct::abs
Abs< T >::type abs(const T &t)
Definition:
Abs.h:22
CutApplicatorWithEventContentBase.h
edm::Ptr< reco::Muon >
MuonDxyCut::BestTrackType
BestTrackType
Definition:
MuonDxyCut.cc:20
Muon.h
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:70
MuonDxyCut::NONE
Definition:
MuonDxyCut.cc:20
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition:
Ref.h:235
edm::EventBase
Definition:
EventBase.h:46
CutApplicatorWithEventContentBase::contentTokens_
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
Definition:
CutApplicatorWithEventContentBase.h:40
HLT_2018_cff.muon
muon
Definition:
HLT_2018_cff.py:10336
MuonSelectors.h
MuonDxyCut::maxDxy_
const double maxDxy_
Definition:
MuonDxyCut.cc:19
CutApplicatorBase::MUON
Definition:
CutApplicatorBase.h:47
edm::EventBase::getByLabel
bool getByLabel(InputTag const &, Handle< T > &) const
Definition:
EventBase.h:92
edm::InputTag
Definition:
InputTag.h:15
MuonDxyCut::value
double value(const reco::CandidatePtr &) const final
Definition:
MuonDxyCut.cc:67
CutApplicatorBase::CandidateType
CandidateType
Definition:
CutApplicatorBase.h:47
MuonDxyCut::candidateType
CandidateType candidateType() const final
Definition:
MuonDxyCut.cc:11
edm::ParameterSet
Definition:
ParameterSet.h:36
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition:
PluginFactory.h:124
cand
Definition:
decayParser.h:34
CutApplicatorBase.h
MuonDxyCut::setConsumes
void setConsumes(edm::ConsumesCollector &) final
Definition:
MuonDxyCut.cc:43
MuonDxyCut
Definition:
MuonDxyCut.cc:6
edm::ConsumesCollector
Definition:
ConsumesCollector.h:39
Generated for CMSSW Reference Manual by
1.8.11