Belle II Software development
EclMaterialAnalysis.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 starting from dst root file.
14
15The user should provide input and output root filenames
16as first and second argument respectively.
17
18Usage:
19 $ basf2 EclMaterialAnalysis.py [-- --withBkg]
20"""
21
22import argparse
23import basf2 as b2
24from simulation import add_simulation
25from reconstruction import add_reconstruction
26
27
28def argparser():
29
30 parser = argparse.ArgumentParser()
31
32 parser.add_argument('--withBkg',
33 action='store_true',
34 default=False,
35 help='Add beam background'
36 'Default is False i.e. no beam background.')
37 return parser
38
39
40args = argparser().parse_args()
41
42# Create path. Register necessary modules to this path.
43mainPath = b2.create_path()
44
45# Register and add 'EventInfoSetter' module and settings
46eventInfoSetter = b2.register_module('EventInfoSetter')
47eventInfoSetter.param({'evtNumList': [100000],
48 'runList': [1],
49 'expList': [0]})
50mainPath.add_module(eventInfoSetter)
51
52# Random number for generation
53b2.set_random_seed(123456)
54
55# Create geometry
56
57# Geometry parameter loader
58# gearbox = b2.register_module('Gearbox')
59# mainPath.add_module(gearbox)
60
61# Geometry builder
62# geometry = b2.register_module('Geometry')
63# geometry.param('components', ['ECL'])
64# mainPath.add_module(geometry)
65
66components = [ # 'MagneticField',
67 # 'BeamPipe',
68 'ECL',
69 'PXD',
70 'SVD',
71 'CDC',
72 # 'EKLM',
73 # 'BKLM',
74 # 'TOP',
75 'ARICH',
76]
77
78# Simulation
79# g4sim = b2.register_module('FullSim')
80# mainPath.add_module(g4sim)
81
82# Register and add 'ParticleGun' generator module and settings
83particleGun = b2.register_module('ParticleGun')
84param_particleGun = {
85 'pdgCodes': [22], # 22: photon
86 'nTracks': 1,
87 'momentumGeneration': 'fixed',
88 'momentumParams': [0.5],
89 'thetaGeneration': 'uniform', # uniformCos,
90 'thetaParams': [(12.01), (31.36)],
91 'phiGeneration': 'uniform',
92 'phiParams': [0., 360.],
93 'vertexGeneration': 'uniform',
94 'xVertexParams': [0.0, 0.0],
95 'yVertexParams': [0.0, 0.0],
96 'zVertexParams': [0.0, 0.0],
97}
98particleGun.param(param_particleGun)
99mainPath.add_module(particleGun)
100
101if args.withBkg:
102 bkgdir = 'bkg/'
103 # bkgFiles = glob.glob(bkgdir+'*.root')
104 bkgFiles = [
105 bkgdir + 'Coulomb_HER_100us.root',
106 bkgdir + 'Coulomb_LER_100us.root',
107 bkgdir + 'Coulomb_HER_100usECL.root',
108 bkgdir + 'Coulomb_LER_100usECL.root',
109 bkgdir + 'RBB_HER_100us.root',
110 bkgdir + 'RBB_LER_100us.root',
111 bkgdir + 'RBB_HER_100usECL.root',
112 bkgdir + 'RBB_LER_100usECL.root',
113 bkgdir + 'Touschek_HER_100us.root',
114 bkgdir + 'Touschek_LER_100us.root',
115 bkgdir + 'Touschek_HER_100usECL.root',
116 bkgdir + 'Touschek_LER_100usECL.root',
117 ]
118 # Simulation
119 add_simulation(mainPath, bkgfiles=bkgFiles)
120else:
121 add_simulation(mainPath)
122
123# Reconstruction
124add_reconstruction(mainPath)
125
126# display = b2.register_module('Display')
127# mainPath.add_module(display)
128
129# Register and add 'ECLDataAnalysis' module
130eclDataAnalysis = b2.register_module('ECLDataAnalysis')
131eclDataAnalysis.param('rootFileName',
132 'EclDataAnalysis_500MeV_100000_Full_FWD.root')
133eclDataAnalysis.param('doTracking', 0)
134mainPath.add_module(eclDataAnalysis)
135
136# Process the events and print call statistics
137mainPath.add_module('Progress')
138b2.process(mainPath)
139print(b2.statistics)