PhysicsTools
ParallelAnalysis
src
TrackAnalysisAlgorithm.cc
Go to the documentation of this file.
1
#include "
PhysicsTools/ParallelAnalysis/interface/TrackAnalysisAlgorithm.h
"
2
#include "
DataFormats/TrackReco/interface/Track.h
"
3
#include "
DataFormats/TrackReco/interface/TrackFwd.h
"
4
#include "
DataFormats/Common/interface/Handle.h
"
5
#include "
FWCore/Framework/interface/Event.h
"
6
#include <TCanvas.h>
7
#include <TList.h>
8
#include <TH1.h>
9
#include <iostream>
10
using namespace
examples
;
11
using namespace
std
;
12
using namespace
edm
;
13
using namespace
reco
;
14
15
const
char
*
TrackAnalysisAlgorithm::kPt
=
"pt"
;
16
const
char
*
TrackAnalysisAlgorithm::kEta
=
"eta"
;
17
18
TrackAnalysisAlgorithm::TrackAnalysisAlgorithm
(
const
TList*, TList&
out
) {
19
cout
<<
">> booking histograms"
<< endl;
20
out
.Add(h_pt =
new
TH1F(
kPt
,
"pt"
, 100, 0, 20));
21
out
.Add(h_eta =
new
TH1F(
kEta
,
"#eta"
, 100, -3, 3));
22
}
23
24
void
TrackAnalysisAlgorithm::process
(
const
Event
&
event
) {
25
cout
<<
">> processing event "
<< endl;
26
Handle<TrackCollection>
tracks
;
27
event
.getByLabel(
"ctfWithMaterialTracks"
,
tracks
);
28
29
cout
<<
">> tracks found:"
<<
tracks
->size() << endl;
30
for
(
size_t
i
= 0;
i
<
tracks
->size(); ++
i
) {
31
const
Track
&
track
= (*tracks)[
i
];
32
h_pt->Fill(
track
.pt());
33
h_eta->Fill(
track
.eta());
34
cout
<<
">> pt, eta: "
<<
track
.pt() <<
", "
<<
track
.eta() << endl;
35
}
36
}
37
38
void
TrackAnalysisAlgorithm::postProcess
(TList&) {
cout
<<
">> nothing to be done in post-processing"
<< endl; }
39
40
void
TrackAnalysisAlgorithm::terminate
(TList&
out
) {
41
cout
<<
">> terminating"
<< endl;
42
TCanvas
canvas
;
43
draw
(
out
,
canvas
,
kPt
);
44
draw
(
out
,
canvas
,
kEta
);
45
}
46
47
void
TrackAnalysisAlgorithm::draw
(
const
TList&
out
, TCanvas&
canvas
,
const
char
*
k
) {
48
TObject*
hist
=
out
.FindObject(
k
);
49
if
(
nullptr
!=
hist
) {
50
hist
->Draw();
51
canvas
.SaveAs((
string
(
k
) +
".jpg"
).c_str());
52
}
else
{
53
cerr
<<
">> no '"
<<
k
<<
"' histogram"
<< endl;
54
}
55
}
kPt
example_track example_trackconst char *const kPt
Definition:
TSelector.cc:33
svgfig.canvas
def canvas(*sub, **attr)
Definition:
svgfig.py:482
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition:
PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition:
mps_fire.py:428
HLT_FULL_cff.track
track
Definition:
HLT_FULL_cff.py:11779
edm
HLT enums.
Definition:
AlignableModifier.h:19
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
ntuplePlotting.draw
def draw(name, histos, styles=_defaultStyles, legendLabels=[], **kwargs)
Definition:
ntuplePlotting.py:25
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::Handle
Definition:
AssociativeIterator.h:50
examples::TrackAnalysisAlgorithm::TrackAnalysisAlgorithm
TrackAnalysisAlgorithm(const TList *, TList &)
constructor
Definition:
TrackAnalysisAlgorithm.cc:18
examples::TrackAnalysisAlgorithm::terminate
static void terminate(TList &)
terminate processing
Definition:
TrackAnalysisAlgorithm.cc:40
Track.h
TrackFwd.h
compare.hist
hist
Definition:
compare.py:376
reco::Track
Definition:
Track.h:27
dqmdumpme.k
k
Definition:
dqmdumpme.py:60
examples::TrackAnalysisAlgorithm::kEta
static const char * kEta
Definition:
TrackAnalysisAlgorithm.h:38
Event.h
TrackAnalysisAlgorithm.h
examples::TrackAnalysisAlgorithm::draw
static void draw(const TList &, TCanvas &, const char *)
draw an histogram
Definition:
TrackAnalysisAlgorithm.cc:47
std
Definition:
JetResolutionObject.h:76
examples::TrackAnalysisAlgorithm::postProcess
void postProcess(TList &)
post process
Definition:
TrackAnalysisAlgorithm.cc:38
examples
Definition:
TrackAnalysisAlgorithm.h:20
MillePedeFileConverter_cfg.out
out
Definition:
MillePedeFileConverter_cfg.py:31
JetComb::kEta
Definition:
TtSemiLepJetComb.h:17
event
Definition:
event.py:1
edm::Event
Definition:
Event.h:73
examples::TrackAnalysisAlgorithm::process
void process(const edm::Event &)
process one event
Definition:
TrackAnalysisAlgorithm.cc:24
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition:
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
examples::TrackAnalysisAlgorithm::kPt
static const char * kPt
histogram names
Definition:
TrackAnalysisAlgorithm.h:38
Generated for CMSSW Reference Manual by
1.8.16