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