Belle II Software  release-08-01-10
genTrigTimeStamps.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import basf2 as b2
13 import glob
14 import os
15 
16 # --------------------------------------------------------------------------
17 # Example of using TOPTriggerDigitizer to make time stamps for trigger input
18 # --------------------------------------------------------------------------
19 
20 # Create path
21 main = b2.create_path()
22 
23 # Set number of events to generate
24 eventinfosetter = b2.register_module('EventInfoSetter')
25 eventinfosetter.param({'evtNumList': [100]})
26 main.add_module(eventinfosetter)
27 
28 # Gearbox
29 gearbox = b2.register_module('Gearbox')
30 main.add_module(gearbox)
31 
32 # Geometry
33 geometry = b2.register_module('Geometry')
34 main.add_module(geometry)
35 
36 # generate BBbar events
37 evtgeninput = b2.register_module('EvtGenInput')
38 main.add_module(evtgeninput)
39 
40 # Beam background mixer
41 bg = None
42 if 'BELLE2_BACKGROUND_MIXING_DIR' in os.environ:
43  bg = glob.glob(os.environ['BELLE2_BACKGROUND_MIXING_DIR'] + '/*.root')
44 if bg is not None:
45  bkgmixer = b2.register_module('BeamBkgMixer')
46  bkgmixer.param('backgroundFiles', bg)
47  main.add_module(bkgmixer)
48  b2.B2RESULT('Simulaton w/ beam background, samples taken from folder ' +
49  os.environ['BELLE2_BACKGROUND_MIXING_DIR'])
50 else:
51  b2.B2RESULT('Simulaton w/o beam background')
52 
53 # Simulation
54 simulation = b2.register_module('FullSim')
55 main.add_module(simulation)
56 
57 # TOP digitization
58 main.add_module('TOPDigitizer', allChannels=True)
59 
60 # TOP trigger digitization (time stamps)
61 trigdigi = b2.register_module('TOPTriggerDigitizer')
62 trigdigi.param('threshold', 28) # 3 sigma of electronic noise
63 main.add_module(trigdigi)
64 
65 # Output
66 output = b2.register_module('RootOutput')
67 output.param('branchNames', ['TOPDigits', 'TOPTriggerDigits', 'TOPTriggerMCInfo'])
68 main.add_module(output)
69 
70 # Show progress of processing
71 progress = b2.register_module('Progress')
72 main.add_module(progress)
73 
74 # Process events
75 b2.process(main)
76 
77 # Print call statistics
78 print(b2.statistics)