Belle II Software development
EclRefactoring.py
1#!/usr/bin/env python3
2
3
10
11"""This steering file includes all modules of the
12 ECL code.
13
14Usage:
15 basf2 EclRefactoring.py [-- --bkgDirectory <path_to_files>]
16"""
17
18import glob
19import argparse
20import basf2 as b2
21from simulation import add_simulation
22from reconstruction import add_reconstruction
23from mdst import add_mdst_output
24
25
26def argparser():
27
28 parser = argparse.ArgumentParser()
29
30 parser.add_argument('--bkgDirectory',
31 help='Path to beam background directory'
32 'If you want to add beam background, pass this option.')
33 return parser
34
35
36args = argparser().parse_args()
37
38# Set log level
39b2.set_log_level(b2.LogLevel.INFO)
40
41# Fix random seed
42b2.set_random_seed(123456)
43
44# Create path. Register necessary modules to this path.
45mainPath = b2.create_path()
46
47# Register and add 'EventInfoSetter' module
48eventInfoSetter = b2.register_module('EventInfoSetter')
49mainPath.add_module(eventInfoSetter)
50
51# Register and add 'EvtGenInput' module
52evtGenInput = b2.register_module('EvtGenInput')
53mainPath.add_module(evtGenInput)
54
55# Add default full simulation and digitization
56if args.bkgDirectory:
57 # Add beam background
58 bgFiles = glob.glob(args.bkgDirectory + '/*.root')
59 # Add simulation
60 add_simulation(mainPath, bkgfiles=bgFiles)
61else:
62 add_simulation(mainPath)
63
64# Add reconstruction
65add_reconstruction(mainPath)
66
67# Add output mdst file with all of the available ECL information
68add_mdst_output(
69 mainPath,
70 mc=True,
71 filename='ecl_refactoring.mdst.root',
72 additionalBranches=[
73 'ECLDigits',
74 'ECLCalDigits',
75 'ECLConnectedRegions',
76 'ECLShowers',
77 'ECLLocalMaximums'])
78
79# Show progress of processing
80progressBar = b2.register_module('ProgressBar')
81mainPath.add_module(progressBar)
82
83# Process the events and print call statistics
84mainPath.add_module('Progress')
85b2.process(mainPath)
86print(b2.statistics)