ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/examples/trackerHits.py
Revision: 1.1
Committed: Wed Nov 1 10:47:55 2006 UTC (18 years, 6 months ago) by hegner
Content type: text/x-python
Branch: MAIN
CVS Tags: V00-01-03, V00-01-02
Log Message:
moved examples to example directory/ added interactive example

File Contents

# User Rev Content
1 hegner 1.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")