ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/test/trackerHits.py
Revision: 1.3
Committed: Wed Nov 1 10:45:10 2006 UTC (18 years, 6 months ago) by hegner
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
moved examples to examples directory

File Contents

# User Rev Content
1 hegner 1.2 # first load cmstools and ROOT classes
2     from cmstools import *
3 hegner 1.1 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 hegner 1.2
11 hegner 1.1 simHit = std.vector(PSimHit)()
12     branch.SetAddress(simHit)
13    
14 hegner 1.2 histo = TH1F("tofhits", "Tof of hits", 100, -0.5, 50)
15 hegner 1.1
16 hegner 1.2 # loop over all events
17     for ev in all(events):
18 hegner 1.1 branch.GetEntry(ev)
19 hegner 1.2 for hit in all(simHit):
20     histo.Fill(hit.timeOfFlight())
21 hegner 1.1
22     hFile = TFile("histo.root", "RECREATE")
23 hegner 1.2 histo.Write()
24 hegner 1.1
25     gROOT.SetBatch()
26     gROOT.SetStyle("Plain")
27    
28     c = TCanvas()
29     histo.Draw()
30     c.SaveAs("tofhits.jpg")