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