211 def preselection_cut(self, candidate, IP_cut: float = 250, show_table: bool = False) -> bool:
212 """
213 Umbrella method to apply the pre-selection cuts on the candidate.
214
215 show_table=True tabulates the pre-selection parameters.
216 """
217 flag = True
218
219 if len(self.tree.Particles) != 1:
220 flag = False
221 if not (self.is_in_fiducial(candidate)):
222 flag = False
223 if self.dist_to_innerwall(candidate) <= 5 * u.cm:
224 flag = False
225 if self.dist_to_vesselentrance(candidate) <= 100 * u.cm:
226 flag = False
227 if self.impact_parameter(candidate) >= IP_cut * u.cm:
228 flag = False
229 if self.DOCA(candidate) >= 1 * u.cm:
230 flag = False
231 if np.any(self.nDOF(candidate) <= 25):
232 flag = False
233 if np.any(self.chi2nDOF(candidate) >= 5):
234 flag = False
235 if np.any(self.daughtermomentum(candidate) <= 1 * u.GeV):
236 flag = False
237
238 if show_table:
239 table = [
240 [
241 "Number of candidates in event",
242 len(self.tree.Particles),
243 "==1",
244 len(self.tree.Particles) == 1,
245 ],
246 [
247 "Time @ decay vertex (ns)",
248 self.define_candidate_time(candidate),
249 "",
250 "",
251 ],
252 [
253 "Impact Parameter (cm)",
254 self.impact_parameter(candidate),
255 f"IP < {IP_cut * u.cm} cm",
256 self.impact_parameter(candidate) < IP_cut * u.cm,
257 ],
258 [
259 "DOCA (cm)",
260 self.DOCA(candidate),
261 "DOCA < 1 cm",
262 self.DOCA(candidate) < 1 * u.cm,
263 ],
264 [
265 "Is within Fiducial Volume?",
266 self.is_in_fiducial(candidate),
267 "True",
268 self.is_in_fiducial(candidate),
269 ],
270 [
271 "Dist2InnerWall (cm)",
272 self.dist_to_innerwall(candidate),
273 "> 5 cm",
274 self.dist_to_innerwall(candidate) > 5 * u.cm,
275 ],
276 [
277 "Dist2VesselEntrance (cm)",
278 self.dist_to_vesselentrance(candidate),
279 "> 100 cm",
280 self.dist_to_vesselentrance(candidate) > 100 * u.cm,
281 ],
282 ["Invariant Mass (GeV)", self.invariant_mass(candidate), "", ""],
283 [
284 "Daughter Momentum [d1, d2] (GeV)",
285 self.daughtermomentum(candidate),
286 "> 1 GeV",
287 np.all(self.daughtermomentum(candidate) > 1 * u.GeV),
288 ],
289 [
290 "Degrees of Freedom [d1, d2]",
291 self.nDOF(candidate),
292 "> 25",
293 np.all(self.nDOF(candidate) > 25),
294 ],
295 [
296 "Reduced Chi^2 [d1, d2]",
297 self.chi2nDOF(candidate),
298 "< 5",
299 np.all(self.chi2nDOF(candidate) < 5),
300 ],
301 ["\033[1mPre-selection passed:\033[0m", "", "", flag],
302 ]
303
304 for row in table:
305 row[3] = (
306 f"\033[1;32m{row[3]}\033[0m" if row[3] else f"\033[1;31m{row[3]}\033[0m"
307 )
308
309 print(
310 tabulate(
311 table,
312 headers=[
313 "Parameter",
314 "Value",
315 "Pre-selection cut",
316 "Pre-selection Check",
317 ],
318 tablefmt="grid",
319 )
320 )
321 return flag
322
323