CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/PhysicsTools/PythonAnalysis/examples/trackerHits.py

Go to the documentation of this file.
00001 # first load cmstools and ROOT classes
00002 from PhysicsTools.PythonAnalysis import *
00003 from ROOT import *
00004 
00005 gSystem.Load("libFWCoreFWLite.so")
00006 AutoLibraryLoader.enable()
00007 
00008 # opening file
00009 events = EventTree("simevent.root")
00010 
00011 # prepare the histogram
00012 histo = TH1F("tofhits", "Tof of hits", 100, -0.5, 50)
00013 
00014 # loop over all events and filling the histogram
00015 for event in events:
00016     simHits = event.getProduct("PSimHit_r_TrackerHitsTIBLowTof.obj")
00017     for hit in simHits:
00018         histo.Fill(hit.timeOfFlight())
00019 
00020 hFile = TFile("histo.root", "RECREATE")
00021 histo.Write()
00022 
00023 gROOT.SetBatch()
00024 gROOT.SetStyle("Plain")
00025 
00026 c = TCanvas()
00027 histo.Draw()
00028 c.SaveAs("tofhits.jpg")