Belle II Software  release-08-01-10
path_functions.py
1 
8 
9 
10 def add_ckf_based_merger(path, cdc_reco_tracks, svd_reco_tracks, use_mc_truth=False, direction="backward"):
11  """
12  Convenience function to add the SVD track finding using VXDTF2 and the merger based on the CKF to the path.
13  :param path: The path to add the module to
14  :param cdc_reco_tracks: The name of the already created CDC Reco Tracks
15  :param svd_reco_tracks: The name of the already created CDC Reco Tracks
16  :param use_mc_truth: Use the MC information in the CKF
17  :param direction: where to extrapolate to. Valid options are forward and backward
18  """
19  # The CDC tracks need to be fitted
20  path.add_module("DAFRecoFitter", recoTracksStoreArrayName=cdc_reco_tracks)
21 
22  if use_mc_truth:
23  # MC CKF needs MC matching information
24  path.add_module("MCRecoTracksMatcher", UsePXDHits=False, UseSVDHits=True, UseCDCHits=False,
25  mcRecoTracksStoreArrayName="MCRecoTracks",
26  prRecoTracksStoreArrayName=svd_reco_tracks)
27 
28  result_filter = "truth_svd_cdc_relation"
29  result_filter_parameters = {}
30  else:
31  result_filter = "mva_with_relations"
32  result_filter_parameters = {'DBPayloadName': 'ckf_SeededCDCToSVDResultParameters'}
33 
34  if direction == "forward":
35  reverse_seed = True
36  else:
37  reverse_seed = False
38 
39  path.add_module("CDCToSVDSeedCKF",
40  advanceHighFilterParameters={"direction": direction},
41 
42  fromRelationStoreArrayName=cdc_reco_tracks,
43  toRelationStoreArrayName=svd_reco_tracks,
44 
45  writeOutDirection=direction,
46 
47  inputRecoTrackStoreArrayName=cdc_reco_tracks,
48  relatedRecoTrackStoreArrayName=svd_reco_tracks,
49  relationCheckForDirection=direction,
50  cdcTracksStoreArrayName=cdc_reco_tracks,
51  vxdTracksStoreArrayName=svd_reco_tracks,
52 
53  firstHighFilterParameters={"direction": direction},
54  reverseSeed=reverse_seed,
55 
56  filter=result_filter,
57  filterParameters=result_filter_parameters
58  ).set_name(f"CDCToSVDSeedCKF_{direction}")
59 
60 
61 def add_pxd_ckf(
62  path,
63  svd_cdc_reco_tracks,
64  pxd_reco_tracks,
65  use_mc_truth=False,
66  use_best_seeds=10,
67  use_best_results=2,
68  direction="backward"):
69  """
70  Convenience function to add the PXD ckf to the path.
71  :param path: The path to add the module to
72  :param svd_cdc_reco_tracks: The name of the already created SVD+CDC reco tracks
73  :param pxd_reco_tracks: The name to output the PXD reco tracks to
74  :param use_mc_truth: Use the MC information in the CKF
75  :param use_best_results: CKF parameter for useBestNInSeed
76  :param use_best_seeds: CKF parameter for UseNStates
77  :param direction: where to extrapolate to. Valid options are forward and backward
78  """
79  if "PXDSpacePointCreator" not in [m.name() for m in path.modules()]:
80  path.add_module("PXDSpacePointCreator")
81 
82  path.add_module("DAFRecoFitter", recoTracksStoreArrayName=svd_cdc_reco_tracks)
83 
84  if direction == "forward":
85  reverse_seed = True
86  else:
87  reverse_seed = False
88 
89  if use_mc_truth:
90  path.add_module("MCRecoTracksMatcher", UsePXDHits=False, UseSVDHits=True, UseCDCHits=True,
91  mcRecoTracksStoreArrayName="MCRecoTracks",
92  prRecoTracksStoreArrayName=svd_cdc_reco_tracks)
93 
94  module_parameters = dict(
95  firstHighFilter="truth",
96  secondHighFilter="all",
97  thirdHighFilter="all",
98 
99  filter="truth",
100  useBestNInSeed=1
101  )
102  else:
103  module_parameters = dict(
104  firstHighFilterParameters={
105  'DBPayloadName': 'ckf_ToPXDStateFilter_1Parameters',
106  "direction": direction},
107  firstHighUseNStates=use_best_seeds,
108  secondHighFilterParameters={
109  'DBPayloadName': 'ckf_ToPXDStateFilter_2Parameters'},
110  secondHighUseNStates=use_best_seeds,
111  thirdHighFilterParameters={
112  'DBPayloadName': 'ckf_ToPXDStateFilter_3Parameters'},
113  thirdHighUseNStates=use_best_seeds,
114  filterParameters={
115  'DBPayloadName': 'ckf_PXDTrackCombinationParameters'},
116  useBestNInSeed=use_best_results,
117  )
118 
119  module_parameters["seedHitJumping"] = -1 # get from payload
120  module_parameters["hitHitJumping"] = 0
121 
122  path.add_module("ToPXDCKF",
123  advanceHighFilterParameters={"direction": direction},
124 
125  writeOutDirection=direction,
126 
127  inputRecoTrackStoreArrayName=svd_cdc_reco_tracks,
128  relatedRecoTrackStoreArrayName=pxd_reco_tracks,
129  relationCheckForDirection=direction,
130 
131  outputRecoTrackStoreArrayName=pxd_reco_tracks,
132  outputRelationRecoTrackStoreArrayName=svd_cdc_reco_tracks,
133 
134  reverseSeed=reverse_seed,
135  reverseSeedState=reverse_seed, # Parameter cannot be read twice within a module
136  **module_parameters).set_name(f"ToPXDCKF_{direction}")
137 
138 
139 def add_svd_ckf(
140  path,
141  cdc_reco_tracks,
142  svd_reco_tracks,
143  use_mc_truth=False,
144  use_best_results=5,
145  use_best_seeds=10,
146  direction="backward"):
147  """
148  Convenience function to add the SVD ckf to the path.
149  :param path: The path to add the module to
150  :param cdc_reco_tracks: The name of the already created CDC reco tracks
151  :param svd_reco_tracks: The name to output the SVD reco tracks to
152  :param use_mc_truth: Use the MC information in the CKF
153  :param use_best_results: CKF parameter for useNResults
154  :param use_best_seeds: CKF parameter for useBestNInSeed
155  :param direction: where to extrapolate to. Valid options are forward and backward
156  """
157  if direction == "forward":
158  reverse_seed = True
159  else:
160  reverse_seed = False
161 
162  if use_mc_truth:
163  module_parameters = dict(
164  firstHighFilter="truth",
165  secondHighFilter="all",
166  thirdHighFilter="all",
167 
168  filter="truth",
169  useBestNInSeed=1
170  )
171  else:
172  if direction == "forward":
173  module_parameters = dict(
174  firstHighFilterParameters={
175  "direction": direction,
176  'DBPayloadName': 'ckf_CDCSVDStateFilter_1_forward_Parameters'},
177  firstHighUseNStates=use_best_seeds,
178  secondHighFilterParameters={
179  'DBPayloadName': 'ckf_CDCSVDStateFilter_2_forward_Parameters'},
180  secondHighUseNStates=use_best_seeds,
181  thirdHighFilterParameters={
182  'DBPayloadName': 'ckf_CDCSVDStateFilter_3_forward_Parameters'},
183  thirdHighUseNStates=use_best_seeds,
184  filterParameters={
185  'DBPayloadName': 'ckf_CDCToSVDResultParameters'},
186  useBestNInSeed=use_best_results,
187  )
188  else:
189  module_parameters = dict(
190  firstHighFilterParameters={
191  "direction": direction,
192  'DBPayloadName': 'ckf_CDCSVDStateFilter_1_backward_Parameters'},
193  firstHighUseNStates=use_best_seeds,
194  secondHighFilterParameters={
195  'DBPayloadName': 'ckf_CDCSVDStateFilter_2_backward_Parameters'},
196  secondHighUseNStates=use_best_seeds,
197  thirdHighFilterParameters={
198  'DBPayloadName': 'ckf_CDCSVDStateFilter_3_backward_Parameters'},
199  thirdHighUseNStates=use_best_seeds,
200  filterParameters={
201  'DBPayloadName': 'ckf_CDCToSVDResultParameters'},
202  useBestNInSeed=use_best_results,
203  )
204 
205  path.add_module("CDCToSVDSpacePointCKF",
206  inputRecoTrackStoreArrayName=cdc_reco_tracks,
207  outputRecoTrackStoreArrayName=svd_reco_tracks,
208  outputRelationRecoTrackStoreArrayName=cdc_reco_tracks,
209  relatedRecoTrackStoreArrayName=svd_reco_tracks,
210 
211  advanceHighFilterParameters={"direction": direction},
212  reverseSeed=reverse_seed,
213 
214  writeOutDirection=direction,
215  relationCheckForDirection=direction,
216 
217  seedHitJumping=1,
218  hitHitJumping=1,
219 
220  **module_parameters).set_name(f"CDCToSVDSpacePointCKF_{direction}")
221 
222 
223 def add_cosmics_svd_ckf(
224  path,
225  cdc_reco_tracks,
226  svd_reco_tracks,
227  use_mc_truth=False,
228  use_best_results=5,
229  use_best_seeds=10,
230  direction="backward"):
231  """
232  Convenience function to add the SVD ckf to the path with cosmics settings valid for phase2 and 3.
233  :param path: The path to add the module to
234  :param cdc_reco_tracks: The name of the already created CDC reco tracks
235  :param svd_reco_tracks: The name to output the SVD reco tracks to
236  :param use_mc_truth: Use the MC information in the CKF
237  :param use_best_results: CKF parameter for useNResults
238  :param use_best_seeds: CKF parameter for useBestNInSeed
239  :param direction: where to extrapolate to. Valid options are forward and backward
240  """
241  if direction == "forward":
242  reverse_seed = True
243  else:
244  reverse_seed = False
245 
246  if use_mc_truth:
247  module_parameters = dict(
248  firstHighFilter="truth",
249  secondHighFilter="all",
250  thirdHighFilter="all",
251 
252  filter="truth",
253  useBestNInSeed=1
254  )
255  else:
256  module_parameters = dict(
257  hitFilter="all",
258  seedFilter="all",
259 
260  firstHighFilter="non_ip_crossing",
261  firstHighFilterParameters={"direction": direction},
262  firstHighUseNStates=0,
263 
264  secondHighFilter="residual",
265  secondHighFilterParameters={},
266  secondHighUseNStates=use_best_seeds,
267 
268  thirdHighFilter="residual",
269  thirdHighFilterParameters={},
270  thirdHighUseNStates=use_best_seeds,
271 
272  filter="weight",
273  filterParameters={},
274  useBestNInSeed=use_best_results,
275  )
276 
277  path.add_module("CDCToSVDSpacePointCKF",
278  inputRecoTrackStoreArrayName=cdc_reco_tracks,
279  outputRecoTrackStoreArrayName=svd_reco_tracks,
280  outputRelationRecoTrackStoreArrayName=cdc_reco_tracks,
281  relatedRecoTrackStoreArrayName=svd_reco_tracks,
282 
283  advanceHighFilterParameters={"direction": direction},
284  reverseSeed=reverse_seed,
285 
286  writeOutDirection=direction,
287  relationCheckForDirection=direction,
288 
289  seedHitJumping=3,
290  hitHitJumping=1,
291  **module_parameters).set_name(f"CDCToSVDSpacePointCKF_{direction}")
292 
293 
294 def add_cosmics_pxd_ckf(
295  path,
296  svd_cdc_reco_tracks,
297  pxd_reco_tracks,
298  use_mc_truth=False,
299  use_best_results=5,
300  use_best_seeds=10,
301  direction="backward"):
302  """
303  Convenience function to add the PXD ckf to the path with cosmics settings valid for phase2 and 3.
304  :param path: The path to add the module to
305  :param svd_cdc_reco_tracks: The name of the already created CDC reco tracks
306  :param pxd_reco_tracks: The name to output the SVD reco tracks to
307  :param use_mc_truth: Use the MC information in the CKF
308  :param use_best_results: CKF parameter for useNResults
309  :param use_best_seeds: CKF parameter for useBestNInSeed
310  :param direction: where to extrapolate to. Valid options are forward and backward
311  """
312  if "PXDSpacePointCreator" not in [m.name() for m in path.modules()]:
313  path.add_module("PXDSpacePointCreator")
314 
315  path.add_module("DAFRecoFitter", recoTracksStoreArrayName=svd_cdc_reco_tracks)
316 
317  if direction == "forward":
318  reverse_seed = True
319  else:
320  reverse_seed = False
321 
322  if use_mc_truth:
323  path.add_module("MCRecoTracksMatcher", UsePXDHits=False, UseSVDHits=True, UseCDCHits=True,
324  mcRecoTracksStoreArrayName="MCRecoTracks",
325  prRecoTracksStoreArrayName=svd_cdc_reco_tracks)
326 
327  module_parameters = dict(
328  firstHighFilter="truth",
329  secondHighFilter="all",
330  thirdHighFilter="all",
331 
332  filter="truth",
333  useBestNInSeed=1
334  )
335  else:
336  module_parameters = dict(
337  hitFilter="all",
338  seedFilter="all",
339  preHitFilter="all",
340  preSeedFilter="all",
341  firstHighFilterParameters={
342  'DBPayloadName': 'ckf_ToPXDStateFilter_1Parameters',
343  "direction": direction},
344  firstHighUseNStates=use_best_seeds,
345  secondHighFilterParameters={
346  'DBPayloadName': 'ckf_ToPXDStateFilter_2Parameters'},
347  secondHighUseNStates=use_best_seeds,
348  thirdHighFilterParameters={
349  'DBPayloadName': 'ckf_ToPXDStateFilter_3Parameters'},
350  thirdHighUseNStates=use_best_seeds,
351  filterParameters={
352  'DBPayloadName': 'ckf_PXDTrackCombinationParameters'},
353  useBestNInSeed=use_best_results,
354  seedHitJumping=1,
355  hitHitJumping=0,
356  )
357 
358  path.add_module("ToPXDCKF",
359  advanceHighFilterParameters={"direction": direction},
360 
361  writeOutDirection=direction,
362 
363  inputRecoTrackStoreArrayName=svd_cdc_reco_tracks,
364  relatedRecoTrackStoreArrayName=pxd_reco_tracks,
365  relationCheckForDirection=direction,
366 
367  outputRecoTrackStoreArrayName=pxd_reco_tracks,
368  outputRelationRecoTrackStoreArrayName=svd_cdc_reco_tracks,
369 
370  reverseSeed=reverse_seed,
371  reverseSeedState=reverse_seed,
372  **module_parameters).set_name(f"ToPXDCKF_{direction}")