16 <contact>Michael Ziegler, michael.ziegler2@kit.edu</contact>
17 <description> To be filled by the contact person</description>
21 from simulation
import add_simulation
22 from reconstruction
import add_reconstruction, add_mc_reconstruction
29 def get_generated_pdg_code():
33 def get_simulation_components():
37 def get_reconstruction_components():
39 return get_simulation_components()
42 def get_generated_pt_value(index):
44 List with generated pt values is created in this function. With the
45 parameter index, one is able to access single pt values. If index == -1,
46 the number of pt values in the list is returned.
70 return pt_values[index]
72 print(
'ERROR in %s. Index is out of range. Only %d elements in list.'
73 % (get_generated_pt_value.__name__, len(pt_values)))
77 def get_generated_pt_values():
79 Collects all pt values with help of the function get_generated_pt_value
80 and stores them in a list, that is returned
82 @return list of pt values
86 for index
in range(get_generated_pt_value(-1)):
87 list.append(get_generated_pt_value(index))
92 def additional_options(path):
94 This sets the specifics of simulation and reconstruction in order
95 to use consistent settings across the various involved modules.
99 useInWirePropagation = 1
102 for m
in path.modules():
104 if m.type() ==
'CDCDigitizer':
105 m.param(
'AddInWirePropagationDelay', useInWirePropagation)
106 m.param(
'AddTimeOfFlight', useTime)
107 m.param(
'CorrectForWireSag', useWireSag)
109 if m.type() ==
'CDCDigitizer':
110 m.param(
'AddInWirePropagationDelay', 0)
111 m.param(
'AddTimeOfFlight', 0)
112 m.param(
'CorrectForWireSag', 0)
114 if m.type() ==
'DAFRecoFitter':
115 m.param(
'pdgCodesToUseForFitting', [get_generated_pdg_code()])
117 if m.type() ==
"TrackCreator":
118 m.param(
'pdgCodes', [get_generated_pdg_code(), 211])
121 def run_simulation(path, pt_value, output_filename=''):
122 """Add needed modules to the path and set parameters and start it"""
125 eventinfosetter = register_module(
'EventInfoSetter')
128 eventinfosetter.param(
'expList', [0])
129 eventinfosetter.param(
'runList', [1])
130 eventinfosetter.param(
'evtNumList', [200])
132 path.add_module(eventinfosetter)
134 progress = register_module(
'Progress')
135 path.add_module(progress)
138 pgun = register_module(
'ParticleGun')
141 'pdgCodes': [get_generated_pdg_code(), -get_generated_pdg_code()],
144 'momentumGeneration':
'uniformPt',
145 'momentumParams': [pt_value, pt_value],
146 'vertexGeneration':
'fixed',
147 'xVertexParams': [0.0],
148 'yVertexParams': [0.0],
149 'zVertexParams': [0.0],
150 'thetaGeneration':
'uniformCos',
153 pgun.param(param_pgun)
155 path.add_module(pgun)
157 background_files = []
158 if 'BELLE2_BACKGROUND_DIR' in os.environ:
159 background_files += glob.glob(os.environ[
'BELLE2_BACKGROUND_DIR'] +
'/*.root')
161 print(
'Number of used background files (%d): ' % len(background_files))
163 if len(background_files) == 0:
164 background_files =
None
167 add_simulation(path, get_simulation_components(), background_files)
169 additional_options(path)
171 if output_filename !=
'':
172 root_output = register_module(
'RootOutput')
173 root_output.param(
'outputFileName', output_filename)
174 path.add_module(root_output)
177 def run_reconstruction(path, output_file_name, input_file_name=''):
178 if input_file_name !=
'':
179 root_input = register_module(
'RootInput')
180 root_input.param(
'inputFileNames', input_file_name)
181 path.add_module(root_input)
183 gearbox = register_module(
'Gearbox')
184 path.add_module(gearbox)
186 geometry = register_module(
'Geometry')
187 geometry.param(
"useDB",
True)
188 path.add_module(geometry)
190 add_reconstruction(path, get_reconstruction_components(), pruneTracks=0)
193 tracking_efficiency = register_module(
'StandardTrackingPerformance')
195 tracking_efficiency.param(
'outputFileName', output_file_name)
196 path.add_module(tracking_efficiency)
198 additional_options(path)