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)
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)
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
139def 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 module_parameters = dict(
173 firstHighFilterParameters={
174 "direction": direction,
175 'DBPayloadName': f'ckf_CDCSVDStateFilter_1_{direction}_Parameters'},
176 firstHighUseNStates=use_best_seeds,
177 secondHighFilterParameters={
178 'DBPayloadName': f'ckf_CDCSVDStateFilter_2_{direction}_Parameters'},
179 secondHighUseNStates=use_best_seeds,
180 thirdHighFilterParameters={
181 'DBPayloadName': f'ckf_CDCSVDStateFilter_3_{direction}_Parameters'},
182 thirdHighUseNStates=use_best_seeds,
183 filterParameters={
184 'DBPayloadName': 'ckf_CDCToSVDResultParameters'},
185 useBestNInSeed=use_best_results,
186 )
187
188 path.add_module("CDCToSVDSpacePointCKF",
189 inputRecoTrackStoreArrayName=cdc_reco_tracks,
190 outputRecoTrackStoreArrayName=svd_reco_tracks,
191 outputRelationRecoTrackStoreArrayName=cdc_reco_tracks,
192 relatedRecoTrackStoreArrayName=svd_reco_tracks,
193
194 advanceHighFilterParameters={"direction": direction},
195 reverseSeed=reverse_seed,
196
197 writeOutDirection=direction,
198 relationCheckForDirection=direction,
199
200 seedHitJumping=1,
201 hitHitJumping=1,
202
203 **module_parameters).set_name(f"CDCToSVDSpacePointCKF_{direction}")
204
205
206def add_cosmics_svd_ckf(
207 path,
208 cdc_reco_tracks,
209 svd_reco_tracks,
210 use_mc_truth=False,
211 use_best_results=5,
212 use_best_seeds=10,
213 direction="backward"):
214 """
215 Convenience function to add the SVD ckf to the path with cosmics settings valid for phase2 and 3.
216 :param path: The path to add the module to
217 :param cdc_reco_tracks: The name of the already created CDC reco tracks
218 :param svd_reco_tracks: The name to output the SVD reco tracks to
219 :param use_mc_truth: Use the MC information in the CKF
220 :param use_best_results: CKF parameter for useNResults
221 :param use_best_seeds: CKF parameter for useBestNInSeed
222 :param direction: where to extrapolate to. Valid options are forward and backward
223 """
224 if direction == "forward":
225 reverse_seed = True
226 else:
227 reverse_seed = False
228
229 if use_mc_truth:
230 module_parameters = dict(
231 firstHighFilter="truth",
232 secondHighFilter="all",
233 thirdHighFilter="all",
234
235 filter="truth",
236 useBestNInSeed=1
237 )
238 else:
239 module_parameters = dict(
240 hitFilter="all",
241 seedFilter="all",
242
243 firstHighFilter="non_ip_crossing",
244 firstHighFilterParameters={"direction": direction},
245 firstHighUseNStates=0,
246
247 secondHighFilter="residual",
248 secondHighFilterParameters={},
249 secondHighUseNStates=use_best_seeds,
250
251 thirdHighFilter="residual",
252 thirdHighFilterParameters={},
253 thirdHighUseNStates=use_best_seeds,
254
255 filter="weight",
256 filterParameters={},
257 useBestNInSeed=use_best_results,
258 )
259
260 path.add_module("CDCToSVDSpacePointCKF",
261 inputRecoTrackStoreArrayName=cdc_reco_tracks,
262 outputRecoTrackStoreArrayName=svd_reco_tracks,
263 outputRelationRecoTrackStoreArrayName=cdc_reco_tracks,
264 relatedRecoTrackStoreArrayName=svd_reco_tracks,
265
266 advanceHighFilterParameters={"direction": direction},
267 reverseSeed=reverse_seed,
268
269 writeOutDirection=direction,
270 relationCheckForDirection=direction,
271
272 seedHitJumping=3,
273 hitHitJumping=1,
274 **module_parameters).set_name(f"CDCToSVDSpacePointCKF_{direction}")
275
276
277def add_cosmics_pxd_ckf(
278 path,
279 svd_cdc_reco_tracks,
280 pxd_reco_tracks,
281 use_mc_truth=False,
282 use_best_results=5,
283 use_best_seeds=10,
284 direction="backward"):
285 """
286 Convenience function to add the PXD ckf to the path with cosmics settings valid for phase2 and 3.
287 :param path: The path to add the module to
288 :param svd_cdc_reco_tracks: The name of the already created CDC reco tracks
289 :param pxd_reco_tracks: The name to output the SVD reco tracks to
290 :param use_mc_truth: Use the MC information in the CKF
291 :param use_best_results: CKF parameter for useNResults
292 :param use_best_seeds: CKF parameter for useBestNInSeed
293 :param direction: where to extrapolate to. Valid options are forward and backward
294 """
295 if "PXDSpacePointCreator" not in [m.name() for m in path.modules()]:
296 path.add_module("PXDSpacePointCreator")
297
298 path.add_module("DAFRecoFitter", recoTracksStoreArrayName=svd_cdc_reco_tracks)
299
300 if direction == "forward":
301 reverse_seed = True
302 else:
303 reverse_seed = False
304
305 if use_mc_truth:
306 path.add_module("MCRecoTracksMatcher", UsePXDHits=False, UseSVDHits=True, UseCDCHits=True,
307 mcRecoTracksStoreArrayName="MCRecoTracks",
308 prRecoTracksStoreArrayName=svd_cdc_reco_tracks)
309
310 module_parameters = dict(
311 firstHighFilter="truth",
312 secondHighFilter="all",
313 thirdHighFilter="all",
314
315 filter="truth",
316 useBestNInSeed=1
317 )
318 else:
319 module_parameters = dict(
320 hitFilter="all",
321 seedFilter="all",
322 preHitFilter="all",
323 preSeedFilter="all",
324 firstHighFilterParameters={
325 'DBPayloadName': 'ckf_ToPXDStateFilter_1Parameters',
326 "direction": direction},
327 firstHighUseNStates=use_best_seeds,
328 secondHighFilterParameters={
329 'DBPayloadName': 'ckf_ToPXDStateFilter_2Parameters'},
330 secondHighUseNStates=use_best_seeds,
331 thirdHighFilterParameters={
332 'DBPayloadName': 'ckf_ToPXDStateFilter_3Parameters'},
333 thirdHighUseNStates=use_best_seeds,
334 filterParameters={
335 'DBPayloadName': 'ckf_PXDTrackCombinationParameters'},
336 useBestNInSeed=use_best_results,
337 seedHitJumping=1,
338 hitHitJumping=0,
339 )
340
341 path.add_module("ToPXDCKF",
342 advanceHighFilterParameters={"direction": direction},
343
344 writeOutDirection=direction,
345
346 inputRecoTrackStoreArrayName=svd_cdc_reco_tracks,
347 relatedRecoTrackStoreArrayName=pxd_reco_tracks,
348 relationCheckForDirection=direction,
349
350 outputRecoTrackStoreArrayName=pxd_reco_tracks,
351 outputRelationRecoTrackStoreArrayName=svd_cdc_reco_tracks,
352
353 reverseSeed=reverse_seed,
354 reverseSeedState=reverse_seed,
355 **module_parameters).set_name(f"ToPXDCKF_{direction}")