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