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