Belle II Software development
EclDataAnalysis.py
1#!/usr/bin/env python3
2
3
10
11"""This steering file shows how to use 'EclDataAnalysis'
12 module to dump ECL-related quantities in an ntuple.
13
14Input:
15 File with DST format
16
17Output:
18 Ntuple with ECL-related quantities
19
20Usage:
21 $ basf2 -i <path_to_input_file> -n <number_of_events>
22 EclDataAnalysis.py [-- --withBkg]
23"""
24
25import os
26import glob
27import argparse
28import basf2 as b2
29from simulation import add_simulation
30from reconstruction import add_reconstruction
31
32
33def argparser():
34
35 parser = argparse.ArgumentParser()
36
37 parser.add_argument('--withBkg',
38 action='store_true',
39 default=False,
40 help='Add beam background'
41 'Default is False i.e. no beam background.')
42 return parser
43
44
45args = argparser().parse_args()
46
47# Create path. Register necessary modules to this path.
48mainPath = b2.create_path()
49
50# Register and add 'EventInfoSetter' module and settings
51eventInfoSetter = b2.register_module('EventInfoSetter')
52eventInfoSetter.param({'evtNumList': [100],
53 'runList': [1],
54 'expList': [0]})
55mainPath.add_module(eventInfoSetter)
56
57# Random number for generation
58b2.set_random_seed(123456)
59
60# Register and add 'ParticleGun' generator module and settings
61particleGun = b2.register_module('ParticleGun')
62param_particleGun = {
63 'pdgCodes': [13], # 13: muon
64 'nTracks': 1,
65 'momentumGeneration': 'fixed',
66 'momentumParams': [0.5],
67 'thetaGeneration': 'uniform',
68 'thetaParams': [0., 30.],
69 'phiGeneration': 'uniform',
70 'phiParams': [0., 360.],
71 'vertexGeneration': 'uniform',
72 'xVertexParams': [0.0, 0.0],
73 'yVertexParams': [0.0, 0.0],
74 'zVertexParams': [0.0, 0.0],
75}
76particleGun.param(param_particleGun)
77mainPath.add_module(particleGun)
78
79if args.withBkg:
80 # Add beam background overlay files
81 bgFiles = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '*.root')
82 # Add simulation
83 add_simulation(mainPath, bkgfiles=bgFiles)
84else:
85 # Simulation
86 add_simulation(mainPath)
87
88# Reconstruction
89add_reconstruction(mainPath)
90
91# Register and add 'ECLDataAnalysis' module and settings
92eclDataAnalysis = b2.register_module('ECLDataAnalysis')
93eclDataAnalysis.param('rootFileName',
94 'EclDataAnalysis_Test.root')
95eclDataAnalysis.param('doTracking', 1)
96eclDataAnalysis.param('doPureCsIStudy', 0)
97mainPath.add_module(eclDataAnalysis)
98
99# Process the events and print call statistics
100mainPath.add_module('Progress')
101b2.process(mainPath)
102print(b2.statistics)