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