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