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 path.add_module('OpticalGun',
27 minAlpha=0.0, # not used if angulardistribution == 'Gaussian'
28 maxAlpha=33.0, # not used if angulardistribution == 'Gaussian'
29 na=0.50, # used only if angulardistribution == 'Gaussian'
30 startTime=0,
31 pulseWidth=10.0e-3, # laser time jitter (1 Gaussian sigma), [ns]
32 numPhotons=10,
33 diameter=10.0e-3, # source diameter in cm
34 slotID=slotID, # if nonzero, local (slot) frame, otherwise Belle II
35 x=x,
36 y=-3.26,
37 z=-131.33,
38 theta=180 + angle,
39 phi=0.0,
40 psi=0.0,
41 angularDistribution='uniform'
42 # angularDistribution='(40-x)*TMath::Sin(x)' # You can have whatever distribution you like
43 )
44
45
46# Create path
47main = b2.create_path()
48
49
50# Set number of events to generate
51main.add_module('EventInfoSetter',
52 expList=[1003], # 0 for nominal phase 3, 1002 for phase II, 1003 for early phase III
53 evtNumList=[100])
54
55# Gearbox: access to database (xml files)
56main.add_module('Gearbox')
57
58# Geometry
59main.add_module('Geometry')
60
61# Optical sources
62for slotId in range(1, 17):
63 for pos in [0.9, 5.7, 11.3, 16.9, 22.5, 28.1, 33.7, 39.3, 44.1]:
64 angle = 17
65 x = -45. / 2. + pos
66 addSource(x, angle, slotId, main)
67
68# Simulation
69main.add_module('FullSim')
70
71# TOP digitization
72main.add_module('TOPDigitizer')
73
74# Output
75main.add_module('RootOutput',
76 outputFileName='opticalGun.root',
77 additionalBranchNames=['TOPSimPhotons', 'TOPSimHitsToTOPSimPhotons'])
78
79# Show progress of processing
80main.add_module('Progress')
81
82# Process events
83b2.process(main)
84
85# Print call statistics
86print(b2.statistics)
87