TopQuarkAnalysis
TopTools
plugins
MuonSelectorVertex.cc
Go to the documentation of this file.
1
//
2
//
3
4
#include "
FWCore/Framework/interface/EDProducer.h
"
5
#include "
FWCore/Framework/interface/Event.h
"
6
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
7
8
#include "
DataFormats/PatCandidates/interface/Muon.h
"
9
#include "
DataFormats/VertexReco/interface/Vertex.h
"
10
11
class
MuonSelectorVertex
:
public
edm::EDProducer
{
12
public
:
13
explicit
MuonSelectorVertex
(
const
edm::ParameterSet
& iConfig);
14
~MuonSelectorVertex
()
override
{};
15
void
produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
override
;
16
17
private
:
18
edm::EDGetTokenT<std::vector<pat::Muon>
>
muonSource_
;
19
edm::EDGetTokenT<std::vector<reco::Vertex>
>
vertexSource_
;
20
double
maxDZ_
;
21
};
22
23
#include <vector>
24
#include <memory>
25
#include <cmath>
26
27
MuonSelectorVertex::MuonSelectorVertex
(
const
edm::ParameterSet
& iConfig)
28
: muonSource_(consumes<
std
::
vector
<
pat
::
Muon
> >(iConfig.getParameter<
edm
::
InputTag
>(
"muonSource"
))),
29
vertexSource_(consumes<
std
::
vector
<
reco
::
Vertex
> >(iConfig.getParameter<
edm
::
InputTag
>(
"vertexSource"
))),
30
maxDZ_(iConfig.getParameter<double>(
"maxDZ"
)) {
31
produces<std::vector<pat::Muon> >();
32
}
33
34
void
MuonSelectorVertex::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
35
edm::Handle<std::vector<pat::Muon>
>
muons
;
36
iEvent
.getByToken(
muonSource_
,
muons
);
37
38
edm::Handle<std::vector<reco::Vertex>
>
vertices
;
39
iEvent
.getByToken(
vertexSource_
,
vertices
);
40
41
std::vector<pat::Muon>*
selectedMuons
(
new
std::vector<pat::Muon>);
42
43
if
(!
vertices
->empty()) {
44
for
(
unsigned
iMuon = 0; iMuon <
muons
->size(); ++iMuon) {
45
if
(std::fabs(
muons
->at(iMuon).vertex().z() -
vertices
->at(0).z()) <
maxDZ_
) {
46
selectedMuons
->push_back(
muons
->at(iMuon));
47
}
48
}
49
}
50
51
std::unique_ptr<std::vector<pat::Muon> > selectedMuonsPtr(
selectedMuons
);
52
iEvent
.put(
std::move
(selectedMuonsPtr));
53
}
54
55
#include "
FWCore/Framework/interface/MakerMacros.h
"
56
DEFINE_FWK_MODULE
(
MuonSelectorVertex
);
PDWG_BPHSkim_cff.muons
muons
Definition:
PDWG_BPHSkim_cff.py:47
MuonSelectorVertex::muonSource_
edm::EDGetTokenT< std::vector< pat::Muon > > muonSource_
Definition:
MuonSelectorVertex.cc:18
MuonSelectorVertex::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition:
MuonSelectorVertex.cc:34
MuonSelectorVertex::vertexSource_
edm::EDGetTokenT< std::vector< reco::Vertex > > vertexSource_
Definition:
MuonSelectorVertex.cc:19
EDProducer.h
MuonSelectorVertex::~MuonSelectorVertex
~MuonSelectorVertex() override
Definition:
MuonSelectorVertex.cc:14
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm
HLT enums.
Definition:
AlignableModifier.h:19
Muon.h
METSignificanceObjects_cfi.selectedMuons
selectedMuons
======================================
Definition:
METSignificanceObjects_cfi.py:7
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89287
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::Handle
Definition:
AssociativeIterator.h:50
MuonSelectorVertex
Definition:
MuonSelectorVertex.cc:11
Muon
Definition:
Muon.py:1
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
Vertex.h
edm::ParameterSet
Definition:
ParameterSet.h:47
MuonSelectorVertex::maxDZ_
double maxDZ_
Definition:
MuonSelectorVertex.cc:20
Event.h
iEvent
int iEvent
Definition:
GenABIO.cc:224
trackerHitRTTI::vector
Definition:
trackerHitRTTI.h:21
edm::EventSetup
Definition:
EventSetup.h:57
pat
Definition:
HeavyIon.h:7
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
HltBtagValidation_cff.Vertex
Vertex
Definition:
HltBtagValidation_cff.py:32
MuonSelectorVertex::MuonSelectorVertex
MuonSelectorVertex(const edm::ParameterSet &iConfig)
Definition:
MuonSelectorVertex.cc:27
edm::EDProducer
Definition:
EDProducer.h:35
ParameterSet.h
edm::Event
Definition:
Event.h:73
pwdgSkimBPark_cfi.vertices
vertices
Definition:
pwdgSkimBPark_cfi.py:7
Generated for CMSSW Reference Manual by
1.8.16