ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/test/trackerHits.py
Revision: 1.1
Committed: Fri Mar 10 19:32:54 2006 UTC (19 years, 1 month ago) by hegner
Content type: text/x-python
Branch: MAIN
CVS Tags: CMSSW_0_6_0_pre1, V00-00-01, V00-00-00
Log Message:
first commit of python example

File Contents

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