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