Belle II Software  release-06-02-00
evtgen_gen.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
28 
29 import basf2 as b2
30 from generators import add_evtgen_generator
31 from modularAnalysis import setupEventInfo
32 from modularAnalysis import loadGearbox
33 from reconstruction import add_mdst_output
34 from optparse import OptionParser
35 from ROOT import Belle2
36 
37 parser = OptionParser()
38 parser.add_option('-n', '--nevents', dest='nevents', default=1000,
39  help='Number of events to process')
40 parser.add_option('-f', '--file', dest='filename',
41  default='B2Kpi_events.root')
42 (options, args) = parser.parse_args()
43 
44 # Suppress messages and warnings during processing:
45 b2.set_log_level(b2.LogLevel.ERROR)
46 
47 
48 # generation of 1000 events according to the specified DECAY table
49 # Y(4S) -> B0 B0bar
50 # one B0->K+pi-, other generic decay
51 mypath = b2.create_path()
52 setupEventInfo(int(options.nevents), mypath)
53 add_evtgen_generator(mypath, 'signal', Belle2.FileSystem.findFile('arich/examples/B2kpi.dec'))
54 
55 # If the simulation and reconstruction is not performed in the sam job,
56 # then the Gearbox needs to be loaded with the loadGearbox() function.
57 loadGearbox(mypath)
58 
59 # dump generated events in MDST format to the output ROOT file
60 add_mdst_output(mypath, True, options.filename)
61 
62 # process all modules added to the mypath path
63 b2.process(mypath)
64 
65 # print out the summary
66 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