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