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
}
MuonDxyCut::BestTrackType
BestTrackType
Definition:
MuonDxyCut.cc:20
MuonDxyCut::vtxs_
edm::Handle< reco::VertexCollection > vtxs_
Definition:
MuonDxyCut.cc:18
Muon.h
MuonDxyCut::maxDxy_
const double maxDxy_
Definition:
MuonDxyCut.cc:19
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
MuonDxyCut::MUONBESTTRACK
Definition:
MuonDxyCut.cc:20
MuonDxyCut::operator()
result_type operator()(const reco::MuonPtr &) const final
Definition:
MuonDxyCut.cc:55
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
MuonDxyCut::setConsumes
void setConsumes(edm::ConsumesCollector &) final
Definition:
MuonDxyCut.cc:43
MuonDxyCut::INNERTRACK
Definition:
MuonDxyCut.cc:20
HLT_FULL_cff.muon
muon
Definition:
HLT_FULL_cff.py:11710
MuonSelectors.h
CutApplicatorWithEventContentBase.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition:
PluginFactory.h:124
CutApplicatorBase::MUON
Definition:
CutApplicatorBase.h:47
MuonDxyCut
Definition:
MuonDxyCut.cc:6
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
MuonDxyCut::value
double value(const reco::CandidatePtr &) const final
Definition:
MuonDxyCut.cc:67
MuonDxyCut::NONE
Definition:
MuonDxyCut.cc:20
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition:
MessageLogger.h:123
cc
MuonDxyCut::getEventContent
void getEventContent(const edm::EventBase &) final
Definition:
MuonDxyCut.cc:48
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
MuonDxyCut::MuonDxyCut
MuonDxyCut(const edm::ParameterSet &c)
Definition:
MuonDxyCut.cc:25
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
edm::InputTag
Definition:
InputTag.h:15
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
MuonDxyCut::trackType_
enum MuonDxyCut::BestTrackType trackType_
CutApplicatorWithEventContentBase
Definition:
CutApplicatorWithEventContentBase.h:19
MuonDxyCut::candidateType
CandidateType candidateType() const final
Definition:
MuonDxyCut.cc:11
Generated for CMSSW Reference Manual by
1.8.16