PhysicsTools
PatExamples
plugins
PatZjetsJetAnalyzer.cc
Go to the documentation of this file.
1
#include <map>
2
#include <string>
3
4
#include "TH1.h"
5
6
#include "
FWCore/Framework/interface/Event.h
"
7
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
8
#include "
FWCore/Utilities/interface/InputTag.h
"
9
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
10
#include "
FWCore/ServiceRegistry/interface/Service.h
"
11
#include "
CommonTools/UtilAlgos/interface/TFileService.h
"
12
13
#include "
DataFormats/PatCandidates/interface/Jet.h
"
14
15
class
PatZjetsJetAnalyzer
:
public
edm::EDAnalyzer
{
16
public
:
17
explicit
PatZjetsJetAnalyzer
(
const
edm::ParameterSet
&);
18
~PatZjetsJetAnalyzer
()
override
;
19
20
private
:
21
void
beginJob
()
override
;
22
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
23
void
endJob
()
override
;
24
25
// simple map to contain all histograms;
26
// histograms are booked in the beginJob()
27
// method
28
std::map<std::string, TH1F*>
histContainer_
;
29
30
// input tags
31
edm::EDGetTokenT<edm::View<pat::Jet>
>
srcToken_
;
32
};
33
34
PatZjetsJetAnalyzer::PatZjetsJetAnalyzer
(
const
edm::ParameterSet
& iConfig)
35
: histContainer_(),
36
srcToken_(consumes<
edm
::
View
<
pat
::
Jet
> >(iConfig.getUntrackedParameter<
edm
::
InputTag
>(
"src"
))) {}
37
38
PatZjetsJetAnalyzer::~PatZjetsJetAnalyzer
() {}
39
40
void
PatZjetsJetAnalyzer::analyze
(
const
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
41
// get electron collection
42
edm::Handle<edm::View<pat::Jet>
>
jets
;
43
iEvent
.getByToken(
srcToken_
,
jets
);
44
45
// loop jets
46
for
(
edm::View<pat::Jet>::const_iterator
ijet =
jets
->begin(); ijet !=
jets
->end(); ++ijet) {
47
// fill simple histograms
48
pat::Jet
jet
= ijet->correctedJet(
"had"
,
"uds"
);
49
histContainer_
[
"pt"
]->Fill(
jet
.pt());
50
histContainer_
[
"eta"
]->Fill(
jet
.eta());
51
histContainer_
[
"phi"
]->Fill(
jet
.phi());
52
histContainer_
[
"emf"
]->Fill(
jet
.emEnergyFraction());
53
for
(
unsigned
int
i
= 0;
i
<
jet
.getCaloConstituents().size(); ++
i
) {
54
histContainer_
[
"dEta"
]->Fill(
jet
.getCaloConstituent(
i
)->eta() -
jet
.eta());
55
}
56
}
57
}
58
59
void
PatZjetsJetAnalyzer::beginJob
() {
60
// register to the TFileService
61
edm::Service<TFileService>
fs;
62
63
// book histograms:
64
histContainer_
[
"pt"
] = fs->
make
<TH1F>(
"pt"
,
"pt"
, 150, 0., 150.);
65
histContainer_
[
"eta"
] = fs->
make
<TH1F>(
"eta"
,
"eta"
, 50, 0., 5.);
66
histContainer_
[
"phi"
] = fs->
make
<TH1F>(
"phi"
,
"phi"
, 60, 3.14, 3.14);
67
histContainer_
[
"emf"
] = fs->
make
<TH1F>(
"emf"
,
"emf"
, 40, 0., 1.);
68
histContainer_
[
"dEta"
] = fs->
make
<TH1F>(
"dEta"
,
"dEta"
, 40, 0., 1.);
69
}
70
71
void
PatZjetsJetAnalyzer::endJob
() {}
72
73
#include "
FWCore/Framework/interface/MakerMacros.h
"
74
DEFINE_FWK_MODULE
(
PatZjetsJetAnalyzer
);
mps_fire.i
i
Definition:
mps_fire.py:428
PatZjetsJetAnalyzer::~PatZjetsJetAnalyzer
~PatZjetsJetAnalyzer() override
Definition:
PatZjetsJetAnalyzer.cc:38
PatZjetsJetAnalyzer
Definition:
PatZjetsJetAnalyzer.cc:15
sistrip::View
View
Definition:
ConstantsForView.h:26
PatZjetsJetAnalyzer::histContainer_
std::map< std::string, TH1F * > histContainer_
Definition:
PatZjetsJetAnalyzer.cc:28
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm
HLT enums.
Definition:
AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89353
EDAnalyzer.h
singleTopDQM_cfi.jets
jets
Definition:
singleTopDQM_cfi.py:42
edm::Handle
Definition:
AssociativeIterator.h:50
PatZjetsJetAnalyzer::beginJob
void beginJob() override
Definition:
PatZjetsJetAnalyzer.cc:59
edm::EDAnalyzer
Definition:
EDAnalyzer.h:28
MakerMacros.h
pat::Jet
Analysis-level calorimeter jet class.
Definition:
Jet.h:77
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
Jet
Definition:
Jet.py:1
PatZjetsJetAnalyzer::PatZjetsJetAnalyzer
PatZjetsJetAnalyzer(const edm::ParameterSet &)
Definition:
PatZjetsJetAnalyzer.cc:34
Service.h
TFileService.h
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
PatZjetsJetAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition:
PatZjetsJetAnalyzer.cc:40
edm::Service< TFileService >
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:57
pat
Definition:
HeavyIon.h:7
Jet.h
InputTag.h
PatZjetsJetAnalyzer::endJob
void endJob() override
Definition:
PatZjetsJetAnalyzer.cc:71
metsig::jet
Definition:
SignAlgoResolutions.h:47
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition:
View.h:86
ParameterSet.h
edm::Event
Definition:
Event.h:73
PatZjetsJetAnalyzer::srcToken_
edm::EDGetTokenT< edm::View< pat::Jet > > srcToken_
Definition:
PatZjetsJetAnalyzer.cc:31
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition:
TFileService.h:64
Generated for CMSSW Reference Manual by
1.8.16