11from basf2
import B2ERROR, B2WARNING
12from b2bii
import isB2BII
13from modularAnalysis
import cutAndCopyList, reconstructDecay, applyCuts
14from vertex
import treeFit, kFit
16from stdCharged
import stdPi, stdK
17from stdV0s
import stdLambdas
18from stdPhotons
import stdPhotons
21def stdXi(fitter="TreeFit", addSuffix=False, path=None):
23 Reconstruct the standard :math:`\Xi^-` ``ParticleList`` named ``Xi-:std`` by default.
24 If ``addSuffix`` is set to True, then a suffix of form ``_<fitter>`` is added
25 depending on the chosen fitter.
27 .. seealso:: `BELLE2-NOTE-PH-2019-011 <https://docs.belle2.org/record/BELLE2-NOTE-PH-2019-011.pdf>`_.
30 fitter (str): specify either ``KFit`` or ``TreeFit`` for the vertex reconstructions (default ``TreeFit``)
31 addSuffix (bool): whether to add a suffix of form ``_<fitter>`` to the ParticleList name
32 depending on the chosen fitter
33 path (basf2.Path): modules are added to this path building the ``Xi-:std`` list
37 "stdXi is deprecated and will be removed at the end of 2026. "
38 "Please replace it with a custom hyperon reconstruction and selection optimised for "
39 "your specific analysis. To provide feedback on the removal, see "
40 "https://gitlab.desy.de/belle2/software/basf2/-/work_items/11641"
47 stdLambdas(path=path, addSuffix=addSuffix)
50 f
"Lambda0:reco{suffix}",
51 f
"Lambda0:merged{suffix}",
52 "[ abs( dM ) < 0.0035 ] and \
53 [ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
54 [ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.35 ] and \
55 [ daughter(0,protonID) > 0.01 ] and \
61 stdPi(
'all', path=path)
63 kFit(
'Lambda0:mdst', conf_level=0.0, path=path)
65 f
"Lambda0:reco{suffix}",
67 "[ abs( dM ) < 0.0035 ] and \
68 [ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
70 [ daughter(0,atcPIDBelle(4,3)) > 0.2 ] and \
71 [ daughter(0,atcPIDBelle(4,2)) > 0.2 ] and \
79 kFit(f
"Lambda0:reco{suffix}", 0.0, fit_type=
"massvertex", path=path)
81 f
"Xi-:reco{suffix} -> Lambda0:reco{suffix} pi-:all",
85 kFit(f
"Xi-:reco{suffix}", conf_level=0.0, path=path)
86 elif fitter ==
"TreeFit":
88 f
"Xi-:reco{suffix} -> Lambda0:reco{suffix} pi-:all",
92 treeFit(f
"Xi-:reco{suffix}", conf_level=0.0, massConstraint=[3122], path=path)
94 B2ERROR(f
"stdXi: invalid fitter ({fitter}). Choose from KFit or TreeFit")
99 "[ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
100 [ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0. and \
101 formula([dr^2 + dz^2 ]^[0.5])<formula([daughter(0,dr)^2 + daughter(0,dz)^2]^[0.5])] and \
108def stdXi0(gammatype='eff40', beamBackgroundMVAWeight="", fakePhotonMVAWeight="", biasCorrectionTable="", path=None):
110 Reconstruct the standard :math:`\Xi^0` ``ParticleList`` named ``Xi0:std``.
112 .. seealso:: `BELLE2-NOTE-PH-2019-011 <https://docs.belle2.org/record/BELLE2-NOTE-PH-2019-011.pdf>`_.
115 gammatype (str): specify either ``eff60``, ``eff50``, ``eff40``, ``eff30``, or ``eff20``
116 to select the signal efficiency of the photons used in the pi0 reconstruction
119 beamBackgroundMVAWeight (str): type of weight file for beam background MVA; if empty, beam background MVA will not be used
123 `Performance Recommendations <https://belle2.pages.desy.de/performance/recommendations/>`_
124 for information on the beam background MVA.
126 fakePhotonMVAWeight (str): type of weight file for fake photon MVA; if empty, fake photon MVA will not be used
130 `Performance Recommendations <https://belle2.pages.desy.de/performance/recommendations/>`_
131 for information on the fake photon MVA.
133 biasCorrectionTable (str): correction table for the photon energy bias correction (should only be applied to data)
137 `Performance Recommendations <https://belle2.pages.desy.de/performance/recommendations/>`_
138 for information on the names of available correction tables.
140 path (basf2.Path): modules are added to this path building the ``Xi0:std`` list
144 "stdXi0 is deprecated and will be removed at the end of 2026. "
145 "Please replace it with a custom hyperon reconstruction and selection optimised for "
146 "your specific analysis. To provide feedback on the removal, see "
147 "https://gitlab.desy.de/belle2/software/basf2/-/work_items/11641"
151 stdLambdas(path=path)
156 '[ abs( dM ) < 0.0035 ] and \
157 [ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
158 [ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.35 ] and \
159 [ daughter(0,protonID) > 0.01 ] and \
164 f
'pi0{gammatype}_May2020',
166 beamBackgroundMVAWeight=beamBackgroundMVAWeight,
167 fakePhotonMVAWeight=fakePhotonMVAWeight,
168 biasCorrectionTable=biasCorrectionTable)
169 reconstructDecay(f
'pi0:reco -> gamma:pi0{gammatype}_May2020 gamma:pi0{gammatype}_May2020',
170 'abs( dM ) < 0.0406',
178 '[ abs( dM ) < 0.0189 ] and \
179 [ [ daughter(0,clusterReg) == 1 and daughter(0,E) > 0.05 ] or [ daughter(0,clusterReg) == 3 and daughter(0,E) > 0.05 ] or \
180 [ daughter(0,clusterReg) == 2 and daughter(0,E) > 0.03 ] ] and \
181 [ [ daughter(1,clusterReg) == 1 and daughter(1,E) > 0.05 ] or [ daughter(1,clusterReg) == 3 and daughter(1,E) > 0.05 ] or \
182 [ daughter(1,clusterReg) == 2 and daughter(1,E) > 0.03 ] ]',
184 kFit(
'Lambda0:mdst', conf_level=0.0, path=path)
188 '[ abs( dM ) < 0.0035 ] and \
189 [ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
191 [ daughter(0,atcPIDBelle(4,3)) > 0.2 ] and \
192 [ daughter(0,atcPIDBelle(4,2)) > 0.2 ] and \
197 'Xi0:prelim -> Lambda0:reco pi0:reco',
200 treeFit(
'Xi0:prelim', conf_level=0.0, massConstraint=[3122], ipConstraint=
True, updateAllDaughters=
True, path=path)
203 applyCuts(
'Xi0:prelim',
'[ abs( daughter(1,dM) ) < 0.0232 ]', path=path)
204 treeFit(
'Xi0:prelim', conf_level=0.0, massConstraint=[111, 3122], ipConstraint=
True, updateAllDaughters=
False, path=path)
209 '[ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
210 [ daughter(0,cosAngleBetweenMomentumAndVertexVectorInXYPlane) < cosAngleBetweenMomentumAndVertexVectorInXYPlane ] and \
211 [ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.0 and \
212 formula([dr^2 + dz^2]^[0.5])<formula([daughter(0,dr)^2 + daughter(0,dz)^2]^[0.5])] and \
218def stdOmega(fitter="TreeFit", addSuffix=False, path=None):
220 Reconstruct the standard :math:`\Omega^-` ``ParticleList`` named ``Omega-:std``.
221 If ``addSuffix`` is set to True, then a suffix of form ``_<fitter>`` is added
222 depending on the chosen fitter.
224 .. seealso:: `BELLE2-NOTE-PH-2019-011 <https://docs.belle2.org/record/BELLE2-NOTE-PH-2019-011.pdf>`_.
227 fitter (str): specify either ``KFit`` or ``TreeFit`` for the vertex reconstructions (default ``TreeFit``)
228 addSuffix (bool): whether to add a suffix of form ``_<fitter>`` to the ParticleList name
229 depending on the chosen fitter
230 path (basf2.Path): modules are added to this path building the ``Omega-:std`` list
234 "stdOmega is deprecated and will be removed at the end of 2026. "
235 "Please replace it with a custom hyperon reconstruction and selection optimised for "
236 "your specific analysis. To provide feedback on the removal, see "
237 "https://gitlab.desy.de/belle2/software/basf2/-/work_items/11641"
242 suffix = f
"_{fitter}"
244 stdLambdas(path=path, addSuffix=addSuffix)
247 f
"Lambda0:reco{suffix}",
248 f
"Lambda0:merged{suffix}",
249 "[ abs( dM ) < 0.0035 ] and \
250 [ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
251 [ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.35 ] and \
252 [ daughter(0,protonID) > 0.01 ] and \
258 stdPi(
'all', path=path)
260 kFit(
'Lambda0:mdst', conf_level=0.0, path=path)
262 f
"Lambda0:reco{suffix}",
264 "[ abs( dM ) < 0.0035 ] and \
265 [ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
267 [ daughter(0,atcPIDBelle(4,3)) > 0.2 ] and \
268 [ daughter(0,atcPIDBelle(4,2)) > 0.2 ] and \
274 stdK(
'all', path=path)
277 kFit(f
"Lambda0:reco{suffix}", 0.0, fit_type=
"massvertex", path=path)
279 f
"Omega-:reco{suffix} -> Lambda0:reco{suffix} K-:all",
"1.622 < M < 1.722", path=path
281 kFit(f
"Omega-:reco{suffix}", conf_level=0.0, path=path)
282 elif fitter ==
"TreeFit":
284 f
"Omega-:reco{suffix} -> Lambda0:reco{suffix} K-:all",
"1.622 < M < 1.722", path=path
286 treeFit(f
"Omega-:reco{suffix}", conf_level=0.0, massConstraint=[3122], path=path)
288 B2ERROR(f
"stdOmega: invalid fitter ({fitter}). Choose from KFit or TreeFit")
292 f
"Omega-:std{suffix}",
293 f
"Omega-:reco{suffix}",
294 "[ cosAngleBetweenMomentumAndVertexVector > 0.0] and \
295 [ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0. and \
296 formula([dr^2 + dz^2]^[0.5])<formula([daughter(0,dr)^2 + daughter(0,dz)^2]^[0.5])] and \
297 [ chiProb > 0.0 ] and \
298 [ daughter(1,kaonID) > 0.01 ]",
305 f
"Omega-:std{suffix}",
306 f
"Omega-:reco{suffix}",
307 "[ cosAngleBetweenMomentumAndVertexVector > 0.0 ] and \
308 [ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0. and \
309 formula([dr^2 + dz^2]^[0.5])<formula([daughter(0,dr)^2 + daughter(0,dz)^2 ]^[0.5])] and \
310 [ chiProb > 0.0 ] and \
311 [ daughter(1,atcPIDBelle(3,4)) > 0.2 and daughter(1,atcPIDBelle(3,2)) > 0.2 ]",
317def goodXi(xitype='loose', path=None):
319 Select the standard good :math:`\Xi^-` ``ParticleList`` named ``Xi-:veryloose``, ``Xi-:loose``, or ``Xi-:tight``
320 from the reconstructed ``Xi-:std``.
322 .. seealso:: `BELLE2-NOTE-PH-2019-011 <https://docs.belle2.org/record/BELLE2-NOTE-PH-2019-011.pdf>`_.
325 xitype (str): specify either ``veryloose``, ``loose``, or ``tight`` for good ``ParticleList`` selection (default ``loose``)
326 path (basf2.Path): modules are added to this path building the ``Xi-:veryloose``, ``Xi-:loose``, or ``Xi-:tight``, list
330 "goodXi is deprecated and will be removed at the end of 2026. "
331 "Please replace it with a custom hyperon reconstruction and selection optimised for "
332 "your specific analysis. To provide feedback on the removal, see "
333 "https://gitlab.desy.de/belle2/software/basf2/-/work_items/11641"
336 if not _std_hyperon_is_in_path(
"Xi-", path):
337 B2WARNING(
"Could not find standard Xi particle list! Creating it with default options.")
339 assert _std_hyperon_is_in_path(
"Xi-", path)
341 if xitype ==
'veryloose':
345 '[ daughter(1,pt) > 0.05 and \
346 formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.1 ]',
350 elif xitype ==
'loose':
354 '[ daughter(1,pt) > 0.05 and \
355 formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.1 and \
356 formula([daughter(0,cosAngleBetweenMomentumAndVertexVectorInXYPlane)/cosAngleBetweenMomentumAndVertexVectorInXYPlane])\
361 elif xitype ==
'tight':
365 '[ daughter(1,pt) > 0.1 and \
366 formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.15 and \
367 formula([daughter(0,cosAngleBetweenMomentumAndVertexVectorInXYPlane)/cosAngleBetweenMomentumAndVertexVectorInXYPlane])\
372 raise ValueError(f
"\"{xitype}\" is none of the allowed Xi- list types!")
375def goodXi0(xitype='loose', path=None):
377 Select the standard good :math:`\Xi^0` ``ParticleList`` named ``Xi0:veryloose``, ``Xi0:loose``, or ``Xi0:tight``
378 from the reconstructed ``Xi0:std``.
380 .. seealso:: `BELLE2-NOTE-PH-2019-011 <https://docs.belle2.org/record/BELLE2-NOTE-PH-2019-011.pdf>`_.
383 xitype (str): specify either ``veryloose``, ``loose``, or ``tight`` for good ``ParticleList`` selection (default ``loose``)
384 path (basf2.Path): modules are added to this path building the ``Xi0:veryloose``, ``Xi0:loose``, or ``Xi0:tight``, list
388 "goodXi0 is deprecated and will be removed at the end of 2026. "
389 "Please replace it with a custom hyperon reconstruction and selection optimised for "
390 "your specific analysis. To provide feedback on the removal, see "
391 "https://gitlab.desy.de/belle2/software/basf2/-/work_items/11641"
394 if not _std_hyperon_is_in_path(
"Xi0", path):
395 B2WARNING(
"Could not find standard Xi0 particle list! Creating it with default options.")
397 assert _std_hyperon_is_in_path(
"Xi0", path)
399 if xitype ==
'veryloose':
404 '[ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.25 and \
405 daughter(1,p) > 0.1 and \
406 abs( daughter(1,dM) ) < 0.0174 ]',
410 elif xitype ==
'loose':
415 '[ formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.5 and \
416 daughter(1,p) > 0.15 and \
417 abs( daughter(1,dM) ) < 0.0174 ]',
421 elif xitype ==
'tight':
426 '[ formula( [ dr^2 + dz^2 ]^[0.5] ) > 1.4 and \
427 daughter(1,p) > 0.25 and \
428 abs( daughter(1,dM) ) < 0.0116 ]',
432 raise ValueError(f
"\"{xitype}\" is none of the allowed Xi0 list types!")
435def goodOmega(omegatype='loose', path=None):
437 Select the standard good :math:`\Omega^-` ``ParticleList`` named ``Omega-:veryloose``, ``Omega-:loose``,
438 or ``Omega-:tight`` from the reconstructed ``Omega-:std``.
440 .. seealso:: `BELLE2-NOTE-PH-2019-011 <https://docs.belle2.org/record/BELLE2-NOTE-PH-2019-011.pdf>`_.
443 omegatype (str): specify either ``veryloose``, ``loose``, or ``tight`` for good ``ParticleList`` selection
444 (default ``veryloose``)
445 path (basf2.Path): modules are added to this path building the ``Omega-:veryloose``, ``Omega-:loose``,
446 or ``Omega-:tight``, list
450 "goodOmega is deprecated and will be removed at the end of 2026. "
451 "Please replace it with a custom hyperon reconstruction and selection optimised for "
452 "your specific analysis. To provide feedback on the removal, see "
453 "https://gitlab.desy.de/belle2/software/basf2/-/work_items/11641"
456 if not _std_hyperon_is_in_path(
"Omega-", path):
457 B2WARNING(
"Could not find standard Omega particle list! Creating it with default options.")
459 assert _std_hyperon_is_in_path(
"Omega-", path)
461 if omegatype ==
'veryloose':
465 '[ daughter(1,pt) > 0.15 and \
466 formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.05 ]',
470 elif omegatype ==
'loose':
474 '[ daughter(1,pt) > 0.15 and \
475 formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.15 and \
476 formula([daughter(0,cosAngleBetweenMomentumAndVertexVectorInXYPlane)/cosAngleBetweenMomentumAndVertexVectorInXYPlane])\
481 elif omegatype ==
'tight':
485 '[ daughter(1,pt) > 0.3 and \
486 formula( [ dr^2 + dz^2 ]^[0.5] ) > 0.15 and \
487 formula([daughter(0,cosAngleBetweenMomentumAndVertexVectorInXYPlane)/cosAngleBetweenMomentumAndVertexVectorInXYPlane])\
492 raise ValueError(f
"\"{omegatype}\" is none of the allowed Omega list types!")
495def _std_hyperon_is_in_path(hyperon, path):
497 Helper function to check if the std hyperon is already in the reconstruction path.
499 Checks whether there is a ``PListCutAndCopy`` module with the
500 ``outputListName``: ``<hyperon>:std``.
501 :param hyperon: One of ["Xi-", "Xi0", "Omega-"]
502 :param path: Instance of basf2.Path
503 :returns: Boolean, whether ``PListCutAndCopy`` with ``outputListName`` ``<hyperon>:std`` was found in path.
507 allowed_hyperons = {
"Xi-",
"Xi0",
"Omega-"}
508 if hyperon
not in allowed_hyperons:
510 f
"\"{hyperon}\" is not in list of hyperons that this function has been tested for ({allowed_hyperons})."
512 for module
in path.modules():
513 if (module.name() == f
"PListCutAndCopy_{hyperon}:std" or
514 module.name().split(
" -> ")[0] == f
"ParticleCombiner_{hyperon}:std"):