CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
trackerHits.py
Go to the documentation of this file.
1 # first load cmstools and ROOT classes
2 from PhysicsTools.PythonAnalysis import *
3 from ROOT import *
4 
5 gSystem.Load("libFWCoreFWLite.so")
6 ROOT.FWLiteEnabler.enable()
7 
8 # opening file
9 events = EventTree("simevent.root")
10 
11 # prepare the histogram
12 histo = TH1F("tofhits", "Tof of hits", 100, -0.5, 50)
13 
14 # loop over all events and filling the histogram
15 for event in events:
16  simHits = event.getProduct("PSimHit_r_TrackerHitsTIBLowTof.obj")
17  for hit in simHits:
18  histo.Fill(hit.timeOfFlight())
19 
20 hFile = TFile("histo.root", "RECREATE")
21 histo.Write()
22 
23 gROOT.SetBatch()
24 gROOT.SetStyle("Plain")
25 
26 c = TCanvas()
27 histo.Draw()
28 c.SaveAs("tofhits.jpg")