Belle II Software  release-08-01-10
evaluateSimulation.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import basf2 as b2
13 from basf2 import conditions as b2conditions
14 from simulation import add_simulation
15 
16 numEvents = 2000
17 svdOnlySimulation = False
18 
19 if svdOnlySimulation:
20  b2conditions.prepend_globaltag("svd_onlySVDinGeoConfiguration")
21 
22 main = b2.create_path()
23 
24 b2.set_random_seed(1)
25 
26 eventinfosetter = b2.register_module('EventInfoSetter')
27 eventinfosetter.param('expList', [0])
28 eventinfosetter.param('runList', [1])
29 eventinfosetter.param('evtNumList', [numEvents])
30 main.add_module(eventinfosetter)
31 main.add_module('EventInfoPrinter')
32 main.add_module('EvtGenInput')
33 
34 if not svdOnlySimulation:
35  # Belle2 Simulation
36  add_simulation(main, simulateT0jitter=True, usePXDDataReduction=False, forceSetPXDDataReduction=True)
37 
38  for m in main.modules():
39  if m.name() == "SVDEventInfoSetter":
40  m.param("useDB", True)
41  m.param("daqMode", 3)
42  m.param("relativeShift", 9)
43  m.set_log_level(b2.LogLevel.DEBUG)
44  m.set_debug_level(25)
45  if m.name() == "SVDDigitizer":
46  m.set_log_level(b2.LogLevel.INFO)
47  m.set_debug_level(25)
48 
49 else:
50 
51  # gearbox
52  main.add_module('Gearbox')
53 
54  # detector geometry
55  geometry = b2.register_module('Geometry')
56  main.add_module(geometry)
57 
58  # event T0 jitter simulation
59  eventt0 = b2.register_module('EventT0Generator')
60  eventt0.param('coreGaussWidth', 10.0) # 10 sigma of core gaussian [ns]
61  # eventt0.param('fixedT0', nan) If set, a fixed event t0 is used instead of simulating the bunch timing.
62  eventt0.param('tailGaussFraction', 0.0) # 0 fraction (by area) of tail gaussian
63  eventt0.param('tailGaussWidth', 20.0) # 20 sigma of tail gaussian [ns]
64  # main.add_module(eventt0)
65 
66  # detector simulation
67  main.add_module('FullSim')
68 
69  # including the timing module
70  # main.add_module("FullSimTiming", rootFile="EvtGenTiming.root", logLevel=LogLevel.INFO)
71 
72  # from svd import add_svd_trgsummary
73  # add_svd_trgsummary(main)
74 
75  # SVD simulation
76  svdevtinfoset = b2.register_module("SVDEventInfoSetter")
77  # svdevtinfoset.param("useDB",True)
78  svdevtinfoset.param("daqMode", 3)
79  svdevtinfoset.param("relativeShift", 9)
80  svdevtinfoset.set_log_level(b2.LogLevel.DEBUG)
81  svdevtinfoset.set_debug_level(25)
82 
83  main.add_module(svdevtinfoset)
84 
85  digitizer = b2.register_module('SVDDigitizer')
86  digitizer.param('statisticsFilename', "digitizer_test2021_1_hwclock.root")
87  digitizer.param('storeWaveforms', True)
88  digitizer.param('signalsList', "digitizer_test2021_1_hwclock.txt")
89  digitizer.set_log_level(b2.LogLevel.DEBUG)
90  digitizer.set_debug_level(30)
91  main.add_module(digitizer)
92 
93 main.add_module('RootOutput')
94 main.add_module('Progress')
95 
96 b2.print_path(main)
97 
98 b2.process(main)
99 
100 print(b2.statistics)