Belle II Software  release-08-01-10
1_makeNtuple.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 <header>
14  <input>EvtGenSimRec.root, EvtGenSimRec_B2Kpi.root</input>
15  <output>TOPNtuple.root</output>
16  <contact>marko.staric@ijs.si</contact>
17  <description>Makes a flat ntuple with TOP PID, track info and MC truth </description>
18 </header>
19 """
20 
21 import basf2 as b2
22 
23 # ---------------------------------------------------------------
24 # Make a flat ntuple for validation of top package
25 # ---------------------------------------------------------------
26 
27 # Suppress messages and warnings during processing:
28 b2.set_log_level(b2.LogLevel.ERROR)
29 
30 # Create path
31 main = b2.create_path()
32 
33 # Input
34 roinput = b2.register_module('RootInput')
35 roinput.param('inputFileNames', ['../EvtGenSimRec_B2Kpi.root',
36  '../EvtGenSimRec.root'])
37 main.add_module(roinput)
38 
39 # Gearbox: access to database (xml files)
40 gearbox = b2.register_module('Gearbox')
41 main.add_module(gearbox)
42 
43 # Geometry (only TOP is needed and B-field)
44 geometry = b2.register_module('Geometry')
45 geometry.param('components', ['MagneticField', 'TOP'])
46 main.add_module(geometry)
47 
48 # Output: make flat ntuple from TOPLikelihoods, tracking info and MC truth
49 output = b2.register_module('TOPNtuple')
50 output.param('outputFileName', '../TOPNtuple.root')
51 main.add_module(output)
52 
53 # Show progress of processing
54 main.add_module('Progress')
55 
56 # Process events
57 b2.process(main)
58 
59 # Print call statistics
60 print(b2.statistics)