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