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