Belle II Software  release-08-01-10
2_recoTest.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 <header>
14  <output>TOPNtupleRecoTest.root</output>
15  <contact>marko.staric@ijs.si</contact>
16  <description>Makes a flat ntuple for validation of top reconstruction </description>
17 </header>
18 """
19 
20 import basf2 as b2
21 
22 # ---------------------------------------------------------------------------------
23 # Simulate, reconstruct and make a flat ntuple for validation of top reconstruction
24 # Here we just want to test intrinsic TOP PID (no other material and ideal tracks)
25 # ---------------------------------------------------------------------------------
26 
27 # Suppress messages and warnings during processing:
28 b2.set_log_level(b2.LogLevel.ERROR)
29 
30 b2.set_random_seed(123452)
31 
32 # Create path
33 main = b2.create_path()
34 
35 # Set number of events to generate
36 eventinfosetter = b2.register_module('EventInfoSetter')
37 eventinfosetter.param('evtNumList', [10000])
38 main.add_module(eventinfosetter)
39 
40 # Gearbox: access to database (xml files)
41 gearbox = b2.register_module('Gearbox')
42 main.add_module(gearbox)
43 
44 # Geometry (only TOP and B-field, since we are testing intrinsic TOP PID)
45 geometry = b2.register_module('Geometry')
46 geometry.param('useDB', False)
47 geometry.param('components', ['MagneticField', 'TOP'])
48 main.add_module(geometry)
49 
50 # Particle gun: generate multiple tracks
51 particlegun = b2.register_module('ParticleGun')
52 particlegun.param('pdgCodes', [211, -211, 321, -321])
53 particlegun.param('nTracks', 1)
54 particlegun.param('varyNTracks', False)
55 particlegun.param('momentumGeneration', 'fixed')
56 particlegun.param('momentumParams', [3])
57 particlegun.param('thetaGeneration', 'uniformCos')
58 particlegun.param('thetaParams', [30, 122])
59 particlegun.param('phiGeneration', 'uniform')
60 particlegun.param('phiParams', [0, 360])
61 particlegun.param('vertexGeneration', 'fixed')
62 particlegun.param('xVertexParams', [0])
63 particlegun.param('yVertexParams', [0])
64 particlegun.param('zVertexParams', [0])
65 main.add_module(particlegun)
66 
67 # Simulation
68 simulation = b2.register_module('FullSim')
69 main.add_module(simulation)
70 
71 # TOP digitization
72 topdigi = b2.register_module('TOPDigitizer')
73 main.add_module(topdigi)
74 
75 # Dedicated track maker using MC information only
76 trackmaker = b2.register_module('TOPMCTrackMaker')
77 main.add_module(trackmaker)
78 
79 # Channel masker
80 main.add_module('TOPChannelMasker')
81 
82 # TOP reconstruction
83 topreco = b2.register_module('TOPReconstructor')
84 main.add_module(topreco)
85 
86 # Output: make flat ntuple from TOPLikelihoods, tracking info and MC truth
87 output = b2.register_module('TOPNtuple')
88 output.param('outputFileName', '../TOPNtupleRecoTest.root')
89 main.add_module(output)
90 
91 # Show progress of processing
92 main.add_module('Progress')
93 
94 # Process events
95 b2.process(main)
96 
97 # Print call statistics
98 print(b2.statistics)