Belle II Software  release-05-01-25
evtgenB2Kpi.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 from basf2 import *
5 import os
6 from simulation import add_simulation
7 from reconstruction import add_reconstruction
8 from reconstruction import add_mdst_output
9 import glob
10 from ROOT import Belle2
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 # Suppress messages and warnings during processing:
22 set_log_level(LogLevel.ERROR)
23 
24 # Create path
25 main = create_path()
26 
27 # Number of events to be generated
28 eventinfosetter = register_module('EventInfoSetter')
29 eventinfosetter.param('evtNumList', [100])
30 main.add_module(eventinfosetter)
31 
32 # Event generator (B0 -> K+pi- + cc, other B0 generic)
33 evtgeninput = register_module('EvtGenInput')
34 evtgeninput.param('userDECFile',
35  Belle2.FileSystem.findFile('top/examples/B2Kpi.dec'))
36 main.add_module(evtgeninput)
37 
38 # Detector simulation
39 bg = None
40 if 'BELLE2_BACKGROUND_DIR' in os.environ:
41  bg = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '/*.root')
42 add_simulation(main, bkgfiles=bg)
43 
44 # Reconstruction
45 add_reconstruction(main)
46 
47 # Output to mdst
48 add_mdst_output(main, filename='evtgenB2Kpi.mdst.root')
49 
50 # Output to a flat ntuple with TOP likelihoods, track info and MC truth
51 ntuple = register_module('TOPNtuple')
52 ntuple.param('outputFileName', 'ntupleB2Kpi.root')
53 main.add_module(ntuple)
54 
55 # Show progress of processing
56 progress = register_module('Progress')
57 main.add_module(progress)
58 
59 # Process events
60 process(main)
61 
62 # Print call statistics
63 print(statistics)
Belle2::FileSystem::findFile
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:147