Belle II Software  release-06-02-00
gun.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # --------------------------------------------------------------------
13 # Example of using TOP reconstruction
14 # needs reconstructed tracks (Tracks), extrapolated to TOP (ExtHits)
15 # log likelihoods in TOPLikelihoods
16 # relation from Tracks to TOPLikelihoods
17 # --------------------------------------------------------------------
18 
19 import basf2 as b2
20 from tracking import add_tracking_reconstruction
21 from simulation import add_svd_simulation
22 
23 # Suppress messages and warnings during processing:
24 b2.set_log_level(b2.LogLevel.ERROR)
25 
26 # Create path
27 main = b2.create_path()
28 
29 # Set number of events to generate
30 eventinfosetter = b2.register_module('EventInfoSetter')
31 eventinfosetter.param('evtNumList', [10])
32 main.add_module(eventinfosetter)
33 
34 # Histogram manager immediately after master module
35 histo = b2.register_module('HistoManager')
36 histo.param('histoFileName', 'DQMhistograms.root') # File to save histograms
37 main.add_module(histo)
38 
39 # Gearbox: access to database (xml files)
40 gearbox = b2.register_module('Gearbox')
41 main.add_module(gearbox)
42 
43 # Geometry
44 geometry = b2.register_module('Geometry')
45 main.add_module(geometry)
46 
47 # Particle gun: generate multiple tracks
48 particlegun = b2.register_module('ParticleGun')
49 particlegun.param('pdgCodes', [211, -211, 321, -321])
50 particlegun.param('nTracks', 5)
51 particlegun.param('varyNTracks', True)
52 particlegun.param('momentumGeneration', 'uniform')
53 particlegun.param('momentumParams', [0.5, 4])
54 particlegun.param('thetaGeneration', 'uniformCos')
55 particlegun.param('thetaParams', [32, 122])
56 particlegun.param('phiGeneration', 'uniform')
57 particlegun.param('phiParams', [0, 360])
58 particlegun.param('vertexGeneration', 'fixed')
59 particlegun.param('xVertexParams', [0])
60 particlegun.param('yVertexParams', [0])
61 particlegun.param('zVertexParams', [0])
62 particlegun.param('independentVertices', False)
63 main.add_module(particlegun)
64 
65 # Simulation
66 simulation = b2.register_module('FullSim')
67 main.add_module(simulation)
68 
69 # PXD digitization & clustering
70 pxd_digitizer = b2.register_module('PXDDigitizer')
71 main.add_module(pxd_digitizer)
72 pxd_clusterizer = b2.register_module('PXDClusterizer')
73 main.add_module(pxd_clusterizer)
74 
75 # SVD digitization & clustering
76 add_svd_simulation(main)
77 
78 # CDC digitization
79 cdcDigitizer = b2.register_module('CDCDigitizer')
80 main.add_module(cdcDigitizer)
81 
82 # TOP digitization
83 topdigi = b2.register_module('TOPDigitizer')
84 main.add_module(topdigi)
85 
86 # tracking
87 add_tracking_reconstruction(main)
88 
89 # Track extrapolation
90 ext = b2.register_module('Ext')
91 main.add_module(ext)
92 
93 # Channel masker
94 main.add_module('TOPChannelMasker')
95 
96 # TOP reconstruction
97 topreco = b2.register_module('TOPReconstructor')
98 topreco.logging.log_level = b2.LogLevel.DEBUG # remove or comment to suppress printout
99 topreco.logging.debug_level = 2 # or set level to 0 to suppress printout
100 main.add_module(topreco)
101 
102 # TOP DQM
103 topdqm = b2.register_module('TOPDQM')
104 main.add_module(topdqm)
105 
106 # Output
107 output = b2.register_module('RootOutput')
108 output.param('outputFileName', 'TOPOutput.root')
109 main.add_module(output)
110 
111 # Show progress of processing
112 progress = b2.register_module('Progress')
113 main.add_module(progress)
114 
115 # Process events
116 b2.process(main)
117 
118 # Print call statistics
119 print(b2.statistics)