12from basf2
import B2ERROR, B2WARNING
13import modularAnalysis
as ma
14from stdCharged
import stdPi, stdPr
22 updateAllDaughters=False,
27 Load a combined list of the Kshorts list from V0 objects merged with
28 a list of particles combined using the analysis ParticleCombiner module.
30 The ParticleList is named ``K_S0:merged`` by default. If ``addSuffix`` is set to True,
31 then a suffix of form ``_<fitter>`` is added depending on the chosen fitter.
32 A vertex fit is performed and only candidates with an invariant mass in the
33 range :math:`0.450 < M < 0.550~GeV` after the vertex fit,
34 and for which the vertex fit did not fail, are kept.
36 The vertex fitter can be selected among ``TreeFit``, ``KFit``, and ``Rave``.
39 prioritiseV0 (bool): should the V0 mdst objects be prioritised when merging?
40 fitter (str): vertex fitter name, valid options are ``TreeFit``, ``KFit``, and ``Rave``.
41 path (basf2.Path): the path to load the modules
42 updateAllDaughters (bool): see the ``updateAllDaughters`` parameter of `vertex.treeFit`
43 or the ``daughtersUpdate`` parameter of `vertex.kFit` / `vertex.raveFit`.
45 .. warning:: The momenta of the daughters are updated only if ``updateAllDaughters`` is set
46 to ``True`` (i.e. **not** by default). Some variables, e.g. `daughterAngle`, will only
47 return meaningful results if the daughters momenta are updated.
49 This happens because variables like `daughterAngle` assume the direction of the
50 daughers momenta *at the Ks vertex* to be provided, while non-updated daughters will
51 provide their momenta direction at the point-of-closest-approach (POCA) to the beam axis.
53 writeOut (bool): whether RootOutput module should save the created ParticleList
54 addSuffix (bool): whether to add a suffix of form ``_<fitter>`` to the ParticleList name
55 depending on the chosen fitter
62 f
"K_S0:V0_ToFit{suffix} -> pi+ pi-",
"", writeOut=writeOut, path=path
65 if fitter ==
"TreeFit":
67 f
"K_S0:V0_ToFit{suffix}",
70 updateAllDaughters=updateAllDaughters,
72 elif fitter ==
"KFit":
74 f
"K_S0:V0_ToFit{suffix}",
77 daughtersUpdate=updateAllDaughters,
79 elif fitter ==
"Rave":
81 f
"K_S0:V0_ToFit{suffix}",
85 daughtersUpdate=updateAllDaughters,
89 "Valid fitter options for Kshorts are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended."
91 ma.applyCuts(f
"K_S0:V0_ToFit{suffix}",
"0.450 < M < 0.550", path=path)
93 stdPi(
"all", path=path, writeOut=writeOut)
95 f
"K_S0:RD{suffix} -> pi+:all pi-:all",
102 if fitter ==
"TreeFit":
107 updateAllDaughters=updateAllDaughters,
109 elif fitter ==
"KFit":
114 daughtersUpdate=updateAllDaughters,
116 elif fitter ==
"Rave":
121 silence_warning=
True,
122 daughtersUpdate=updateAllDaughters,
124 ma.applyCuts(f
"K_S0:RD{suffix}",
"0.450 < M < 0.550", path=path)
126 ma.mergeListsWithBestDuplicate(
127 f
"K_S0:merged{suffix}",
128 [f
"K_S0:V0_ToFit{suffix}", f
"K_S0:RD{suffix}"],
129 variable=
"particleSource",
130 preferLowest=prioritiseV0,
135def goodBelleKshort(path):
137 Load the Belle goodKshort list. Creates a ParticleList named
138 ``K_S0:legacyGoodKS``. A vertex fit is performed and only candidates that
139 satisfy the :b2:var:`goodBelleKshort` criteria, with an invariant mass in the range
140 :math:`0.468 < M < 0.528~GeV` after the vertex fit, and for which the vertex fit did not fail, are kept.
143 path (basf2.Path): the path to load the modules
146 "The standard K_S0 list 'K_S0:legacyGoodKS' is deprecated "
147 "and will be removed at the end of 2026. "
148 "Please update your analysis accordingly."
152 "K_S0:legacyGoodKS",
"K_S0:mdst",
"0.3 < M < 0.7", writeOut=
True, path=path
156 "K_S0:legacyGoodKS -> pi+ pi-",
"0.3 < M < 0.7", writeOut=
True, path=path
158 vertex.kFit(
"K_S0:legacyGoodKS", conf_level=0.0, path=path)
160 "K_S0:legacyGoodKS",
"0.468 < M < 0.528 and goodBelleKshort==1", path=path
164def scaleErrorKshorts(
167 scaleFactors_V0=[1.125927, 1.058803, 1.205928, 1.066734, 1.047513],
168 scaleFactorsNoPXD_V0=[1.125927, 1.058803, 1.205928, 1.066734, 1.047513],
169 d0Resolution_V0=[0.001174, 0.000779],
170 z0Resolution_V0=[0.001350, 0.000583],
171 d0MomThr_V0=0.500000,
173 scaleFactors_RD=[1.149631, 1.085547, 1.151704, 1.096434, 1.086659],
174 scaleFactorsNoPXD_RD=[1.149631, 1.085547, 1.151704, 1.096434, 1.086659],
175 d0Resolution_RD=[0.00115328, 0.00134704],
176 z0Resolution_RD=[0.00124327, 0.0013272],
177 d0MomThr_RD=0.500000,
178 z0MomThr_RD=0.500000,
183 Reconstruct K_S0 applying helix error correction to K_S0 daughters given by ``modularAnalysis.scaleError``.
184 The ParticleList is named ``K_S0:scaled`` by default. If ``addSuffix`` is set to True,
185 then a suffix of form ``_<fitter>`` is added.
187 Considering the difference of multiple scattering through the beam pipe,
188 different parameter sets are used for K_S0 decaying outside/inside the beam pipe (``K_S0:V0/RD``).
190 Only for TDCPV analysis.
192 @param prioritiseV0 If True K_S0 from V0 object is prioritised over RD when merged.
193 @param fitter Vertex fitter option. Choose from ``TreeFit``, ``KFit`` and ``Rave``.
194 @param scaleFactors_V0 List of five constants to be multiplied to each of helix errors (for tracks with a PXD hit)
195 @param scaleFactorsNoPXD_V0 List of five constants to be multiplied to each of helix errors (for tracks without a PXD hit)
196 @param d0Resolution_V0 List of two parameters, (a [cm], b [cm/(GeV/c)]),
197 defining d0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**1.5))**2 }
198 @param z0Resolution_V0 List of two parameters, (a [cm], b [cm/(GeV/c)]),
199 defining z0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**2.5))**2 }
200 @param d0MomThr_V0 d0 best resolution is kept constant below this momentum
201 @param z0MomThr_V0 z0 best resolution is kept constant below this momentum
202 @param scaleFactors_RD List of five constants to be multiplied to each of helix errors (for tracks with a PXD hit)
203 @param scaleFactorsNoPXD_RD List of five constants to be multiplied to each of helix errors (for tracks without a PXD hit)
204 @param d0Resolution_RD List of two parameters, (a [cm], b [cm/(GeV/c)]),
205 defining d0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**1.5))**2 }
206 @param z0Resolution_RD List of two parameters, (a [cm], b [cm/(GeV/c)]),
207 defining z0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**2.5))**2 }
208 @param d0MomThr_RD d0 best resolution is kept constant below this momentum
209 @param z0MomThr_RD z0 best resolution is kept constant below this momentum
210 @param addSuffix Whether to add a suffix of form ``_<fitter>`` to the ParticleList name
211 depending on the chosen fitter
214 from basf2
import register_module
218 suffix = f
"_{fitter}"
221 ma.fillParticleList(f
"K_S0:V0{suffix} -> pi+ pi-",
"",
True, path=path)
222 scaler_V0 = register_module(
"HelixErrorScaler")
223 scaler_V0.set_name(
"ScaleError_" + f
"K_S0:V0{suffix}")
224 scaler_V0.param(
"inputListName", f
"K_S0:V0{suffix}")
225 scaler_V0.param(
"outputListName", f
"K_S0:V0_scaled{suffix}")
226 scaler_V0.param(
"scaleFactors_PXD", scaleFactors_V0)
227 scaler_V0.param(
"scaleFactors_noPXD", scaleFactorsNoPXD_V0)
228 scaler_V0.param(
"d0ResolutionParameters", d0Resolution_V0)
229 scaler_V0.param(
"z0ResolutionParameters", z0Resolution_V0)
230 scaler_V0.param(
"d0MomentumThreshold", d0MomThr_V0)
231 scaler_V0.param(
"z0MomentumThreshold", z0MomThr_V0)
232 path.add_module(scaler_V0)
235 if fitter ==
"TreeFit":
236 vertex.treeFit(f
"K_S0:V0_scaled{suffix}", conf_level=0.0, path=path)
237 elif fitter ==
"KFit":
238 vertex.kFit(f
"K_S0:V0_scaled{suffix}", conf_level=0.0, path=path)
239 elif fitter ==
"Rave":
241 f
"K_S0:V0_scaled{suffix}", conf_level=0.0, path=path, silence_warning=
True
245 "Valid fitter options for Kshorts are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended."
247 ma.applyCuts(f
"K_S0:V0_scaled{suffix}",
"0.450 < M < 0.550", path=path)
250 stdPi(
"all", path=path)
254 scaleFactors=scaleFactors_RD,
255 scaleFactorsNoPXD=scaleFactorsNoPXD_RD,
256 d0Resolution=d0Resolution_RD,
257 z0Resolution=z0Resolution_RD,
258 d0MomThr=d0MomThr_RD,
259 z0MomThr=z0MomThr_RD,
264 f
"K_S0:RD_scaled{suffix} -> pi+:scaled pi-:scaled",
"0.3 < M < 0.7", 1,
True, path=path
267 if fitter ==
"TreeFit":
268 vertex.treeFit(f
"K_S0:RD_scaled{suffix}", conf_level=0.0, path=path)
269 elif fitter ==
"KFit":
270 vertex.kFit(f
"K_S0:RD_scaled{suffix}", conf_level=0.0, path=path)
271 elif fitter ==
"Rave":
273 f
"K_S0:RD_scaled{suffix}", conf_level=0.0, path=path, silence_warning=
True
275 ma.applyCuts(f
"K_S0:RD_scaled{suffix}",
"0.450 < M < 0.550", path=path)
277 ma.mergeListsWithBestDuplicate(
278 f
"K_S0:scaled{suffix}",
279 [f
"K_S0:V0_scaled{suffix}", f
"K_S0:RD_scaled{suffix}"],
280 variable=
"particleSource",
281 preferLowest=prioritiseV0,
290 updateAllDaughters=False,
295 Load a combined list of the Lambda list from V0 objects merged with
296 a list of particles combined using the analysis ParticleCombiner module.
298 The ParticleList is named ``Lambda0:merged`` by default. If ``addSuffix`` is set to True,
299 then a suffix of form ``_<fitter>`` is added depending on the chosen fitter.
300 A vertex fit is performed and only candidates with an invariant mass in the
301 range :math:`1.10 < M < 1.13~GeV` after the vertex fit,
302 and for which the vertex fit did not fail, are kept.
304 The vertex fitter can be selected among ``TreeFit``, ``KFit``, and ``Rave``.
307 prioritiseV0 (bool): should the V0 mdst objects be prioritised when merging?
308 fitter (str): vertex fitter name, valid options are ``TreeFit``, ``KFit``, and ``Rave``.
309 path (basf2.Path): the path to load the modules
310 updateAllDaughters (bool): see the ``updateAllDaughters`` parameter of `vertex.treeFit`
311 or the ``daughtersUpdate`` parameter of `vertex.kFit` / `vertex.raveFit`.
313 .. warning:: The momenta of the daughters are updated only if ``updateAllDaughters`` is set
314 to ``True`` (i.e. **not** by default). Some variables, e.g. `daughterAngle`, will only
315 return meaningful results if the daughters momenta are updated.
317 This happens because variables like `daughterAngle` assume the direction of the
318 daughers momenta *at the Lambda vertex* to be provided, while non-updated daughters
319 will provide their momenta direction at the point-of-closest-approach (POCA) to the
322 writeOut (bool): whether RootOutput module should save the created ParticleList
323 addSuffix (bool): whether to add a suffix of form ``_<fitter>`` to the ParticleList name
324 depending on the chosen fitter
328 suffix = f
"_{fitter}"
329 if f
"PListMerger_Lambda0:merged{suffix}" in [m.name()
for m
in path.modules()]:
333 f
"Lambda0:V0_ToFit{suffix} -> p+ pi-",
"", writeOut=writeOut, path=path
336 if fitter ==
"TreeFit":
338 f
"Lambda0:V0_ToFit{suffix}",
341 updateAllDaughters=updateAllDaughters,
343 elif fitter ==
"KFit":
345 f
"Lambda0:V0_ToFit{suffix}",
348 daughtersUpdate=updateAllDaughters,
350 elif fitter ==
"Rave":
352 f
"Lambda0:V0_ToFit{suffix}",
355 silence_warning=
True,
356 daughtersUpdate=updateAllDaughters,
360 "Valid fitter options for Lambdas are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended."
362 ma.applyCuts(f
"Lambda0:V0_ToFit{suffix}",
"1.10 < M < 1.13", path=path)
364 ma.markDuplicate(f
"Lambda0:V0_ToFit{suffix}",
False, path=path)
365 ma.applyCuts(f
"Lambda0:V0_ToFit{suffix}",
"extraInfo(highQualityVertex)", path=path)
367 stdPi(
"all", path=path, writeOut=writeOut)
368 stdPr(
"all", path=path, writeOut=writeOut)
370 f
"Lambda0:RD{suffix} -> p+:all pi-:all",
377 if fitter ==
"TreeFit":
379 f
"Lambda0:RD{suffix}",
382 updateAllDaughters=updateAllDaughters,
384 elif fitter ==
"KFit":
386 f
"Lambda0:RD{suffix}",
389 daughtersUpdate=updateAllDaughters,
391 elif fitter ==
"Rave":
393 f
"Lambda0:RD{suffix}",
396 silence_warning=
True,
397 daughtersUpdate=updateAllDaughters,
399 ma.applyCuts(f
"Lambda0:RD{suffix}",
"1.10 < M < 1.13", path=path)
401 ma.markDuplicate(f
"Lambda0:RD{suffix}",
False, path=path)
402 ma.applyCuts(f
"Lambda0:RD{suffix}",
"extraInfo(highQualityVertex)", path=path)
403 ma.mergeListsWithBestDuplicate(
404 f
"Lambda0:merged{suffix}",
405 [f
"Lambda0:V0_ToFit{suffix}", f
"Lambda0:RD{suffix}"],
406 variable=
"particleSource",
407 preferLowest=prioritiseV0,
treeFit(list_name, conf_level=0.001, massConstraint=[], ipConstraint=False, updateAllDaughters=False, massConstraintDecayString='', massConstraintMassValues=[], customOriginConstraint=False, customOriginVertex=[0.001, 0, 0.0116], customOriginCovariance=[0.0048, 0, 0, 0, 0.003567, 0, 0, 0, 0.0400], originDimension=3, treatAsInvisible='', ignoreFromVertexFit='', path=None)
raveFit(list_name, conf_level, fit_type='vertex', decay_string='', constraint='', daughtersUpdate=False, path=None, silence_warning=False)
kFit(list_name, conf_level, fit_type='vertex', constraint='', daughtersUpdate=False, decay_string='', massConstraint=[], recoilMass=0, smearing=0, path=None)