12from basf2
import B2ERROR
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
147 "K_S0:legacyGoodKS",
"K_S0:mdst",
"0.3 < M < 0.7", writeOut=
True, path=path
151 "K_S0:legacyGoodKS -> pi+ pi-",
"0.3 < M < 0.7", writeOut=
True, path=path
153 vertex.kFit(
"K_S0:legacyGoodKS", conf_level=0.0, path=path)
155 "K_S0:legacyGoodKS",
"0.468 < M < 0.528 and goodBelleKshort==1", path=path
159def scaleErrorKshorts(
162 scaleFactors_V0=[1.125927, 1.058803, 1.205928, 1.066734, 1.047513],
163 scaleFactorsNoPXD_V0=[1.125927, 1.058803, 1.205928, 1.066734, 1.047513],
164 d0Resolution_V0=[0.001174, 0.000779],
165 z0Resolution_V0=[0.001350, 0.000583],
166 d0MomThr_V0=0.500000,
168 scaleFactors_RD=[1.149631, 1.085547, 1.151704, 1.096434, 1.086659],
169 scaleFactorsNoPXD_RD=[1.149631, 1.085547, 1.151704, 1.096434, 1.086659],
170 d0Resolution_RD=[0.00115328, 0.00134704],
171 z0Resolution_RD=[0.00124327, 0.0013272],
172 d0MomThr_RD=0.500000,
173 z0MomThr_RD=0.500000,
178 Reconstruct K_S0 applying helix error correction to K_S0 daughters given by ``modularAnalysis.scaleError``.
179 The ParticleList is named ``K_S0:scaled`` by default. If ``addSuffix`` is set to True,
180 then a suffix of form ``_<fitter>`` is added.
182 Considering the difference of multiple scattering through the beam pipe,
183 different parameter sets are used for K_S0 decaying outside/inside the beam pipe (``K_S0:V0/RD``).
185 Only for TDCPV analysis.
187 @param prioritiseV0 If True K_S0 from V0 object is prioritised over RD when merged.
188 @param fitter Vertex fitter option. Choose from ``TreeFit``, ``KFit`` and ``Rave``.
189 @param scaleFactors_V0 List of five constants to be multiplied to each of helix errors (for tracks with a PXD hit)
190 @param scaleFactorsNoPXD_V0 List of five constants to be multiplied to each of helix errors (for tracks without a PXD hit)
191 @param d0Resolution_V0 List of two parameters, (a [cm], b [cm/(GeV/c)]),
192 defining d0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**1.5))**2 }
193 @param z0Resolution_V0 List of two parameters, (a [cm], b [cm/(GeV/c)]),
194 defining z0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**2.5))**2 }
195 @param d0MomThr_V0 d0 best resolution is kept constant below this momentum
196 @param z0MomThr_V0 z0 best resolution is kept constant below this momentum
197 @param scaleFactors_RD List of five constants to be multiplied to each of helix errors (for tracks with a PXD hit)
198 @param scaleFactorsNoPXD_RD List of five constants to be multiplied to each of helix errors (for tracks without a PXD hit)
199 @param d0Resolution_RD List of two parameters, (a [cm], b [cm/(GeV/c)]),
200 defining d0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**1.5))**2 }
201 @param z0Resolution_RD List of two parameters, (a [cm], b [cm/(GeV/c)]),
202 defining z0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**2.5))**2 }
203 @param d0MomThr_RD d0 best resolution is kept constant below this momentum
204 @param z0MomThr_RD z0 best resolution is kept constant below this momentum
205 @param addSuffix Whether to add a suffix of form ``_<fitter>`` to the ParticleList name
206 depending on the chosen fitter
209 from basf2
import register_module
213 suffix = f
"_{fitter}"
216 ma.fillParticleList(f
"K_S0:V0{suffix} -> pi+ pi-",
"",
True, path=path)
217 scaler_V0 = register_module(
"HelixErrorScaler")
218 scaler_V0.set_name(
"ScaleError_" + f
"K_S0:V0{suffix}")
219 scaler_V0.param(
"inputListName", f
"K_S0:V0{suffix}")
220 scaler_V0.param(
"outputListName", f
"K_S0:V0_scaled{suffix}")
221 scaler_V0.param(
"scaleFactors_PXD", scaleFactors_V0)
222 scaler_V0.param(
"scaleFactors_noPXD", scaleFactorsNoPXD_V0)
223 scaler_V0.param(
"d0ResolutionParameters", d0Resolution_V0)
224 scaler_V0.param(
"z0ResolutionParameters", z0Resolution_V0)
225 scaler_V0.param(
"d0MomentumThreshold", d0MomThr_V0)
226 scaler_V0.param(
"z0MomentumThreshold", z0MomThr_V0)
227 path.add_module(scaler_V0)
230 if fitter ==
"TreeFit":
231 vertex.treeFit(f
"K_S0:V0_scaled{suffix}", conf_level=0.0, path=path)
232 elif fitter ==
"KFit":
233 vertex.kFit(f
"K_S0:V0_scaled{suffix}", conf_level=0.0, path=path)
234 elif fitter ==
"Rave":
236 f
"K_S0:V0_scaled{suffix}", conf_level=0.0, path=path, silence_warning=
True
240 "Valid fitter options for Kshorts are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended."
242 ma.applyCuts(f
"K_S0:V0_scaled{suffix}",
"0.450 < M < 0.550", path=path)
245 stdPi(
"all", path=path)
249 scaleFactors=scaleFactors_RD,
250 scaleFactorsNoPXD=scaleFactorsNoPXD_RD,
251 d0Resolution=d0Resolution_RD,
252 z0Resolution=z0Resolution_RD,
253 d0MomThr=d0MomThr_RD,
254 z0MomThr=z0MomThr_RD,
259 f
"K_S0:RD_scaled{suffix} -> pi+:scaled pi-:scaled",
"0.3 < M < 0.7", 1,
True, path=path
262 if fitter ==
"TreeFit":
263 vertex.treeFit(f
"K_S0:RD_scaled{suffix}", conf_level=0.0, path=path)
264 elif fitter ==
"KFit":
265 vertex.kFit(f
"K_S0:RD_scaled{suffix}", conf_level=0.0, path=path)
266 elif fitter ==
"Rave":
268 f
"K_S0:RD_scaled{suffix}", conf_level=0.0, path=path, silence_warning=
True
270 ma.applyCuts(f
"K_S0:RD_scaled{suffix}",
"0.450 < M < 0.550", path=path)
272 ma.mergeListsWithBestDuplicate(
273 f
"K_S0:scaled{suffix}",
274 [f
"K_S0:V0_scaled{suffix}", f
"K_S0:RD_scaled{suffix}"],
275 variable=
"particleSource",
276 preferLowest=prioritiseV0,
285 updateAllDaughters=False,
290 Load a combined list of the Lambda list from V0 objects merged with
291 a list of particles combined using the analysis ParticleCombiner module.
293 The ParticleList is named ``Lambda0:merged`` by default. If ``addSuffix`` is set to True,
294 then a suffix of form ``_<fitter>`` is added depending on the chosen fitter.
295 A vertex fit is performed and only candidates with an invariant mass in the
296 range :math:`1.10 < M < 1.13~GeV` after the vertex fit,
297 and for which the vertex fit did not fail, are kept.
299 The vertex fitter can be selected among ``TreeFit``, ``KFit``, and ``Rave``.
302 prioritiseV0 (bool): should the V0 mdst objects be prioritised when merging?
303 fitter (str): vertex fitter name, valid options are ``TreeFit``, ``KFit``, and ``Rave``.
304 path (basf2.Path): the path to load the modules
305 updateAllDaughters (bool): see the ``updateAllDaughters`` parameter of `vertex.treeFit`
306 or the ``daughtersUpdate`` parameter of `vertex.kFit` / `vertex.raveFit`.
308 .. warning:: The momenta of the daughters are updated only if ``updateAllDaughters`` is set
309 to ``True`` (i.e. **not** by default). Some variables, e.g. `daughterAngle`, will only
310 return meaningful results if the daughters momenta are updated.
312 This happens because variables like `daughterAngle` assume the direction of the
313 daughers momenta *at the Lambda vertex* to be provided, while non-updated daughters
314 will provide their momenta direction at the point-of-closest-approach (POCA) to the
317 writeOut (bool): whether RootOutput module should save the created ParticleList
318 addSuffix (bool): whether to add a suffix of form ``_<fitter>`` to the ParticleList name
319 depending on the chosen fitter
323 suffix = f
"_{fitter}"
326 f
"Lambda0:V0_ToFit{suffix} -> p+ pi-",
"", writeOut=writeOut, path=path
329 if fitter ==
"TreeFit":
331 f
"Lambda0:V0_ToFit{suffix}",
334 updateAllDaughters=updateAllDaughters,
336 elif fitter ==
"KFit":
338 f
"Lambda0:V0_ToFit{suffix}",
341 daughtersUpdate=updateAllDaughters,
343 elif fitter ==
"Rave":
345 f
"Lambda0:V0_ToFit{suffix}",
348 silence_warning=
True,
349 daughtersUpdate=updateAllDaughters,
353 "Valid fitter options for Lambdas are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended."
355 ma.applyCuts(f
"Lambda0:V0_ToFit{suffix}",
"1.10 < M < 1.13", path=path)
357 ma.markDuplicate(f
"Lambda0:V0_ToFit{suffix}",
False, path=path)
358 ma.applyCuts(f
"Lambda0:V0_ToFit{suffix}",
"extraInfo(highQualityVertex)", path=path)
360 stdPi(
"all", path=path, writeOut=writeOut)
361 stdPr(
"all", path=path, writeOut=writeOut)
363 f
"Lambda0:RD{suffix} -> p+:all pi-:all",
370 if fitter ==
"TreeFit":
372 f
"Lambda0:RD{suffix}",
375 updateAllDaughters=updateAllDaughters,
377 elif fitter ==
"KFit":
379 f
"Lambda0:RD{suffix}",
382 daughtersUpdate=updateAllDaughters,
384 elif fitter ==
"Rave":
386 f
"Lambda0:RD{suffix}",
389 silence_warning=
True,
390 daughtersUpdate=updateAllDaughters,
392 ma.applyCuts(f
"Lambda0:RD{suffix}",
"1.10 < M < 1.13", path=path)
394 ma.markDuplicate(f
"Lambda0:RD{suffix}",
False, path=path)
395 ma.applyCuts(f
"Lambda0:RD{suffix}",
"extraInfo(highQualityVertex)", path=path)
396 ma.mergeListsWithBestDuplicate(
397 f
"Lambda0:merged{suffix}",
398 [f
"Lambda0:V0_ToFit{suffix}", f
"Lambda0:RD{suffix}"],
399 variable=
"particleSource",
400 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)