Belle II Software development
0_EvtGenSimRec_B2Kpi.py
1#!/usr/bin/env python3
2
3
10
11"""
12<header>
13 <output>EvtGenSimRec_B2Kpi.root</output>
14 <contact>marko.staric@ijs.si</contact>
15 <description>Generates signal MC of B0 -> K-pi+, 200 events</description>
16</header>
17"""
18
19import basf2 as b2
20import os
21from simulation import add_simulation
22from reconstruction import add_reconstruction
23from ROOT import Belle2
24import glob
25
26b2.set_random_seed(123451)
27
28main = b2.create_path()
29
30# specify number of events to be generated
31eventinfosetter = b2.register_module('EventInfoSetter')
32eventinfosetter.param('evtNumList', [1000])
33main.add_module(eventinfosetter)
34
35# generate events (B0 -> K+pi- + cc, other B0 generic)
36evtgeninput = b2.register_module('EvtGenInput')
37evtgeninput.param('userDECFile', Belle2.FileSystem.findFile('top/validation/B2Kpi.dec'))
38main.add_module(evtgeninput)
39
40# detector simulation
41bg = None
42if 'BELLE2_BACKGROUND_DIR' in os.environ:
43 bg = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '/*.root')
44add_simulation(main, bkgfiles=bg)
45
46# reconstruction
47add_reconstruction(main)
48
49# output (to save space only branches needed in 1_makeNtuple.py)
50output = b2.register_module('RootOutput')
51output.param('outputFileName', '../EvtGenSimRec_B2Kpi.root')
52output.param('branchNames', ['MCParticles', 'MCInitialParticles', 'Tracks', 'TrackFitResults',
53 'TOPLikelihoods', 'TOPBarHits', 'ExtHits', 'TOPRecBunch'])
54main.add_module(output)
55
56main.add_module('Progress')
57b2.process(main)
58
59# Print call statistics
60print(b2.statistics)