ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/examples/trackerHits.py
Revision: 1.2
Committed: Sat Mar 3 03:49:59 2007 UTC (18 years, 2 months ago) by hegner
Content type: text/x-python
Branch: MAIN
Changes since 1.1: +8 -13 lines
Log Message:
Updated documentation.

File Contents

# User Rev Content
1 hegner 1.1 # first load cmstools and ROOT classes
2 hegner 1.2 from PhysicsTools.PythonAnalysis.cmstools import *
3 hegner 1.1 from ROOT import *
4    
5 hegner 1.2 # opening file
6     events = EventTree("simevent.root")
7 hegner 1.1
8 hegner 1.2 # prepare the histogram
9 hegner 1.1 histo = TH1F("tofhits", "Tof of hits", 100, -0.5, 50)
10    
11 hegner 1.2 # loop over all events and filling the histogram
12     for event in events:
13     simHits = event.getProduct("PSimHit_r_TrackerHitsTIBLowTof.obj")
14     for hit in simHits:
15 hegner 1.1 histo.Fill(hit.timeOfFlight())
16    
17     hFile = TFile("histo.root", "RECREATE")
18     histo.Write()
19    
20     gROOT.SetBatch()
21     gROOT.SetStyle("Plain")
22    
23     c = TCanvas()
24     histo.Draw()
25     c.SaveAs("tofhits.jpg")