Belle II Software  release-05-01-25
kinfit.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 from basf2 import register_module
5 import inspect
6 
7 
8 def fitKinematic4C(
9  list_name,
10  fitterEngine='NewFitterGSL',
11  constraint='HardBeam',
12  daughtersUpdate=True,
13  addUnmeasuredPhoton=False,
14  path=None,
15 ):
16  """
17  Perform 4C momentum constraint kinematic fit for particles in the given ParticleList.
18 
19  @param list_name name of the input ParticleList
20  @param fitterEngine NewFitterGSL or OPALFitterGSL
21  @param constraint HardBeam or RecoilMass
22  @param daughtersUpdate make copy of the daughters and update them after the vertex fit
23  @param addUnmeasuredPhoton add one unmeasured photon (costs 3C)
24  @param path modules are added to this path
25  """
26 
27  orca = register_module('ParticleKinematicFitter')
28  orca.set_name('ParticleKinematicFitter_' + list_name)
29  orca.param('debugFitter', False)
30  orca.param('orcaTracer', 'None')
31  orca.param('orcaFitterEngine', fitterEngine)
32  orca.param('orcaConstraint', constraint) # beam parameters automatically taken from database
33  orca.param('listName', list_name)
34  orca.param('updateDaughters', daughtersUpdate)
35  orca.param('addUnmeasuredPhoton', addUnmeasuredPhoton)
36  path.add_module(orca)
37 
38 
39 def UnmeasuredfitKinematic1C(
40  list_name,
41  fitterEngine='NewFitterGSL',
42  constraint='HardBeam',
43  daughtersUpdate=True,
44  addUnmeasuredPhoton=True,
45  path=None,
46 ):
47  """
48  Perform 1C momentum constraint kinematic fit with one unmeasured photon for particles in the given ParticleList.
49 
50  @param list_name name of the input ParticleList
51  @param fitterEngine NewFitterGSL or OPALFitterGSL
52  @param constraint HardBeam or RecoilMass
53  @param daughtersUpdate make copy of the daughters and update them after the vertex fit
54  @param addUnmeasuredPhoton add one unmeasured photon (costs 3C)
55  @param path modules are added to this path
56  """
57 
58  orca = register_module('ParticleKinematicFitter')
59  orca.set_name('ParticleKinematicFitter_' + list_name)
60  orca.param('debugFitter', False)
61  orca.param('orcaTracer', 'None')
62  orca.param('orcaFitterEngine', fitterEngine)
63  orca.param('orcaConstraint', constraint) # beam parameters automatically taken from database
64  orca.param('listName', list_name)
65  orca.param('updateDaughters', daughtersUpdate)
66  orca.param('addUnmeasuredPhoton', addUnmeasuredPhoton)
67  path.add_module(orca)
68 
69 
70 def fitKinematic3C(
71  list_name,
72  fitterEngine='NewFitterGSL',
73  constraint='HardBeam',
74  daughtersUpdate=True,
75  addUnmeasuredPhoton=False,
76  add3CPhoton=True,
77  path=None,
78 ):
79  """
80  Perform 3C momentum constraint kinematic fit with one photon with unmeasured energy for particles
81  in the given ParticleList, the first daughter should be the energy unmeasured Photon.
82 
83  @param list_name name of the input ParticleList
84  @param fitterEngine NewFitterGSL or OPALFitterGSL
85  @param constraint HardBeam or RecoilMass
86  @param daughtersUpdate make copy of the daughters and update them after the vertex fit
87  @param addUnmeasuredPhoton add one unmeasured photon (costs 3C)
88  @param add3CPhoton add one photon with unmeasured energy (costs 1C)
89  @param path modules are added to this path
90  """
91 
92  orca = register_module('ParticleKinematicFitter')
93  orca.set_name('ParticleKinematicFitter_' + list_name)
94  orca.param('debugFitter', False)
95  orca.param('orcaTracer', 'None')
96  orca.param('orcaFitterEngine', fitterEngine)
97  orca.param('orcaConstraint', constraint) # beam parameters automatically taken from database
98  orca.param('listName', list_name)
99  orca.param('updateDaughters', daughtersUpdate)
100  orca.param('addUnmeasuredPhoton', addUnmeasuredPhoton)
101  orca.param('add3CPhoton', add3CPhoton)
102  path.add_module(orca)
103 
104 
105 def MassfitKinematic1CRecoil(
106  list_name,
107  recoilMass,
108  fitterEngine='NewFitterGSL',
109  constraint='RecoilMass',
110  daughtersUpdate=True,
111  addUnmeasuredPhoton=False,
112  path=None,
113 ):
114  """
115  Perform recoil mass kinematic fit for particles in the given ParticleList.
116 
117  @param list_name name of the input ParticleList
118  @param fitterEngine NewFitterGSL or OPALFitterGSL
119  @param constraint HardBeam or RecoilMass
120  @param recoilMass RecoilMass (GeV)
121  @param daughtersUpdate make copy of the daughters and update them after the vertex fit
122  @param addUnmeasuredPhoton add one unmeasured photon (costs 3C)
123  @param path modules are added to this path
124  """
125 
126  orca = register_module('ParticleKinematicFitter')
127  orca.set_name('ParticleKinematicFitter_' + list_name)
128  orca.param('debugFitter', False)
129  orca.param('orcaTracer', 'None')
130  orca.param('orcaFitterEngine', fitterEngine)
131  orca.param('orcaConstraint', constraint)
132  orca.param('recoilMass', recoilMass)
133  orca.param('listName', list_name)
134  orca.param('updateDaughters', daughtersUpdate)
135  orca.param('addUnmeasuredPhoton', addUnmeasuredPhoton)
136  path.add_module(orca)
137 
138 
139 def MassfitKinematic1C(
140  list_name,
141  invMass,
142  fitterEngine='NewFitterGSL',
143  constraint='Mass',
144  daughtersUpdate=True,
145  addUnmeasuredPhoton=False,
146  path=None,
147 ):
148  """
149  Perform recoil mass kinematic fit for particles in the given ParticleList.
150 
151  @param list_name name of the input ParticleList
152  @param fitterEngine NewFitterGSL or OPALFitterGSL
153  @param constraint HardBeam or RecoilMass or Mass
154  @param invMass Inviriant Mass (GeV)
155  @param daughtersUpdate make copy of the daughters and update them after the vertex fit
156  @param addUnmeasuredPhoton add one unmeasured photon (costs 3C)
157  @param path modules are added to this path
158  """
159 
160  orca = register_module('ParticleKinematicFitter')
161  orca.set_name('ParticleKinematicFitter_' + list_name)
162  orca.param('debugFitter', False)
163  orca.param('orcaTracer', 'None')
164  orca.param('orcaFitterEngine', fitterEngine)
165  orca.param('orcaConstraint', constraint)
166  orca.param('invMass', invMass)
167  orca.param('listName', list_name)
168  orca.param('updateDaughters', daughtersUpdate)
169  orca.param('addUnmeasuredPhoton', addUnmeasuredPhoton)
170  path.add_module(orca)
171 
172 
173 if __name__ == '__main__':
174  from basf2.utils import pretty_print_module
175  pretty_print_module(__name__, "kinfit")
basf2.utils
Definition: utils.py:1