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