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