ElectroWeakAnalysis
ZMuMu
plugins
EventVtxInfoNtupleDumper.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/EDProducer.h
"
2
#include "
FWCore/Utilities/interface/InputTag.h
"
3
#include "
DataFormats/Common/interface/Handle.h
"
4
#include "
FWCore/Framework/interface/Event.h
"
5
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
6
#include "
DataFormats/VertexReco/interface/Vertex.h
"
7
#include "
DataFormats/VertexReco/interface/VertexFwd.h
"
8
9
#include <vector>
10
11
using namespace
edm
;
12
using namespace
std
;
13
using namespace
reco
;
14
15
class
EventVtxInfoNtupleDumper
:
public
edm::EDProducer
{
16
public
:
17
EventVtxInfoNtupleDumper
(
const
edm::ParameterSet
&);
18
19
private
:
20
void
produce(
edm::Event
&,
const
edm::EventSetup
&)
override
;
21
edm::EDGetTokenT<reco::VertexCollection>
primaryVerticesToken_
;
22
};
23
24
EventVtxInfoNtupleDumper::EventVtxInfoNtupleDumper
(
const
ParameterSet
&
cfg
)
25
: primaryVerticesToken_(consumes<
reco
::
VertexCollection
>(
cfg
.getParameter<
InputTag
>(
"primaryVertices"
))) {
26
produces<int>(
"numPV"
).setBranchAlias(
"numPV"
);
27
produces<int>(
"nTrkPV"
).setBranchAlias(
"nTrkPV"
);
28
produces<float>(
"chi2PV"
).setBranchAlias(
"chi2PV"
);
29
produces<float>(
"ndofPV"
).setBranchAlias(
"ndofPV"
);
30
produces<float>(
"zPV"
).setBranchAlias(
"zPV"
);
31
produces<float>(
"rhoPV"
).setBranchAlias(
"rhoPV"
);
32
// produces<std::vector< unsigned int > >( "nTrkPV" ).setBranchAlias( "nTrkPV" );
33
// produces<std::vector< float > >( "chi2PV" ).setBranchAlias( "chi2PV" );
34
// produces<std::vector< float > >( "ndofPV" ).setBranchAlias( "ndofPV" );
35
}
36
37
void
EventVtxInfoNtupleDumper::produce
(
Event
&evt,
const
EventSetup
&) {
38
Handle<reco::VertexCollection>
primaryVertices
;
// Collection of primary Vertices
39
evt.
getByToken
(
primaryVerticesToken_
,
primaryVertices
);
40
unique_ptr<int> nVtxs(
new
int
);
41
unique_ptr<int> nTrkVtx(
new
int
);
42
unique_ptr<float> chi2Vtx(
new
float
);
43
unique_ptr<float> ndofVtx(
new
float
);
44
unique_ptr<float> zVtx(
new
float
);
45
unique_ptr<float>
rhoVtx
(
new
float
);
46
// unique_ptr< vector< unsigned int > > nTrkVtx( new vector< unsigned int > );
47
// unique_ptr< vector< float > > chi2Vtx( new vector< float > );
48
// unique_ptr< vector< float > > ndofVtx( new vector< float > );
49
50
const
reco::Vertex
&
pv
= (*primaryVertices)[0];
51
52
*nVtxs = -1;
53
*nTrkVtx = -1;
54
*chi2Vtx = -1.0;
55
*ndofVtx = -1.0;
56
*zVtx = -1000;
57
*
rhoVtx
= -1000;
58
if
(!(
pv
.isFake())) {
59
*nVtxs =
primaryVertices
->size();
60
*nTrkVtx =
pv
.tracksSize();
61
*chi2Vtx =
pv
.chi2();
62
*ndofVtx =
pv
.ndof();
63
*zVtx =
pv
.z();
64
*
rhoVtx
=
pv
.position().Rho();
65
}
66
// nTrkVtx->push_back(pv.tracksSize());
67
// chi2Vtx->push_back(pv.chi2());
68
// ndofVtx->push_back(pv.ndof());
69
evt.
put
(
std::move
(nVtxs),
"numPV"
);
70
evt.
put
(
std::move
(nTrkVtx),
"nTrkPV"
);
71
evt.
put
(
std::move
(chi2Vtx),
"chi2PV"
);
72
evt.
put
(
std::move
(ndofVtx),
"ndofPV"
);
73
evt.
put
(
std::move
(zVtx),
"zPV"
);
74
evt.
put
(
std::move
(
rhoVtx
),
"rhoPV"
);
75
}
76
77
#include "
FWCore/Framework/interface/MakerMacros.h
"
78
79
DEFINE_FWK_MODULE
(
EventVtxInfoNtupleDumper
);
EventVtxInfoNtupleDumper::EventVtxInfoNtupleDumper
EventVtxInfoNtupleDumper(const edm::ParameterSet &)
Definition:
EventVtxInfoNtupleDumper.cc:24
Handle.h
EDProducer.h
edm::EDGetTokenT< reco::VertexCollection >
edm
HLT enums.
Definition:
AlignableModifier.h:19
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition:
VertexFwd.h:9
EventVtxInfoNtupleDumper::primaryVerticesToken_
edm::EDGetTokenT< reco::VertexCollection > primaryVerticesToken_
Definition:
EventVtxInfoNtupleDumper.cc:21
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::Handle< reco::VertexCollection >
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:528
Vertex.h
EventVtxInfoNtupleDumper::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
EventVtxInfoNtupleDumper.cc:37
edm::ParameterSet
Definition:
ParameterSet.h:36
zMuMuMuonUserData.primaryVertices
primaryVertices
Definition:
zMuMuMuonUserData.py:12
Event.h
MetAnalyzer.pv
def pv(vc)
Definition:
MetAnalyzer.py:7
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:132
TrackCollections2monitor_cff.rhoVtx
rhoVtx
Definition:
TrackCollections2monitor_cff.py:263
edm::EventSetup
Definition:
EventSetup.h:57
InputTag.h
looper.cfg
cfg
Definition:
looper.py:297
VertexFwd.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
EventVtxInfoNtupleDumper
Definition:
EventVtxInfoNtupleDumper.cc:15
edm::EDProducer
Definition:
EDProducer.h:36
ParameterSet.h
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
reco::Vertex
Definition:
Vertex.h:35
Generated for CMSSW Reference Manual by
1.8.16