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