src
PhysicsTools
PythonAnalysis
examples
trackerHits.py
Go to the documentation of this file.
1
# first load cmstools and ROOT classes
2
from
PhysicsTools.PythonAnalysis
import
*
3
from
ROOT
import
gSystem, gROOT, TFile, TH1F, TCanvas
4
import
ROOT
5
6
gSystem.Load(
"libFWCoreFWLite.so"
)
7
ROOT.FWLiteEnabler.enable()
8
9
# opening file
10
events = EventTree(
"simevent.root"
)
11
12
# prepare the histogram
13
histo = TH1F(
"tofhits"
,
"Tof of hits"
, 100, -0.5, 50)
14
15
# loop over all events and filling the histogram
16
for
event
in
events:
17
simHits = event.getProduct(
"PSimHit_r_TrackerHitsTIBLowTof.obj"
)
18
for
hit
in
simHits:
19
histo.Fill(hit.timeOfFlight())
20
21
hFile = TFile(
"histo.root"
,
"RECREATE"
)
22
histo.Write()
23
24
gROOT.SetBatch()
25
gROOT.SetStyle(
"Plain"
)
26
27
c = TCanvas()
28
histo.Draw()
29
c.SaveAs(
"tofhits.jpg"
)
PythonAnalysis
Generated for CMSSW Reference Manual by
1.8.14