Belle II Software  light-2212-foldex
stdV0s.py
1 #!/usr/bin/env python3
2 
3 
10 
11 from basf2 import B2ERROR
12 import modularAnalysis as ma
13 from stdCharged import stdPi, stdPr
14 import vertex
15 
16 
17 def stdKshorts(prioritiseV0=True, fitter='TreeFit', path=None):
18  """
19  Load a combined list of the Kshorts list from V0 objects merged with
20  a list of particles combined using the analysis ParticleCombiner module.
21 
22  The ParticleList is named ``K_S0:merged``. A vertex fit is performed and only
23  candidates with an invariant mass in the range :math:`0.450 < M < 0.550~GeV`,
24  and for which the vertex fit did not fail, are kept.
25 
26  The vertex fitter can be selected among ``TreeFit``, ``KFit``, and ``Rave``.
27 
28  Parameters:
29  prioritiseV0 (bool): should the V0 mdst objects be prioritised when merging?
30  fitter (str): vertex fitter name, valid options are ``TreeFit``, ``KFit``, and ``Rave``.
31  path (basf2.Path): the path to load the modules
32  """
33  # Fill one list from V0
34  ma.fillParticleList('K_S0:V0 -> pi+ pi-', '', True, path=path)
35  ma.cutAndCopyList('K_S0:V0_MassWindow', 'K_S0:V0', '0.3 < M < 0.7', path=path)
36  # Perform vertex fit and apply tighter mass window
37  if fitter == 'TreeFit':
38  vertex.treeFit('K_S0:V0_MassWindow', conf_level=0.0, path=path)
39  elif fitter == 'KFit':
40  vertex.kFit('K_S0:V0_MassWindow', conf_level=0.0, path=path)
41  elif fitter == 'Rave':
42  vertex.raveFit('K_S0:V0_MassWindow', conf_level=0.0, path=path, silence_warning=True)
43  else:
44  B2ERROR("Valid fitter options for Kshorts are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended.")
45  ma.applyCuts('K_S0:V0_MassWindow', '0.450 < M < 0.550', path=path)
46  # Reconstruct a second list
47  stdPi('all', path=path) # no quality cuts
48  ma.reconstructDecay('K_S0:RD -> pi+:all pi-:all', '0.3 < M < 0.7', 1, True, path=path)
49  # Again perform vertex fit and apply tighter mass window
50  if fitter == 'TreeFit':
51  vertex.treeFit('K_S0:RD', conf_level=0.0, path=path)
52  elif fitter == 'KFit':
53  vertex.kFit('K_S0:RD', conf_level=0.0, path=path)
54  elif fitter == 'Rave':
55  vertex.raveFit('K_S0:RD', conf_level=0.0, path=path, silence_warning=True)
56  ma.applyCuts('K_S0:RD', '0.450 < M < 0.550', path=path)
57  # Create merged list based on provided priority
58  ma.mergeListsWithBestDuplicate('K_S0:merged', ['K_S0:V0_MassWindow', 'K_S0:RD'],
59  variable='particleSource', preferLowest=prioritiseV0, path=path)
60 
61 
62 def goodBelleKshort(path):
63  """
64  Load the Belle goodKshort list. Creates a ParticleList named
65  ``K_S0:legacyGoodKS``. A vertex fit is performed and only candidates that
66  satisfy the :b2:var:`goodBelleKshort` criteria, with an invariant mass in the range
67  :math:`0.468 < M < 0.528~GeV`, and for which the vertex fit did not fail, are kept
68 
69  Parameters:
70  path (basf2.Path): the path to load the modules
71  """
72  ma.fillParticleList('K_S0:legacyGoodKS -> pi+ pi-', '0.3 < M < 0.7', True, path=path)
73  vertex.kFit('K_S0:legacyGoodKS', conf_level=0.0, path=path)
74  ma.applyCuts('K_S0:legacyGoodKS', '0.468 < M < 0.528 and goodBelleKshort==1', path=path)
75 
76 
77 def scaleErrorKshorts(prioritiseV0=True, fitter='TreeFit',
78  scaleFactors_V0=[1.125927, 1.058803, 1.205928, 1.066734, 1.047513],
79  scaleFactorsNoPXD_V0=[1.125927, 1.058803, 1.205928, 1.066734, 1.047513],
80  d0Resolution_V0=[0.001174, 0.000779],
81  z0Resolution_V0=[0.001350, 0.000583],
82  d0MomThr_V0=0.500000,
83  z0MomThr_V0=0.00000,
84  scaleFactors_RD=[1.149631, 1.085547, 1.151704, 1.096434, 1.086659],
85  scaleFactorsNoPXD_RD=[1.149631, 1.085547, 1.151704, 1.096434, 1.086659],
86  d0Resolution_RD=[0.00115328, 0.00134704],
87  z0Resolution_RD=[0.00124327, 0.0013272],
88  d0MomThr_RD=0.500000,
89  z0MomThr_RD=0.500000,
90  path=None):
91  '''
92  Reconstruct K_S0 applying helix error correction to K_S0 daughters given by ``modularAnalysis.scaleError``.
93  The ParticleList is named ``K_S0:scaled``
94 
95  Considering the difference of multiple scattering through the beam pipe,
96  different parameter sets are used for K_S0 decaying outside/inside the beam pipe (``K_S0:V0/RD``).
97 
98  Only for TDCPV analysis.
99 
100  @param prioritiseV0 If True K_S0 from V0 object is prioritised over RD when merged.
101  @param fitter Vertex fitter option. Choose from ``TreeFit``, ``KFit`` and ``Rave``.
102  @param scaleFactors_V0 List of five constants to be multiplied to each of helix errors (for tracks with a PXD hit)
103  @param scaleFactorsNoPXD_V0 List of five constants to be multiplied to each of helix errors (for tracks without a PXD hit)
104  @param d0Resolution_V0 List of two parameters, (a [cm], b [cm/(GeV/c)]),
105  defining d0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**1.5))**2 }
106  @param z0Resolution_V0 List of two parameters, (a [cm], b [cm/(GeV/c)]),
107  defining z0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**2.5))**2 }
108  @param d0MomThr_V0 d0 best resolution is kept constant below this momentum
109  @param z0MomThr_V0 z0 best resolution is kept constant below this momentum
110  @param scaleFactors_RD List of five constants to be multiplied to each of helix errors (for tracks with a PXD hit)
111  @param scaleFactorsNoPXD_RD List of five constants to be multiplied to each of helix errors (for tracks without a PXD hit)
112  @param d0Resolution_RD List of two parameters, (a [cm], b [cm/(GeV/c)]),
113  defining d0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**1.5))**2 }
114  @param z0Resolution_RD List of two parameters, (a [cm], b [cm/(GeV/c)]),
115  defining z0 best resolution as sqrt{ a**2 + (b / (p*beta*sinTheta**2.5))**2 }
116  @param d0MomThr_RD d0 best resolution is kept constant below this momentum
117  @param z0MomThr_RD z0 best resolution is kept constant below this momentum
118 
119  '''
120  from basf2 import register_module
121  # Load K_S0 from V0 and apply helix error correction to V0 daughters
122  ma.fillParticleList('K_S0:V0 -> pi+ pi-', '', True, path=path)
123  scaler_V0 = register_module("HelixErrorScaler")
124  scaler_V0.set_name('ScaleError_' + 'K_S0:V0')
125  scaler_V0.param('inputListName', 'K_S0:V0')
126  scaler_V0.param('outputListName', 'K_S0:V0_scaled')
127  scaler_V0.param('scaleFactors_PXD', scaleFactors_V0)
128  scaler_V0.param('scaleFactors_noPXD', scaleFactorsNoPXD_V0)
129  scaler_V0.param('d0ResolutionParameters', d0Resolution_V0)
130  scaler_V0.param('z0ResolutionParameters', z0Resolution_V0)
131  scaler_V0.param('d0MomentumThreshold', d0MomThr_V0)
132  scaler_V0.param('z0MomentumThreshold', z0MomThr_V0)
133  path.add_module(scaler_V0)
134 
135  ma.applyCuts('K_S0:V0_scaled', '0.3 < M < 0.7', path=path)
136  # Perform vertex fit and apply tighter mass window
137  if fitter == 'TreeFit':
138  vertex.treeFit('K_S0:V0_scaled', conf_level=0.0, path=path)
139  elif fitter == 'KFit':
140  vertex.kFit('K_S0:V0_scaled', conf_level=0.0, path=path)
141  elif fitter == 'Rave':
142  vertex.raveFit('K_S0:V0_scaled', conf_level=0.0, path=path, silence_warning=True)
143  else:
144  B2ERROR("Valid fitter options for Kshorts are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended.")
145  ma.applyCuts('K_S0:V0_scaled', '0.450 < M < 0.550', path=path)
146 
147  # Reconstruct a second list
148  stdPi('all', path=path)
149  ma.scaleError('pi+:scaled', 'pi+:all',
150  scaleFactors=scaleFactors_RD,
151  scaleFactorsNoPXD=scaleFactorsNoPXD_RD,
152  d0Resolution=d0Resolution_RD,
153  z0Resolution=z0Resolution_RD,
154  d0MomThr=d0MomThr_RD,
155  z0MomThr=z0MomThr_RD,
156  path=path)
157 
158  ma.reconstructDecay('K_S0:RD_scaled -> pi+:scaled pi-:scaled', '0.3 < M < 0.7', 1, True, path=path)
159  # Again perform vertex fit and apply tighter mass window
160  if fitter == 'TreeFit':
161  vertex.treeFit('K_S0:RD_scaled', conf_level=0.0, path=path)
162  elif fitter == 'KFit':
163  vertex.kFit('K_S0:RD_scaled', conf_level=0.0, path=path)
164  elif fitter == 'Rave':
165  vertex.raveFit('K_S0:RD_scaled', conf_level=0.0, path=path, silence_warning=True)
166  ma.applyCuts('K_S0:RD_scaled', '0.450 < M < 0.550', path=path)
167  # Create merged list based on provided priority
168  ma.mergeListsWithBestDuplicate('K_S0:scaled', ['K_S0:V0_scaled', 'K_S0:RD_scaled'],
169  variable='particleSource', preferLowest=prioritiseV0, path=path)
170 
171 
172 def stdLambdas(prioritiseV0=True, fitter='TreeFit', path=None):
173  """
174  Load a combined list of the Lambda list from V0 objects merged with
175  a list of particles combined using the analysis ParticleCombiner module.
176 
177  The ParticleList is named ``Lambda0:merged``. A vertex fit is performed and only
178  candidates with an invariant mass in the range :math:`1.10 < M < 1.13~GeV`,
179  and for which the vertex fit did not fail, are kept.
180 
181  The vertex fitter can be selected among ``TreeFit``, ``KFit``, and ``Rave``.
182 
183  Parameters:
184  prioritiseV0 (bool): should the V0 mdst objects be prioritised when merging?
185  fitter (str): vertex fitter name, valid options are ``TreeFit``, ``KFit``, and ``Rave``.
186  path (basf2.Path): the path to load the modules
187  """
188  # Fill one list from V0
189  ma.fillParticleList('Lambda0:V0 -> p+ pi-', '', True, path=path)
190  ma.cutAndCopyList('Lambda0:V0_MassWindow', 'Lambda0:V0', '0.9 < M < 1.3', path=path)
191  # Perform vertex fit and apply tighter mass window
192  if fitter == 'TreeFit':
193  vertex.treeFit('Lambda0:V0_MassWindow', conf_level=0.0, path=path)
194  elif fitter == 'KFit':
195  vertex.kFit('Lambda0:V0_MassWindow', conf_level=0.0, path=path)
196  elif fitter == 'Rave':
197  vertex.raveFit('Lambda0:V0_MassWindow', conf_level=0.0, path=path, silence_warning=True)
198  else:
199  B2ERROR("Valid fitter options for Lambdas are 'TreeFit', 'KFit', and 'Rave'. However, the latter is not recommended.")
200  ma.applyCuts('Lambda0:V0_MassWindow', '1.10 < M < 1.13', path=path)
201  # Find V0 duplicate with better vertex fit quality
202  ma.markDuplicate('Lambda0:V0_MassWindow', False, path=path)
203  ma.applyCuts('Lambda0:V0_MassWindow', 'extraInfo(highQualityVertex)', path=path)
204  # Reconstruct a second list
205  stdPi('all', path=path) # no quality cuts
206  stdPr('all', path=path) # no quality cuts
207  ma.reconstructDecay('Lambda0:RD -> p+:all pi-:all', '0.9 < M < 1.3', 1, True, path=path)
208  # Again perform vertex fit and apply tighter mass window
209  if fitter == 'TreeFit':
210  vertex.treeFit('Lambda0:RD', conf_level=0.0, path=path)
211  elif fitter == 'KFit':
212  vertex.kFit('Lambda0:RD', conf_level=0.0, path=path)
213  elif fitter == 'Rave':
214  vertex.raveFit('Lambda0:RD', conf_level=0.0, path=path, silence_warning=True)
215  ma.applyCuts('Lambda0:RD', '1.10 < M < 1.13', path=path)
216  # Find RD duplicate with better vertex fit quality
217  ma.markDuplicate('Lambda0:RD', False, path=path)
218  ma.applyCuts('Lambda0:RD', 'extraInfo(highQualityVertex)', path=path)
219  ma.mergeListsWithBestDuplicate('Lambda0:merged', ['Lambda0:V0_MassWindow', 'Lambda0:RD'],
220  variable='particleSource', preferLowest=prioritiseV0, path=path)
def raveFit(list_name, conf_level, fit_type='vertex', decay_string='', constraint='', daughtersUpdate=False, path=None, silence_warning=False)
Definition: vertex.py:172
def kFit(list_name, conf_level, fit_type='vertex', constraint='', daughtersUpdate=False, decay_string='', massConstraint=[], recoilMass=0, smearing=0, path=None)
Definition: vertex.py:129
def treeFit(list_name, conf_level=0.001, massConstraint=[], ipConstraint=False, updateAllDaughters=False, customOriginConstraint=False, customOriginVertex=[0.001, 0, 0.0116], customOriginCovariance=[0.0048, 0, 0, 0, 0.003567, 0, 0, 0, 0.0400], originDimension=3, treatAsInvisible='', path=None)
Definition: vertex.py:238