18from simulation
import add_simulation
19from reconstruction
import add_reconstruction
26def get_generated_pdg_code():
30def get_simulation_components():
34def get_reconstruction_components():
36 return get_simulation_components()
39def get_generated_pt_value(index):
41 List with generated pt values
is created
in this function. With the
42 parameter index, one
is able to access single pt values. If index == -1,
43 the number of pt values
in the list
is returned.
67 return pt_values[index]
69 print(
'ERROR in %s. Index is out of range. Only %d elements in list.'
70 % (get_generated_pt_value.__name__, len(pt_values)))
74def get_generated_pt_values():
76 Collects all pt values with help of the function get_generated_pt_value
77 and stores them
in a list, that
is returned
79 @return list of pt values
83 for index
in range(get_generated_pt_value(-1)):
84 list.append(get_generated_pt_value(index))
89def additional_options(path):
91 This sets the specifics of simulation and reconstruction
in order
92 to use consistent settings across the various involved modules.
96 useInWirePropagation = 1
99 for m
in path.modules():
101 if m.type() ==
'CDCDigitizer':
102 m.param(
'AddInWirePropagationDelay', useInWirePropagation)
103 m.param(
'AddTimeOfFlight', useTime)
104 m.param(
'CorrectForWireSag', useWireSag)
106 if m.type() ==
'CDCDigitizer':
107 m.param(
'AddInWirePropagationDelay', 0)
108 m.param(
'AddTimeOfFlight', 0)
109 m.param(
'CorrectForWireSag', 0)
111 if m.type() ==
'DAFRecoFitter':
112 m.param(
'pdgCodesToUseForFitting', [get_generated_pdg_code()])
114 if m.type() ==
"TrackCreator":
115 m.param(
'pdgCodes', [get_generated_pdg_code(), 211])
118def run_simulation(path, pt_value, output_filename=''):
119 """Add needed modules to the path and set parameters and start it"""
122 eventinfosetter = b2.register_module(
'EventInfoSetter')
125 eventinfosetter.param(
'expList', [0])
126 eventinfosetter.param(
'runList', [1])
127 eventinfosetter.param(
'evtNumList', [200])
129 path.add_module(eventinfosetter)
131 progress = b2.register_module(
'Progress')
132 path.add_module(progress)
135 pgun = b2.register_module(
'ParticleGun')
138 'pdgCodes': [get_generated_pdg_code(), -get_generated_pdg_code()],
141 'momentumGeneration':
'uniformPt',
142 'momentumParams': [pt_value, pt_value],
143 'vertexGeneration':
'fixed',
144 'xVertexParams': [0.0],
145 'yVertexParams': [0.0],
146 'zVertexParams': [0.0],
147 'thetaGeneration':
'uniformCos',
150 pgun.param(param_pgun)
152 path.add_module(pgun)
154 background_files = []
155 if 'BELLE2_BACKGROUND_DIR' in os.environ:
156 background_files += glob.glob(os.environ[
'BELLE2_BACKGROUND_DIR'] +
'/*.root')
158 print(f
'Number of used background files ({len(background_files)}): ')
160 if len(background_files) == 0:
161 background_files =
None
164 add_simulation(path, get_simulation_components(), background_files)
166 additional_options(path)
168 if output_filename !=
'':
169 root_output = b2.register_module(
'RootOutput')
170 root_output.param(
'outputFileName', output_filename)
171 path.add_module(root_output)
174def run_reconstruction(path, output_file_name, input_file_name=''):
175 if input_file_name !=
'':
176 root_input = b2.register_module(
'RootInput')
177 root_input.param(
'inputFileNames', input_file_name)
178 path.add_module(root_input)
180 gearbox = b2.register_module(
'Gearbox')
181 path.add_module(gearbox)
183 geometry = b2.register_module(
'Geometry')
184 geometry.param(
"useDB",
True)
185 path.add_module(geometry)
187 add_reconstruction(path, get_reconstruction_components(), pruneTracks=0)
190 tracking_efficiency = b2.register_module(
'StandardTrackingPerformance')
192 tracking_efficiency.param(
'outputFileName', output_file_name)
193 path.add_module(tracking_efficiency)
195 additional_options(path)