Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:58:27

0001 # first load cmstools and ROOT classes
0002 from PhysicsTools.PythonAnalysis import *
0003 from ROOT import *
0004 
0005 gSystem.Load("libFWCoreFWLite.so")
0006 ROOT.FWLiteEnabler.enable()
0007 
0008 # opening file
0009 events = EventTree("simevent.root")
0010 
0011 # prepare the histogram
0012 histo = TH1F("tofhits", "Tof of hits", 100, -0.5, 50)
0013 
0014 # loop over all events and filling the histogram
0015 for event in events:
0016     simHits = event.getProduct("PSimHit_r_TrackerHitsTIBLowTof.obj")
0017     for hit in simHits:
0018         histo.Fill(hit.timeOfFlight())
0019 
0020 hFile = TFile("histo.root", "RECREATE")
0021 histo.Write()
0022 
0023 gROOT.SetBatch()
0024 gROOT.SetStyle("Plain")
0025 
0026 c = TCanvas()
0027 histo.Draw()
0028 c.SaveAs("tofhits.jpg")