Belle II Software development
simLaserCalibSystem.py
1#!/usr/bin/env python3
2
3
10
11# ---------------------------------------------------------------
12# example of using OpticalGun to simulate the TOP laser calibration
13# system. Nine sources are located outside of the prism, in front
14# of its slanted face, pointing to the PMTs
15# ---------------------------------------------------------------
16
17import basf2 as b2
18
19
20def addSource(x, angle, slotID, path):
21 '''
22 Adds a laser source to the path
23 @param x local x coordinate of teh source in the bar frame
24 @param angle vertical tilt of the source
25 @param slotID 1-16, slot number. If it's 0, then all the coorinates are in the BelleII frame
26 '''
27 path.add_module('OpticalGun',
28 minAlpha=0.0, # not used if angulardistribution == 'Gaussian'
29 maxAlpha=33.0, # not used if angulardistribution == 'Gaussian'
30 na=0.50, # used only if angulardistribution == 'Gaussian'
31 startTime=0,
32 pulseWidth=10.0e-3, # laser time jitter (1 Gaussian sigma), [ns]
33 numPhotons=10,
34 diameter=10.0e-3, # source diameter in cm
35 slotID=slotID, # if nonzero, local (slot) frame, otherwise Belle II
36 x=x,
37 y=-3.26,
38 z=-131.33,
39 theta=180 + angle,
40 phi=0.0,
41 psi=0.0,
42 angularDistribution='uniform'
43 # angularDistribution='(40-x)*TMath::Sin(x)' # You can have whatever distribution you like
44 )
45
46
47# Create path
48main = b2.create_path()
49
50
51# Set number of events to generate
52main.add_module('EventInfoSetter',
53 expList=[1003], # 0 for nominal phase 3, 1002 for phase II, 1003 for early phase III
54 evtNumList=[100])
55
56# Gearbox: access to database (xml files)
57main.add_module('Gearbox')
58
59# Geometry
60main.add_module('Geometry')
61
62# Optical sources
63for slotId in range(1, 17):
64 for pos in [0.9, 5.7, 11.3, 16.9, 22.5, 28.1, 33.7, 39.3, 44.1]:
65 angle = 17
66 x = -45. / 2. + pos
67 addSource(x, angle, slotId, main)
68
69# Simulation
70main.add_module('FullSim')
71
72# TOP digitization
73main.add_module('TOPDigitizer')
74
75# Output
76main.add_module('RootOutput',
77 outputFileName='opticalGun.root',
78 additionalBranchNames=['TOPSimPhotons', 'TOPSimHitsToTOPSimPhotons'])
79
80# Show progress of processing
81main.add_module('Progress')
82
83# Process events
84b2.process(main, calculateStatistics=True)
85
86# Print call statistics
87print(b2.statistics)