Belle II Software development
path_functions.py
1
8
9
10def 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).set_name(f"DAFRecoFitter {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
61def 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).set_name(f"DAFRecoFitter {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 module_parameters = dict(
91 firstHighFilter="truth",
92 secondHighFilter="all",
93 thirdHighFilter="all",
94
95 filter="truth",
96 useBestNInSeed=1
97 )
98 else:
99 module_parameters = dict(
100 firstHighFilterParameters={
101 'DBPayloadName': 'ckf_ToPXDStateFilter_1Parameters',
102 "direction": direction},
103 firstHighUseNStates=use_best_seeds,
104 secondHighFilterParameters={
105 'DBPayloadName': 'ckf_ToPXDStateFilter_2Parameters'},
106 secondHighUseNStates=use_best_seeds,
107 thirdHighFilterParameters={
108 'DBPayloadName': 'ckf_ToPXDStateFilter_3Parameters'},
109 thirdHighUseNStates=use_best_seeds,
110 filterParameters={
111 'DBPayloadName': 'ckf_PXDTrackCombinationParameters'},
112 useBestNInSeed=use_best_results,
113 )
114
115 module_parameters["seedHitJumping"] = -1 # get from payload
116 module_parameters["hitHitJumping"] = 0
117
118 path.add_module("ToPXDCKF",
119 advanceHighFilterParameters={"direction": direction},
120
121 writeOutDirection=direction,
122
123 inputRecoTrackStoreArrayName=svd_cdc_reco_tracks,
124 relatedRecoTrackStoreArrayName=pxd_reco_tracks,
125 relationCheckForDirection=direction,
126
127 outputRecoTrackStoreArrayName=pxd_reco_tracks,
128 outputRelationRecoTrackStoreArrayName=svd_cdc_reco_tracks,
129
130 reverseSeed=reverse_seed,
131 reverseSeedState=reverse_seed, # Parameter cannot be read twice within a module
132 **module_parameters).set_name(f"ToPXDCKF_{direction}")
133
134
135def add_svd_ckf(
136 path,
137 cdc_reco_tracks,
138 svd_reco_tracks,
139 use_mc_truth=False,
140 use_best_results=5,
141 use_best_seeds=10,
142 direction="backward"):
143 """
144 Convenience function to add the SVD ckf to the path.
145 :param path: The path to add the module to
146 :param cdc_reco_tracks: The name of the already created CDC reco tracks
147 :param svd_reco_tracks: The name to output the SVD reco tracks to
148 :param use_mc_truth: Use the MC information in the CKF
149 :param use_best_results: CKF parameter for useNResults
150 :param use_best_seeds: CKF parameter for useBestNInSeed
151 :param direction: where to extrapolate to. Valid options are forward and backward
152 """
153 if direction == "forward":
154 reverse_seed = True
155 else:
156 reverse_seed = False
157
158 if use_mc_truth:
159 module_parameters = dict(
160 firstHighFilter="truth",
161 secondHighFilter="all",
162 thirdHighFilter="all",
163
164 filter="truth",
165 useBestNInSeed=1
166 )
167 else:
168 module_parameters = dict(
169 firstHighFilterParameters={
170 "direction": direction,
171 'DBPayloadName': f'ckf_CDCSVDStateFilter_1_{direction}_Parameters'},
172 firstHighUseNStates=use_best_seeds,
173 secondHighFilterParameters={
174 'DBPayloadName': f'ckf_CDCSVDStateFilter_2_{direction}_Parameters'},
175 secondHighUseNStates=use_best_seeds,
176 thirdHighFilterParameters={
177 'DBPayloadName': f'ckf_CDCSVDStateFilter_3_{direction}_Parameters'},
178 thirdHighUseNStates=use_best_seeds,
179 filterParameters={
180 'DBPayloadName': 'ckf_CDCToSVDResultParameters'},
181 useBestNInSeed=use_best_results,
182 )
183
184 path.add_module("CDCToSVDSpacePointCKF",
185 inputRecoTrackStoreArrayName=cdc_reco_tracks,
186 outputRecoTrackStoreArrayName=svd_reco_tracks,
187 outputRelationRecoTrackStoreArrayName=cdc_reco_tracks,
188 relatedRecoTrackStoreArrayName=svd_reco_tracks,
189
190 advanceHighFilterParameters={"direction": direction},
191 reverseSeed=reverse_seed,
192
193 writeOutDirection=direction,
194 relationCheckForDirection=direction,
195
196 seedHitJumping=1,
197 hitHitJumping=1,
198
199 **module_parameters).set_name(f"CDCToSVDSpacePointCKF_{direction}")
200
201
202def add_cosmics_svd_ckf(
203 path,
204 cdc_reco_tracks,
205 svd_reco_tracks,
206 use_mc_truth=False,
207 use_best_results=5,
208 use_best_seeds=10,
209 direction="backward"):
210 """
211 Convenience function to add the SVD ckf to the path with cosmics settings valid for phase2 and 3.
212 :param path: The path to add the module to
213 :param cdc_reco_tracks: The name of the already created CDC reco tracks
214 :param svd_reco_tracks: The name to output the SVD reco tracks to
215 :param use_mc_truth: Use the MC information in the CKF
216 :param use_best_results: CKF parameter for useNResults
217 :param use_best_seeds: CKF parameter for useBestNInSeed
218 :param direction: where to extrapolate to. Valid options are forward and backward
219 """
220 if direction == "forward":
221 reverse_seed = True
222 else:
223 reverse_seed = False
224
225 if use_mc_truth:
226 module_parameters = dict(
227 firstHighFilter="truth",
228 secondHighFilter="all",
229 thirdHighFilter="all",
230
231 filter="truth",
232 useBestNInSeed=1
233 )
234 else:
235 module_parameters = dict(
236 hitFilter="all",
237 seedFilter="all",
238
239 firstHighFilter="non_ip_crossing",
240 firstHighFilterParameters={"direction": direction},
241 firstHighUseNStates=0,
242
243 secondHighFilter="residual",
244 secondHighFilterParameters={},
245 secondHighUseNStates=use_best_seeds,
246
247 thirdHighFilter="residual",
248 thirdHighFilterParameters={},
249 thirdHighUseNStates=use_best_seeds,
250
251 filter="weight",
252 filterParameters={},
253 useBestNInSeed=use_best_results,
254 )
255
256 path.add_module("CDCToSVDSpacePointCKF",
257 inputRecoTrackStoreArrayName=cdc_reco_tracks,
258 outputRecoTrackStoreArrayName=svd_reco_tracks,
259 outputRelationRecoTrackStoreArrayName=cdc_reco_tracks,
260 relatedRecoTrackStoreArrayName=svd_reco_tracks,
261
262 advanceHighFilterParameters={"direction": direction},
263 reverseSeed=reverse_seed,
264
265 writeOutDirection=direction,
266 relationCheckForDirection=direction,
267
268 seedHitJumping=3,
269 hitHitJumping=1,
270 **module_parameters).set_name(f"CDCToSVDSpacePointCKF_{direction}")
271
272
273def add_cosmics_pxd_ckf(
274 path,
275 svd_cdc_reco_tracks,
276 pxd_reco_tracks,
277 use_mc_truth=False,
278 use_best_results=5,
279 use_best_seeds=10,
280 direction="backward"):
281 """
282 Convenience function to add the PXD ckf to the path with cosmics settings valid for phase2 and 3.
283 :param path: The path to add the module to
284 :param svd_cdc_reco_tracks: The name of the already created CDC reco tracks
285 :param pxd_reco_tracks: The name to output the SVD reco tracks to
286 :param use_mc_truth: Use the MC information in the CKF
287 :param use_best_results: CKF parameter for useNResults
288 :param use_best_seeds: CKF parameter for useBestNInSeed
289 :param direction: where to extrapolate to. Valid options are forward and backward
290 """
291 if "PXDSpacePointCreator" not in [m.name() for m in path.modules()]:
292 path.add_module("PXDSpacePointCreator")
293
294 path.add_module("DAFRecoFitter", recoTracksStoreArrayName=svd_cdc_reco_tracks).set_name(f"DAFRecoFitter {svd_cdc_reco_tracks}")
295
296 if direction == "forward":
297 reverse_seed = True
298 else:
299 reverse_seed = False
300
301 if use_mc_truth:
302 path.add_module("MCRecoTracksMatcher", UsePXDHits=False, UseSVDHits=True, UseCDCHits=True,
303 mcRecoTracksStoreArrayName="MCRecoTracks",
304 prRecoTracksStoreArrayName=svd_cdc_reco_tracks)
305
306 module_parameters = dict(
307 firstHighFilter="truth",
308 secondHighFilter="all",
309 thirdHighFilter="all",
310
311 filter="truth",
312 useBestNInSeed=1
313 )
314 else:
315 module_parameters = dict(
316 hitFilter="all",
317 seedFilter="all",
318 preHitFilter="all",
319 preSeedFilter="all",
320 firstHighFilterParameters={
321 'DBPayloadName': 'ckf_ToPXDStateFilter_1Parameters',
322 "direction": direction},
323 firstHighUseNStates=use_best_seeds,
324 secondHighFilterParameters={
325 'DBPayloadName': 'ckf_ToPXDStateFilter_2Parameters'},
326 secondHighUseNStates=use_best_seeds,
327 thirdHighFilterParameters={
328 'DBPayloadName': 'ckf_ToPXDStateFilter_3Parameters'},
329 thirdHighUseNStates=use_best_seeds,
330 filterParameters={
331 'DBPayloadName': 'ckf_PXDTrackCombinationParameters'},
332 useBestNInSeed=use_best_results,
333 seedHitJumping=1,
334 hitHitJumping=0,
335 )
336
337 path.add_module("ToPXDCKF",
338 advanceHighFilterParameters={"direction": direction},
339
340 writeOutDirection=direction,
341
342 inputRecoTrackStoreArrayName=svd_cdc_reco_tracks,
343 relatedRecoTrackStoreArrayName=pxd_reco_tracks,
344 relationCheckForDirection=direction,
345
346 outputRecoTrackStoreArrayName=pxd_reco_tracks,
347 outputRelationRecoTrackStoreArrayName=svd_cdc_reco_tracks,
348
349 reverseSeed=reverse_seed,
350 reverseSeedState=reverse_seed,
351 **module_parameters).set_name(f"ToPXDCKF_{direction}")