1 |
hegner |
1.1 |
# first load the ROOT classes
|
2 |
|
|
# importing all is the safe way
|
3 |
|
|
from ROOT import *
|
4 |
|
|
|
5 |
|
|
# the CMS specific rootlogon.C part
|
6 |
|
|
gSystem.Load("libPhysicsToolsFWLite")
|
7 |
|
|
AutoLibraryLoader.enable()
|
8 |
|
|
|
9 |
|
|
# opening file and accessing branches
|
10 |
|
|
print "Opening SimHit file"
|
11 |
|
|
file = TFile("simevent.root")
|
12 |
|
|
events = file.Get("Events")
|
13 |
|
|
branch = events.GetBranch("PSimHit_r_TrackerHitsTIBLowTof.obj")
|
14 |
|
|
simHit = std.vector(PSimHit)()
|
15 |
|
|
branch.SetAddress(simHit)
|
16 |
|
|
|
17 |
|
|
histo = TH1F("nofhits", "Tof of hits", 100, -0.5, 50)
|
18 |
|
|
|
19 |
|
|
# looping over all events
|
20 |
|
|
nOfEvents = events.GetEntries()
|
21 |
|
|
for ev in range(nOfEvents):
|
22 |
|
|
branch.GetEntry(ev)
|
23 |
|
|
size = simHit.size()
|
24 |
|
|
for i in range(size):
|
25 |
|
|
histo.Fill(simHit[i].timeOfFlight())
|
26 |
|
|
|
27 |
|
|
hFile = TFile("histo.root", "RECREATE")
|
28 |
|
|
histo.Write();
|
29 |
|
|
|
30 |
|
|
gROOT.SetBatch()
|
31 |
|
|
gROOT.SetStyle("Plain")
|
32 |
|
|
|
33 |
|
|
c = TCanvas()
|
34 |
|
|
histo.Draw()
|
35 |
|
|
c.SaveAs("tofhits.jpg")
|