19 from simulation
import add_simulation
20 from reconstruction
import add_reconstruction
27 def get_generated_pdg_code():
31 def get_simulation_components():
35 def get_reconstruction_components():
37 return get_simulation_components()
40 def get_generated_pt_value(index):
42 List with generated pt values is created in this function. With the
43 parameter index, one is able to access single pt values. If index == -1,
44 the number of pt values in the list is returned.
68 return pt_values[index]
70 print(
'ERROR in %s. Index is out of range. Only %d elements in list.'
71 % (get_generated_pt_value.__name__, len(pt_values)))
75 def get_generated_pt_values():
77 Collects all pt values with help of the function get_generated_pt_value
78 and stores them in a list, that is returned
80 @return list of pt values
84 for index
in range(get_generated_pt_value(-1)):
85 list.append(get_generated_pt_value(index))
90 def additional_options(path):
92 This sets the specifics of simulation and reconstruction in order
93 to use consistent settings across the various involved modules.
97 useInWirePropagation = 1
100 for m
in path.modules():
102 if m.type() ==
'CDCDigitizer':
103 m.param(
'AddInWirePropagationDelay', useInWirePropagation)
104 m.param(
'AddTimeOfFlight', useTime)
105 m.param(
'CorrectForWireSag', useWireSag)
107 if m.type() ==
'CDCDigitizer':
108 m.param(
'AddInWirePropagationDelay', 0)
109 m.param(
'AddTimeOfFlight', 0)
110 m.param(
'CorrectForWireSag', 0)
112 if m.type() ==
'DAFRecoFitter':
113 m.param(
'pdgCodesToUseForFitting', [get_generated_pdg_code()])
115 if m.type() ==
"TrackCreator":
116 m.param(
'pdgCodes', [get_generated_pdg_code(), 211])
119 def run_simulation(path, pt_value, output_filename=''):
120 """Add needed modules to the path and set parameters and start it"""
123 eventinfosetter = b2.register_module(
'EventInfoSetter')
126 eventinfosetter.param(
'expList', [0])
127 eventinfosetter.param(
'runList', [1])
128 eventinfosetter.param(
'evtNumList', [200])
130 path.add_module(eventinfosetter)
132 progress = b2.register_module(
'Progress')
133 path.add_module(progress)
136 pgun = b2.register_module(
'ParticleGun')
139 'pdgCodes': [get_generated_pdg_code(), -get_generated_pdg_code()],
142 'momentumGeneration':
'uniformPt',
143 'momentumParams': [pt_value, pt_value],
144 'vertexGeneration':
'fixed',
145 'xVertexParams': [0.0],
146 'yVertexParams': [0.0],
147 'zVertexParams': [0.0],
148 'thetaGeneration':
'uniformCos',
151 pgun.param(param_pgun)
153 path.add_module(pgun)
155 background_files = []
156 if 'BELLE2_BACKGROUND_DIR' in os.environ:
157 background_files += glob.glob(os.environ[
'BELLE2_BACKGROUND_DIR'] +
'/*.root')
159 print(
'Number of used background files (%d): ' % len(background_files))
161 if len(background_files) == 0:
162 background_files =
None
165 add_simulation(path, get_simulation_components(), background_files)
167 additional_options(path)
169 if output_filename !=
'':
170 root_output = b2.register_module(
'RootOutput')
171 root_output.param(
'outputFileName', output_filename)
172 path.add_module(root_output)
175 def run_reconstruction(path, output_file_name, input_file_name=''):
176 if input_file_name !=
'':
177 root_input = b2.register_module(
'RootInput')
178 root_input.param(
'inputFileNames', input_file_name)
179 path.add_module(root_input)
181 gearbox = b2.register_module(
'Gearbox')
182 path.add_module(gearbox)
184 geometry = b2.register_module(
'Geometry')
185 geometry.param(
"useDB",
True)
186 path.add_module(geometry)
188 add_reconstruction(path, get_reconstruction_components(), pruneTracks=0)
191 tracking_efficiency = b2.register_module(
'StandardTrackingPerformance')
193 tracking_efficiency.param(
'outputFileName', output_file_name)
194 path.add_module(tracking_efficiency)
196 additional_options(path)