Belle II Software  release-06-00-14
evtgenB2Kpi.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # ----------------------------------------------------------------------------------
13 # Example of generating signal MC (B0 -> K- pi+, one of the benchmarks for TOP)
14 # Beam BG is added if variable BELLE2_BACKGROUND_DIR is set with the path to BG files
15 # At KEKCC the path to BG files is /sw/belle2/bkg
16 # Two outputs are provided:
17 # - mdst format, suitable for physics studies (analysis package)
18 # - flat ntuple, suitable for TOP efficiency studies
19 # ----------------------------------------------------------------------------------
20 
21 import basf2 as b2
22 import os
23 from simulation import add_simulation
24 from reconstruction import add_reconstruction
25 from reconstruction import add_mdst_output
26 import glob
27 from ROOT import Belle2
28 
29 # Suppress messages and warnings during processing:
30 b2.set_log_level(b2.LogLevel.ERROR)
31 
32 # Create path
33 main = b2.create_path()
34 
35 # Number of events to be generated
36 eventinfosetter = b2.register_module('EventInfoSetter')
37 eventinfosetter.param('evtNumList', [100])
38 main.add_module(eventinfosetter)
39 
40 # Event generator (B0 -> K+pi- + cc, other B0 generic)
41 evtgeninput = b2.register_module('EvtGenInput')
42 evtgeninput.param('userDECFile',
43  Belle2.FileSystem.findFile('top/examples/B2Kpi.dec'))
44 main.add_module(evtgeninput)
45 
46 # Detector simulation
47 bg = None
48 if 'BELLE2_BACKGROUND_DIR' in os.environ:
49  bg = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '/*.root')
50 add_simulation(main, bkgfiles=bg)
51 
52 # Reconstruction
53 add_reconstruction(main)
54 
55 # Output to mdst
56 add_mdst_output(main, filename='evtgenB2Kpi.mdst.root')
57 
58 # Output to a flat ntuple with TOP likelihoods, track info and MC truth
59 ntuple = b2.register_module('TOPNtuple')
60 ntuple.param('outputFileName', 'ntupleB2Kpi.root')
61 main.add_module(ntuple)
62 
63 # Show progress of processing
64 progress = b2.register_module('Progress')
65 main.add_module(progress)
66 
67 # Process events
68 b2.process(main)
69 
70 # Print call statistics
71 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:145