Belle II Software  release-08-00-04
extmuid_createPions.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
18 
19 """
20 <header>
21  <output>pion-ExtMuidValidation.root</output>
22  <contact>giacomo.pietro@kit.edu</contact>
23  <description>Create events with 1 pion track for ext/muid validation.</description>
24 </header>
25 """
26 
27 import glob
28 import basf2 as b2
29 import os
30 from simulation import add_simulation
31 from reconstruction import add_reconstruction
32 
33 b2.set_random_seed(654321)
34 
35 output_filename = '../pion-ExtMuidValidation.root'
36 
37 print(output_filename)
38 
39 path = b2.create_path()
40 
41 eventinfosetter = b2.register_module('EventInfoSetter')
42 eventinfosetter.param('evtNumList', [1000])
43 path.add_module(eventinfosetter)
44 
45 progress = b2.register_module('Progress')
46 path.add_module(progress)
47 
48 pgun = b2.register_module('ParticleGun')
49 param_pgun = {
50  'pdgCodes': [-211, 211],
51  'nTracks': 1,
52  'varyNTracks': 0,
53  'momentumGeneration': 'uniform',
54  'momentumParams': [0.5, 5.0],
55  'thetaGeneration': 'uniformCos',
56  'thetaParams': [15., 150.],
57  'phiGeneration': 'uniform',
58  'phiParams': [0.0, 360.0],
59  'vertexGeneration': 'fixed',
60  'xVertexParams': [0.0],
61  'yVertexParams': [0.0],
62  'zVertexParams': [0.0],
63 }
64 pgun.param(param_pgun)
65 path.add_module(pgun)
66 
67 # add simulation and reconstruction modules to the path
68 if 'BELLE2_BACKGROUND_DIR' in os.environ:
69  background_files = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '/*.root')
70  add_simulation(path, bkgfiles=background_files)
71 else:
72  b2.B2FATAL('BELLE2_BACKGROUND_DIR is not set.')
73 
74 add_reconstruction(path)
75 
76 output = b2.register_module('RootOutput')
77 output.param('outputFileName', output_filename)
78 output.param('branchNames', ['MCParticles', 'ExtHits', 'KLMMuidLikelihoods', 'KLMHit2ds'])
79 path.add_module(output)
80 
81 b2.process(path)
82 print(b2.statistics)