1 |
# first load cmstools and ROOT classes
|
2 |
from cmstools import *
|
3 |
from ROOT import *
|
4 |
|
5 |
# opening file and accessing branches
|
6 |
print "Opening SimHit file"
|
7 |
file = TFile("simevent.root")
|
8 |
events = file.Get("Events")
|
9 |
branch = events.GetBranch("PSimHit_r_TrackerHitsTIBLowTof.obj")
|
10 |
|
11 |
simHit = std.vector(PSimHit)()
|
12 |
branch.SetAddress(simHit)
|
13 |
|
14 |
histo = TH1F("tofhits", "Tof of hits", 100, -0.5, 50)
|
15 |
|
16 |
# loop over all events
|
17 |
for ev in all(events):
|
18 |
branch.GetEntry(ev)
|
19 |
for hit in all(simHit):
|
20 |
histo.Fill(hit.timeOfFlight())
|
21 |
|
22 |
hFile = TFile("histo.root", "RECREATE")
|
23 |
histo.Write()
|
24 |
|
25 |
gROOT.SetBatch()
|
26 |
gROOT.SetStyle("Plain")
|
27 |
|
28 |
c = TCanvas()
|
29 |
histo.Draw()
|
30 |
c.SaveAs("tofhits.jpg")
|