4 from basf2
import register_module
5 from basf2
import B2WARNING
15 daughtersUpdate=False,
20 Perform the specified fit for each Particle in the given ParticleList.
23 Direct use of `fitVertex` is not recommended unless you know what you are doing.
24 If you're unsure, you probably want to use `treeFit` or `kFit`.
27 list_name (str): name of the input ParticleList
28 conf_level (float): minimum value of the confidence level to accept the fit.
29 Setting this parameter to -1 selects all particle candidates.
30 The value of 0 rejects the particle candidates with failed fit.
31 decay_string (str): select particles used for the vertex fit
32 fitter (str): Rave or KFit
33 fit_type (str): type of the kinematic fit (valid options are vertex/massvertex/mass/fourC)
34 constraint (str): add aditional constraint to the fit (valid options are empty string/ipprofile/iptube/mother)
35 daughtersUpdate (bool): make copy of the daughters and update them after the vertex fit
36 smearing (float) : IP tube width is smeared by this value (cm). meaningful only with 'KFit/vertex/iptube' option.
37 path (basf2.Path): modules are added to this path
41 "Direct use of fitVertex is not recommended unless you know what you are doing.\n"
42 "Please use treeFit or kFit.\n"
43 "See documentation at https://software.belle2.org"
48 _fitVertex(list_name, conf_level, decay_string, fitter, fit_type, constraint, daughtersUpdate, smearing, path)
58 daughtersUpdate=False,
63 An internal function, performs the specified fit for each Particle in the given ParticleList.
66 This is a private function, please use one of the aliases provided.
69 list_name (str): name of the input ParticleList
70 conf_level (float): minimum value of the confidence level to accept the fit.
71 Setting this parameter to -1 selects all particle candidates.
72 The value of 0 rejects the particle candidates with failed fit.
73 decay_string (str): select particles used for the vertex fit
74 fitter (str): Rave or KFit
75 fit_type (str): type of the kinematic fit (valid options are vertex/massvertex/mass/fourC)
76 constraint (str): add aditional constraint to the fit (valid options are empty string/ipprofile/iptube/mother)
77 daughtersUpdate (bool): make copy of the daughters and update them after the vertex fit
78 smearing (float) : IP tube width is smeared by this value (cm). meaningful only with 'KFit/vertex/iptube' option.
79 path (basf2.Path): modules are added to this path
82 pvfit = register_module(
'ParticleVertexFitter')
83 pvfit.set_name(
'ParticleVertexFitter_' + list_name)
84 pvfit.param(
'listName', list_name)
85 pvfit.param(
'confidenceLevel', conf_level)
86 pvfit.param(
'vertexFitter', fitter)
87 pvfit.param(
'fitType', fit_type)
88 pvfit.param(
'withConstraint', constraint)
89 pvfit.param(
'updateDaughters', daughtersUpdate)
90 pvfit.param(
'decayString', decay_string)
91 pvfit.param(
'smearing', smearing)
92 path.add_module(pvfit)
99 daughtersUpdate=False,
104 Perform KFit for each Particle in the given ParticleList.
107 list_name (str): name of the input ParticleList
108 conf_level (float): minimum value of the confidence level to accept the fit
109 Setting this parameter to -1 selects all particle candidates.
110 The value of 0 rejects particle candidates with a failed fit.
111 fit_type (str): type of the kinematic fit. Valid options are
113 * ``mass`` for a mass-constrained fit
114 * ``vertex`` for a vertex fit
115 * ``massvertex`` for a vertex fit with a mass constraint on the mother particle
116 * ``fourC`` for a vertex fit in which the mother particle's four-momentum is constrained to the beam four-momentum
118 constraint (str): add an additional constraint to the fit (valid options are ipprofile or iptube)
119 daughtersUpdate (bool): make copy of the daughters and update them after the KFit
120 decay_string (str): select particles used for the KFit
121 smearing (float) : IP tube width is smeared by this value (cm). meaningful only with 'iptube' constraint.
122 path (basf2.Path): modules are added to this path
125 _fitVertex(list_name, conf_level, decay_string,
'KFit', fit_type, constraint, daughtersUpdate, smearing, path)
134 daughtersUpdate=False,
136 silence_warning=False,
139 Performs a vertex fit using `RAVE <https://github.com/rave-package>`_
140 for each Particle in the given ParticleList.
143 `RAVE <https://github.com/rave-package>`_ is deprecated since it is not maintained.
144 Whilst we will not remove RAVE, it is not recommended for analysis use, other than benchmarking or legacy studies.
145 Instead, we recommend :doc:`TreeFitter` (`vertex.treeFit`) or `vertex.kFit`.
148 list_name (str): name of the input ParticleList
149 conf_level (float): minimum value of the confidence level to accept the fit.
150 Setting this parameter to -1 selects all particle candidates.
151 The value of 0 rejects the particle candidates with failed fit.
152 fit_type (str): type of the RAVE vertex fit.Valid options are
154 * ``mass`` for a mass-constrained fit (the 7x7 error matrix of the mother particle has to be defined)
155 * ``vertex`` for a vertex fit without any mass constraint
156 * ``massvertex`` for a mass-constrained vertex fit
158 decay_string (str): select particles used for the vertex fit
159 constraint (str): add aditional constraint to the fit
160 (valid options are ipprofile or iptube).
161 daughtersUpdate (bool): make copy of the daughters and update them after the Rave vertex fit
162 path (basf2.Path): modules are added to this path
163 silence_warning (bool): silence the warning advertising TreeFitter use
168 "RAVE is deprecated since it is not maintained.\n"
169 "Whilst we will not remove RAVE, it is not recommended for analysis use, other than benchmarking or legacy studies.\n"
170 "Instead, we recommend TreeFitter (treeFit) or KFit.\n"
171 "Try: \n treeFit(\'" + list_name +
"\'," + str(conf_level) +
172 ", updateAllDaughters=False, path=mypath)\n"
174 message_b =
"To silence this warning, add silence_warning=True when you call this function."
181 "Please consult the documentation at https://software.belle2.org \n"
182 "(search for TreeFitter) for special constraints.\n"
185 if not silence_warning:
186 B2WARNING(message_a + message_if + message_b)
188 _fitVertex(list_name, conf_level, decay_string,
'Rave', fit_type, constraint, daughtersUpdate, 0, path)
196 updateAllDaughters=False,
197 customOriginConstraint=False,
198 customOriginVertex=[0.001, 0, 0.0116],
199 customOriginCovariance=[0.0048, 0, 0, 0, 0.003567, 0, 0, 0, 0.0400],
203 Perform a :doc:`TreeFitter` fit for each Particle in the given ParticleList.
206 An example of usage for the decay chain :math:`B^0\\to\\pi^+\\pi^-\\pi^0` is the following:
210 reconstructDecay('pi0:A -> gamma:pi0 gamma:pi0', '0.130 < InvM < 0.14', path=mypath)
211 reconstructDecay('B0:treefit -> pi+:my pi-:my pi0:A ', '', path=mypath)
212 treeFit('B0:treefit', ipConstraint=True, path=mypath)
215 list_name (str): name of the input ParticleList
216 conf_level (float): minimum value of the confidence level to accept the fit.
217 Setting this parameter to -1 selects all particle candidates.
218 The value of 0 rejects the particle candidates with failed fit.
219 massConstraint (list(int) or list(str)): list of PDG ids or Names of the particles which are mass-constrained
220 Please do not mix PDG id and particle names in massConstraint list.
221 ipConstraint (bool): constrain head production vertex to IP (x-y-z) constraint
222 customOriginConstraint (bool): use a costum origin vertex as the production vertex of your particle.
223 This is usefull when fitting D*/D without wanting to fit a B but constraining the process to be B-decay-like.
224 (think of semileptonic modes and stuff with a neutrino in the B decay).
225 customOriginVertex (list(float)): 3d vector of the vertex coordinates you want to use as custom origin.
226 Default numbers are taken for B-mesons
227 customOriginCovariance (list(float)): 3x3 covariance matrix for the custom vertex (type: vector).
228 Default numbers extracted from generator distribtuion width of B-mesons.
229 updateAllDaughters (bool): if true the entire tree will be updated with the fitted values
230 for momenta and vertex position. Otherwise only the momenta of the head of the tree will be updated,
231 however for all daughters we also update the vertex position with the fit results as this would
232 otherwise be set to {0, 0, 0} contact us if this causes any hardship/confusion.
233 path (basf2.Path): modules are added to this path
235 treeFitter = register_module(
"TreeFitter")
236 treeFitter.set_name(
'TreeFitter_' + list_name)
238 if isinstance(massConstraint[0], str):
239 treeFitter.param(
'massConstraintListParticlename', massConstraint)
241 treeFitter.param(
'massConstraintList', massConstraint)
242 treeFitter.param(
'particleList', list_name)
243 treeFitter.param(
'confidenceLevel', conf_level)
244 treeFitter.param(
'ipConstraint', ipConstraint)
245 treeFitter.param(
'updateAllDaughters', updateAllDaughters)
246 treeFitter.param(
'customOriginConstraint', customOriginConstraint)
247 treeFitter.param(
'customOriginVertex', customOriginVertex)
248 treeFitter.param(
'customOriginCovariance', customOriginCovariance)
250 path.add_module(treeFitter)
257 trackFindingType="standard_PXD",
268 For each Particle in the given Breco ParticleList:
269 perform the fit of tag side using the track list from the RestOfEvent dataobject
270 save the MC Btag in case of signal MC
274 list_name (str): name of the input Breco ParticleList
275 MCassociation (str): use standard MC association or the internal one
276 confidenceLevel (float): minimum value of the ConfidenceLevel to accept the fit. 0 selects CL > 0
277 constraintType (str): choose the constraint used in the fit. Can be set to
280 * IP: **default**, tag B constrained to be on the IP;
281 * tube: tube along the tag B line of flight, only for fully reconstructed signal B;
282 * boost: long tube along the boost direction;
283 * (breco): deprecated, but similar to tube;
285 trackFindingType (str): choose how to look for tag tracks. Can be set to
287 * standard: all tracks except from Kshorts;
288 * standard_PXD: **default**, same as above but consider only tracks with at least 1 PXD hit.
289 If the fit fails, attempt again with the standard option;
291 fitAlgorithm (str): Fitter used for the tag vertex fit: Rave (default) or KFit
292 askMCInfo (bool): True when requesting MC Information from the tracks performing the vertex fit
293 reqPXDHits (int): minimum N PXD hits for a track (default is 0)
294 maskName (str): get particles from a specified ROE mask
295 useTruthInFit (bool): True when the tag vertex fit is performed with the true momentum and
296 position of the tracks (default is false). The variable :b2:var:`TagVFitTruthStatus` is set to 1
297 if the truth-matching succeeds and 2 otherwise.
298 useRollBack (bool): True when the tag vertex fit is performed with position of tracks rolled back to
299 position of the mother B (default is false). The variable :b2:var:`TagVRollBackStatus` is set to 1
300 if the truth-matching succeeds and 2 otherwise.
301 path (basf2.Path): modules are added to this path
304 Note that the useFitAlgorithm (str) parameter is deprecated and replaced by constraintType (str)
305 and trackFindingType (str)
308 The trackFindingType ``singleTrack`` and ``singleTrack_PXD`` are broken and **cannot** be used any more.
311 tvfit = register_module(
'TagVertex')
312 tvfit.set_name(
'TagVertex_' + list_name)
313 tvfit.param(
'listName', list_name)
314 tvfit.param(
'maskName', maskName)
315 tvfit.param(
'confidenceLevel', confidenceLevel)
316 tvfit.param(
'MCAssociation', MCassociation)
317 tvfit.param(
'trackFindingType', trackFindingType)
318 tvfit.param(
'constraintType', constraintType)
319 tvfit.param(
'askMCInformation', askMCInfo)
320 tvfit.param(
'reqPXDHits', reqPXDHits)
321 tvfit.param(
'fitAlgorithm', fitAlgorithm)
322 tvfit.param(
'useTruthInFit', useTruthInFit)
323 tvfit.param(
'useRollBack', useRollBack)
324 path.add_module(tvfit)
332 Add a pseudo \"vertex fit\" which adds a covariance matrix from the combination of the four-vectors of the daughters.
333 This is similar to BaBar's "Add4" function.
334 It is commonly used for :math:`\\pi^0\\to\\gamma\\gamma` reconstruction where a vertex fit is not possible.
336 Here is the basic usage:
340 from modularAnalysis import fitPseudo
341 from stdPi0s import stdPi0s
342 stdPi0s("eff40_Jan2020", path=mypath)
343 fitPseudo("pi0:eff40_Jan2020", path=mypath)
346 list_name (str): the name of the list to add the covariance matrix to
347 path (basf2.Path): modules are added to this path
349 pseudofit = register_module(
'PseudoVertexFitter')
350 pseudofit.set_name(
'PseudoVertexFitter_' + list_name)
351 pseudofit.param(
'listName', list_name)
352 path.add_module(pseudofit)
355 if __name__ ==
'__main__':
357 pretty_print_module(__name__,
"vertex")