Validation
RecoTau
plugins
MuonFromPVSelector.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/global/EDProducer.h
"
2
#include "
FWCore/Framework/interface/Event.h
"
3
#include "
FWCore/Framework/interface/MakerMacros.h
"
4
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
5
#include "
FWCore/Utilities/interface/InputTag.h
"
6
7
#include "
CommonTools/Utils/interface/StringCutObjectSelector.h
"
8
9
#include "
DataFormats/MuonReco/interface/Muon.h
"
10
#include "
DataFormats/MuonReco/interface/MuonFwd.h
"
11
12
#include "
DataFormats/VertexReco/interface/Vertex.h
"
13
#include "
DataFormats/VertexReco/interface/VertexFwd.h
"
14
15
#include <memory>
16
#include <numeric>
17
#include <vector>
18
20
// class definition
22
class
MuonFromPVSelector
:
public
edm::global::EDProducer
<> {
23
public
:
24
explicit
MuonFromPVSelector
(
edm::ParameterSet
const
&);
25
void
produce
(
edm::StreamID
,
edm::Event
&,
edm::EventSetup
const
&)
const override
;
26
27
private
:
28
double
max_dxy_
;
29
double
max_dz_
;
30
edm::EDGetTokenT<std::vector<reco::Vertex>
>
v_recoVertexToken_
;
31
edm::EDGetTokenT<std::vector<reco::Muon>
>
v_recoMuonToken_
;
32
};
33
35
// construction
37
38
MuonFromPVSelector::MuonFromPVSelector
(
edm::ParameterSet
const
& iConfig)
39
: max_dxy_{iConfig.
getParameter
<
double
>(
"max_dxy"
)},
40
max_dz_{iConfig.getParameter<
double
>(
"max_dz"
)},
41
v_recoVertexToken_{consumes<std::vector<reco::Vertex>>(iConfig.getParameter<
edm::InputTag
>(
"srcVertex"
))},
42
v_recoMuonToken_{consumes<std::vector<reco::Muon>>(iConfig.getParameter<
edm::InputTag
>(
"srcMuon"
))} {
43
produces<std::vector<reco::Muon>>();
44
}
45
47
// implementation of member functions
49
50
void
MuonFromPVSelector::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
edm::EventSetup
const
&)
const
{
51
auto
goodMuons
= std::make_unique<std::vector<reco::Muon>>();
52
53
edm::Handle<std::vector<reco::Vertex>
>
vertices
;
54
iEvent
.getByToken(
v_recoVertexToken_
,
vertices
);
55
56
edm::Handle<std::vector<reco::Muon>
>
muons
;
57
iEvent
.getByToken(
v_recoMuonToken_
,
muons
);
58
59
if
(!
vertices
->empty()) {
60
auto
const
&
pv
=
vertices
->front();
61
std::copy_if(std::cbegin(*
muons
), std::cend(*
muons
), std::back_inserter(*
goodMuons
), [&
pv
,
this
](
auto
const
&
muon
) {
62
return
muon
.innerTrack().isNonnull() &&
std::abs
(
muon
.innerTrack()->dxy(
pv
.position())) <
max_dxy_
&&
63
std::abs
(
muon
.innerTrack()->dz(
pv
.position())) <
max_dz_
;
64
});
65
}
66
67
iEvent
.put(
std::move
(
goodMuons
));
68
}
69
70
DEFINE_FWK_MODULE
(
MuonFromPVSelector
);
edm::StreamID
Definition:
StreamID.h:30
PDWG_BPHSkim_cff.muons
muons
Definition:
PDWG_BPHSkim_cff.py:47
Muon.h
muon
Definition:
MuonCocktails.h:17
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm::Handle
Definition:
AssociativeIterator.h:50
AlignmentTracksFromVertexSelector_cfi.vertices
vertices
Definition:
AlignmentTracksFromVertexSelector_cfi.py:5
MuonFromPVSelector::v_recoVertexToken_
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_
Definition:
MuonFromPVSelector.cc:30
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
MuonFwd.h
MuonFromPVSelector::MuonFromPVSelector
MuonFromPVSelector(edm::ParameterSet const &)
Definition:
MuonFromPVSelector.cc:38
edm::global::EDProducer
Definition:
EDProducer.h:32
MuonFromPVSelector::v_recoMuonToken_
edm::EDGetTokenT< std::vector< reco::Muon > > v_recoMuonToken_
Definition:
MuonFromPVSelector.cc:31
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
MetAnalyzer.pv
def pv(vc)
Definition:
MetAnalyzer.py:7
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:58
InputTag.h
VertexFwd.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
StringCutObjectSelector.h
Vertex.h
MuonFromPVSelector::max_dz_
double max_dz_
Definition:
MuonFromPVSelector.cc:29
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
MuonFromPVSelector::max_dxy_
double max_dxy_
Definition:
MuonFromPVSelector.cc:28
funct::abs
Abs< T >::type abs(const T &t)
Definition:
Abs.h:22
ParameterSet.h
MuonFromPVSelector
Definition:
MuonFromPVSelector.cc:22
EDProducer.h
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
goodMuons_cfi.goodMuons
goodMuons
Definition:
goodMuons_cfi.py:3
MuonFromPVSelector::produce
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition:
MuonFromPVSelector.cc:50
Generated for CMSSW Reference Manual by
1.8.16