20 from ROOT
import Belle2
21 from ROOT
import TH2F, TFile
23 inputFile =
'opticalGun.root'
24 if not os.path.exists(inputFile):
25 b2.B2ERROR(inputFile +
': file not found')
26 b2.B2INFO(
'File can be generated with top/examples/simLaserCalibSystem.py')
32 ''' A module to histogram pixel hits from individual fibers'''
35 hist = [TH2F(
'fiber' + str(k + 1),
'Pixel hit distribution from fiber No.' + str(k + 1),
36 64, 0.5, 64.5, 8, 0.5, 8.5)
for k
in range(9)]
40 propTime = TH2F(
'propTime',
'Photon propagation times for pixel ' + str(pixelID) +
41 ' vs. fiber number', 9, 0.5, 9.5, 200, 0.0, 1.0)
42 propTime.GetXaxis().SetTitle(
'fiber number')
43 propTime.GetYaxis().SetTitle(
'propagation time [ns]')
46 ''' Event processor: fill histograms '''
50 simhits = digit.getRelationsWith(
'TOPSimHits')
51 for simhit
in simhits:
52 photon = simhit.getRelated(
'TOPSimPhotons')
54 k = int((photon.getEmissionPoint().X() + 22.5) / 5.5)
56 self.
histhist[k].Fill(digit.getPixelCol(), digit.getPixelRow())
58 b2.B2ERROR(
'wrong decoding of fiber number: ' + str(k + 1))
59 if digit.getPixelID() == self.
pixelIDpixelID:
60 t = photon.getDetectionTime() - photon.getEmissionTime()
64 ''' Write histograms to file '''
66 tfile = TFile(
'laserPixelIlumination.root',
'recreate')
68 self.
histhist[k].Write()
74 main = b2.create_path()
77 roinput = b2.register_module(
'RootInput')
78 roinput.param(
'inputFileName', inputFile)
79 main.add_module(roinput)
85 progress = b2.register_module(
'Progress')
86 main.add_module(progress)
A (simplified) python wrapper for StoreArray.