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