11 from basf2
import register_module
12 from basf2
import B2WARNING
23 daughtersUpdate=False,
28 Perform the specified fit for each Particle in the given ParticleList.
31 Direct use of `fitVertex` is not recommended unless you know what you are doing.
32 If you're unsure, you probably want to use `treeFit` or `kFit`.
35 list_name (str): name of the input ParticleList
36 conf_level (float): minimum value of the confidence level to accept the fit.
37 Setting this parameter to -1 selects all particle candidates.
38 The value of 0 rejects the particle candidates with failed fit.
39 decay_string (str): select particles used for the vertex fit
40 fitter (str): Rave or KFit
41 fit_type (str): type of the kinematic fit (valid options are vertex/massvertex/mass/fourC/massfourC)
42 constraint (str): add additional constraint to the fit (valid options are empty string/ipprofile/iptube/mother)
43 massConstraint (list(int) or list(str)): list of PDG ids or Names of the particles which are mass-constrained
44 Please do not mix PDG id and particle names in massConstraint list (valid only for massfourC).
45 daughtersUpdate (bool): make copy of the daughters and update them after the vertex fit
46 smearing (float) : IP tube width is smeared by this value (cm). meaningful only with 'KFit/vertex/iptube' option.
47 path (basf2.Path): modules are added to this path
51 "Direct use of fitVertex is not recommended unless you know what you are doing.\n"
52 "Please use treeFit or kFit.\n"
53 "See documentation at https://software.belle2.org"
58 _fitVertex(list_name, conf_level, decay_string, fitter, fit_type, constraint, massConstraint, daughtersUpdate, smearing, path)
69 daughtersUpdate=False,
74 An internal function, performs the specified fit for each Particle in the given ParticleList.
77 This is a private function, please use one of the aliases provided.
80 list_name (str): name of the input ParticleList
81 conf_level (float): minimum value of the confidence level to accept the fit.
82 Setting this parameter to -1 selects all particle candidates.
83 The value of 0 rejects the particle candidates with failed fit.
84 decay_string (str): select particles used for the vertex fit
85 fitter (str): Rave or KFit
86 fit_type (str): type of the kinematic fit (valid options are vertex/massvertex/mass/fourC/massfourC)
87 constraint (str): add additional constraint to the fit (valid options are empty string/ipprofile/iptube/mother)
88 massConstraint (list(int) or list(str)): list of PDG ids or Names of the particles which are mass-constrained
89 Please do not mix PDG id and particle names in massConstraint list (valid only for massfourC).
90 daughtersUpdate (bool): make copy of the daughters and update them after the vertex fit
91 smearing (float) : IP tube width is smeared by this value (cm). meaningful only with 'KFit/vertex/iptube' option.
92 path (basf2.Path): modules are added to this path
95 pvfit = register_module(
'ParticleVertexFitter')
96 pvfit.set_name(
'ParticleVertexFitter_' + list_name)
97 pvfit.param(
'listName', list_name)
98 pvfit.param(
'confidenceLevel', conf_level)
99 pvfit.param(
'vertexFitter', fitter)
100 pvfit.param(
'fitType', fit_type)
101 pvfit.param(
'withConstraint', constraint)
102 pvfit.param(
'updateDaughters', daughtersUpdate)
103 pvfit.param(
'decayString', decay_string)
104 pvfit.param(
'smearing', smearing)
106 if isinstance(massConstraint[0], str):
107 pvfit.param(
'massConstraintListParticlename', massConstraint)
109 pvfit.param(
'massConstraintList', massConstraint)
110 path.add_module(pvfit)
117 daughtersUpdate=False,
123 Perform KFit for each Particle in the given ParticleList.
126 list_name (str): name of the input ParticleList
127 conf_level (float): minimum value of the confidence level to accept the fit
128 Setting this parameter to -1 selects all particle candidates.
129 The value of 0 rejects particle candidates with a failed fit.
130 fit_type (str): type of the kinematic fit. Valid options are
132 * ``mass`` for a mass-constrained fit
133 * ``vertex`` for a vertex fit
134 * ``massvertex`` for a vertex fit with a mass constraint on the mother particle
135 * ``fourC`` for a vertex fit in which the mother particle's four-momentum is constrained to the beam four-momentum
136 * ``massfourC`` for a vertex fit with a 4-momentum constraint and mass constraints on the specified daughter particles
138 constraint (str): add an additional constraint to the fit (valid options are ipprofile or iptube)
139 massConstraint (list(int) or list(str)): list of PDG ids or Names of the particles which are mass-constrained
140 Please do not mix PDG id and particle names in massConstraint list (valid only for massfourC).
141 daughtersUpdate (bool): make copy of the daughters and update them after the KFit
142 decay_string (str): select particles used for the KFit
143 smearing (float) : IP tube width is smeared by this value (cm). meaningful only with 'iptube' constraint.
144 path (basf2.Path): modules are added to this path
147 _fitVertex(list_name, conf_level, decay_string,
'KFit', fit_type, constraint, massConstraint, daughtersUpdate, smearing, path)
156 daughtersUpdate=False,
158 silence_warning=False,
161 Performs a vertex fit using `RAVE <https://github.com/rave-package>`_
162 for each Particle in the given ParticleList.
165 `RAVE <https://github.com/rave-package>`_ is deprecated since it is not maintained.
166 Whilst we will not remove RAVE, it is not recommended for analysis use, other than benchmarking or legacy studies.
167 Instead, we recommend :doc:`TreeFitter` (`vertex.treeFit`) or `vertex.kFit`.
170 list_name (str): name of the input ParticleList
171 conf_level (float): minimum value of the confidence level to accept the fit.
172 Setting this parameter to -1 selects all particle candidates.
173 The value of 0 rejects the particle candidates with failed fit.
174 fit_type (str): type of the RAVE vertex fit.Valid options are
176 * ``mass`` for a mass-constrained fit (the 7x7 error matrix of the mother particle has to be defined)
177 * ``vertex`` for a vertex fit without any mass constraint
178 * ``massvertex`` for a mass-constrained vertex fit
180 decay_string (str): select particles used for the vertex fit
181 constraint (str): add additional constraint to the fit
182 (valid options are ipprofile or iptube).
183 daughtersUpdate (bool): make copy of the daughters and update them after the Rave vertex fit
184 path (basf2.Path): modules are added to this path
185 silence_warning (bool): silence the warning advertising TreeFitter use
190 "RAVE is deprecated since it is not maintained.\n"
191 "Whilst we will not remove RAVE, it is not recommended for analysis use, other than benchmarking or legacy studies.\n"
192 "Instead, we recommend TreeFitter (treeFit) or KFit.\n"
193 "Try: \n treeFit(\'" + list_name +
"\'," + str(conf_level) +
194 ", updateAllDaughters=False, path=mypath)\n"
196 message_b =
"To silence this warning, add silence_warning=True when you call this function."
203 "Please consult the documentation at https://software.belle2.org \n"
204 "(search for TreeFitter) for special constraints.\n"
207 if not silence_warning:
208 B2WARNING(message_a + message_if + message_b)
210 _fitVertex(list_name, conf_level, decay_string,
'Rave', fit_type, constraint,
None, daughtersUpdate, 0, path)
218 updateAllDaughters=False,
219 customOriginConstraint=False,
220 customOriginVertex=[0.001, 0, 0.0116],
221 customOriginCovariance=[0.0048, 0, 0, 0, 0.003567, 0, 0, 0, 0.0400],
225 Perform a :doc:`TreeFitter` fit for each Particle in the given ParticleList.
228 An example of usage for the decay chain :math:`B^0\\to\\pi^+\\pi^-\\pi^0` is the following:
232 reconstructDecay('pi0:A -> gamma:pi0 gamma:pi0', '0.130 < InvM < 0.14', path=mypath)
233 reconstructDecay('B0:treefit -> pi+:my pi-:my pi0:A ', '', path=mypath)
234 treeFit('B0:treefit', ipConstraint=True, path=mypath)
237 list_name (str): name of the input ParticleList
238 conf_level (float): minimum value of the confidence level to accept the fit.
239 Setting this parameter to -1 selects all particle candidates.
240 The value of 0 rejects the particle candidates with failed fit.
241 massConstraint (list(int) or list(str)): list of PDG ids or Names of the particles which are mass-constrained
242 Please do not mix PDG id and particle names in massConstraint list.
243 ipConstraint (bool): constrain head production vertex to IP (x-y-z) constraint
244 customOriginConstraint (bool): use a custom origin vertex as the production vertex of your particle.
245 This is useful when fitting D*/D without wanting to fit a B but constraining the process to be B-decay-like.
246 customOriginVertex (list(float)): 3d vector of the vertex coordinates you want to use as custom origin.
247 Default numbers are taken for B-mesons
248 customOriginCovariance (list(float)): 3x3 covariance matrix for the custom vertex (type: vector).
249 Default numbers extracted from generator distribution width of B-mesons.
250 updateAllDaughters (bool): if true the entire tree will be updated with the fitted values
251 for momenta and vertex position. Otherwise only the momenta of the head of the tree will be updated,
252 however for all daughters we also update the vertex position with the fit results as this would
253 otherwise be set to {0, 0, 0} contact us if this causes any hardship/confusion.
254 path (basf2.Path): modules are added to this path
256 treeFitter = register_module(
"TreeFitter")
257 treeFitter.set_name(
'TreeFitter_' + list_name)
259 if isinstance(massConstraint[0], str):
260 treeFitter.param(
'massConstraintListParticlename', massConstraint)
262 treeFitter.param(
'massConstraintList', massConstraint)
263 treeFitter.param(
'particleList', list_name)
264 treeFitter.param(
'confidenceLevel', conf_level)
265 treeFitter.param(
'ipConstraint', ipConstraint)
266 treeFitter.param(
'updateAllDaughters', updateAllDaughters)
267 treeFitter.param(
'customOriginConstraint', customOriginConstraint)
268 treeFitter.param(
'customOriginVertex', customOriginVertex)
269 treeFitter.param(
'customOriginCovariance', customOriginCovariance)
270 path.add_module(treeFitter)
277 trackFindingType="standard_PXD",
288 For each Particle in the given Breco ParticleList:
289 perform the fit of tag side using the track list from the RestOfEvent dataobject
290 save the MC Btag in case of signal MC
294 list_name (str): name of the input Breco ParticleList
295 MCassociation (str): use standard MC association or the internal one
296 confidenceLevel (float): minimum value of the ConfidenceLevel to accept the fit. 0 selects CL > 0
297 constraintType (str): choose the constraint used in the fit. Can be set to
300 * IP: **default**, tag B constrained to be on the IP;
301 * tube: tube along the tag B line of flight, only for fully reconstructed signal B;
302 * boost: long tube along the boost direction;
303 * (breco): deprecated, but similar to tube;
305 trackFindingType (str): choose how to look for tag tracks. Can be set to
307 * standard: all tracks except from Kshorts;
308 * standard_PXD: **default**, same as above but consider only tracks with at least 1 PXD hit.
309 If the fit fails, attempt again with the standard option;
311 fitAlgorithm (str): Fitter used for the tag vertex fit: Rave (default) or KFit
312 askMCInfo (bool): True when requesting MC Information from the tracks performing the vertex fit
313 reqPXDHits (int): minimum N PXD hits for a track (default is 0)
314 maskName (str): get particles from a specified ROE mask
315 useTruthInFit (bool): True when the tag vertex fit is performed with the true momentum and
316 position of the tracks (default is false). The variable :b2:var:`TagVFitTruthStatus` is set to 1
317 if the truth-matching succeeds and 2 otherwise.
318 useRollBack (bool): True when the tag vertex fit is performed with position of tracks rolled back to
319 position of the mother B (default is false). The variable :b2:var:`TagVRollBackStatus` is set to 1
320 if the truth-matching succeeds and 2 otherwise.
321 path (basf2.Path): modules are added to this path
324 Note that the useFitAlgorithm (str) parameter is deprecated and replaced by constraintType (str)
325 and trackFindingType (str)
328 The trackFindingType ``singleTrack`` and ``singleTrack_PXD`` are broken and **cannot** be used any more.
331 tvfit = register_module(
'TagVertex')
332 tvfit.set_name(
'TagVertex_' + list_name)
333 tvfit.param(
'listName', list_name)
334 tvfit.param(
'maskName', maskName)
335 tvfit.param(
'confidenceLevel', confidenceLevel)
336 tvfit.param(
'MCAssociation', MCassociation)
337 tvfit.param(
'trackFindingType', trackFindingType)
338 tvfit.param(
'constraintType', constraintType)
339 tvfit.param(
'askMCInformation', askMCInfo)
340 tvfit.param(
'reqPXDHits', reqPXDHits)
341 tvfit.param(
'fitAlgorithm', fitAlgorithm)
342 tvfit.param(
'useTruthInFit', useTruthInFit)
343 tvfit.param(
'useRollBack', useRollBack)
344 path.add_module(tvfit)
352 Add a pseudo \"vertex fit\" which adds a covariance matrix from the combination of the four-vectors of the daughters.
353 This is similar to BaBar's "Add4" function.
354 It is commonly used for :math:`\\pi^0\\to\\gamma\\gamma` reconstruction where a vertex fit is not possible.
356 Here is the basic usage:
360 from modularAnalysis import fitPseudo
361 from stdPi0s import stdPi0s
362 stdPi0s("eff40_May2020", path=mypath)
363 fitPseudo("pi0:eff40_May2020", path=mypath)
366 list_name (str): the name of the list to add the covariance matrix to
367 path (basf2.Path): modules are added to this path
369 pseudofit = register_module(
'PseudoVertexFitter')
370 pseudofit.set_name(
'PseudoVertexFitter_' + list_name)
371 pseudofit.param(
'listName', list_name)
372 path.add_module(pseudofit)
375 if __name__ ==
'__main__':
377 pretty_print_module(__name__,
"vertex")