ElectroWeakAnalysis
ZMuMu
plugins
DebugZMCTruth.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
2
#include "
FWCore/Utilities/interface/InputTag.h
"
3
#include "
FWCore/Framework/interface/Event.h
"
4
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
5
#include "
DataFormats/Common/interface/Handle.h
"
6
#include "
DataFormats/Candidate/interface/Candidate.h
"
7
#include "
DataFormats/HepMCCandidate/interface/GenParticle.h
"
8
#include "
DataFormats/HepMCCandidate/interface/GenParticleFwd.h
"
9
#include <iostream>
10
using namespace
edm
;
11
using namespace
std
;
12
using namespace
reco
;
13
14
class
DebugZMCTruth
:
public
edm::EDAnalyzer
{
15
public
:
16
DebugZMCTruth
(
const
edm::ParameterSet
&
pset
);
17
18
private
:
19
void
analyze
(
const
Event
&
event
,
const
EventSetup
&
setup
)
override
;
20
InputTag
src_
;
21
EDGetTokenT<CandidateView>
srcToken_
;
22
EDGetTokenT<GenParticleCollection>
genParticlesToken_
;
23
EDGetTokenT<GenParticleMatch>
matchToken_
;
24
};
25
26
DebugZMCTruth::DebugZMCTruth
(
const
ParameterSet
&
cfg
)
27
: src_(
cfg
.getParameter<
InputTag
>(
"src"
)),
28
srcToken_(consumes<
CandidateView
>(src_)),
29
genParticlesToken_(consumes<
GenParticleCollection
>(
cfg
.getParameter<
InputTag
>(
"genParticles"
))),
30
matchToken_(consumes<
GenParticleMatch
>(
cfg
.getParameter<
InputTag
>(
"mcMatch"
))) {}
31
32
void
DebugZMCTruth::analyze
(
const
Event
&
event
,
const
EventSetup
&
setup
) {
33
Handle<GenParticleCollection>
genParticles
;
34
event
.getByToken(
genParticlesToken_
,
genParticles
);
35
Handle<CandidateView>
src
;
36
event
.getByToken(
srcToken_
,
src
);
37
cout
<<
">>> event has "
<<
src
->size() <<
" reconstructed particles in {"
<<
src_
<<
"}"
<< endl;
38
Handle<GenParticleMatch>
match
;
39
event
.getByToken(
matchToken_
,
match
);
40
cout
<<
">>> Z matches: "
;
41
for
(
unsigned
int
i
= 0;
i
<
src
->size(); ++
i
) {
42
CandidateBaseRef
ref =
src
->refAt(
i
);
43
GenParticleRef
mc
= (*match)[ref];
44
cout
<< (
mc
.isNull() ?
"(no)"
:
"(yes)"
);
45
}
46
cout
<< endl;
47
}
48
49
#include "
FWCore/Framework/interface/MakerMacros.h
"
50
51
DEFINE_FWK_MODULE
(
DebugZMCTruth
);
Handle.h
DebugZMCTruth::matchToken_
EDGetTokenT< GenParticleMatch > matchToken_
Definition:
DebugZMCTruth.cc:23
mps_fire.i
i
Definition:
mps_fire.py:355
genParticles2HepMC_cfi.genParticles
genParticles
Definition:
genParticles2HepMC_cfi.py:4
CaloTowersParam_cfi.mc
mc
Definition:
CaloTowersParam_cfi.py:8
edm::EDGetTokenT< CandidateView >
edm
HLT enums.
Definition:
AlignableModifier.h:19
DebugZMCTruth::DebugZMCTruth
DebugZMCTruth(const edm::ParameterSet &pset)
Definition:
DebugZMCTruth.cc:26
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition:
GenParticleFwd.h:13
EDAnalyzer.h
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::Handle
Definition:
AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition:
singleTopDQM_cfi.py:37
edm::Ref< GenParticleCollection >
edm::EDAnalyzer
Definition:
EDAnalyzer.h:29
GenParticle.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
DebugZMCTruth::analyze
void analyze(const Event &event, const EventSetup &setup) override
Definition:
DebugZMCTruth.cc:32
GenParticleFwd.h
edm::View
Definition:
CaloClusterFwd.h:14
edm::ParameterSet
Definition:
ParameterSet.h:36
TrackRefitter_38T_cff.src
src
Definition:
TrackRefitter_38T_cff.py:24
Event.h
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::Association
Definition:
Association.h:18
edm::EventSetup
Definition:
EventSetup.h:57
InputTag.h
looper.cfg
cfg
Definition:
looper.py:297
std
Definition:
JetResolutionObject.h:76
DebugZMCTruth
Definition:
DebugZMCTruth.cc:14
edm::RefToBase< Candidate >
DebugZMCTruth::srcToken_
EDGetTokenT< CandidateView > srcToken_
Definition:
DebugZMCTruth.cc:21
Candidate.h
ParameterSet.h
event
Definition:
event.py:1
edm::Event
Definition:
Event.h:73
DebugZMCTruth::genParticlesToken_
EDGetTokenT< GenParticleCollection > genParticlesToken_
Definition:
DebugZMCTruth.cc:22
edm::InputTag
Definition:
InputTag.h:15
DebugZMCTruth::src_
InputTag src_
Definition:
DebugZMCTruth.cc:20
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
Generated for CMSSW Reference Manual by
1.8.16