Belle II Software light-2406-ragdoll
B2A423-OrcaKinFit_4CFit.py
1#!/usr/bin/env python3
2
3
10
11
23
24
25#
26# Import and mdst loading
27#
28
29import basf2 as b2
30from modularAnalysis import inputMdst
31from modularAnalysis import fillParticleList
32from modularAnalysis import reconstructDecay
33from modularAnalysis import matchMCTruth
34from kinfit import fitKinematic4C
35from modularAnalysis import variablesToNtuple
36import variables.collections as vc
37import variables.utils as vu
38from stdPhotons import stdPhotons
39
40# create path
41mypath = b2.create_path()
42
43# load input ROOT file
44inputMdst(filename=b2.find_file('Y4SEventToetaY1S-evtgen_100.root', 'examples', False),
45 path=mypath)
46
47# Creates a list of good photon and mu
48stdPhotons('loose', path=mypath)
49fillParticleList('mu+:pid', 'chiProb > 0.001 and p > 1.0', path=mypath)
50
51# Reconstructs eta -> gamma gamma
52reconstructDecay("eta:gg -> gamma:loose gamma:loose", "", path=mypath)
53# Reconstructs Upsilon -> u+ u-
54reconstructDecay("Upsilon:uu -> mu+:pid mu-:pid", "M>2.", path=mypath)
55
56# Reconstructs Upsilon(4S) -> Upsilon eta
57reconstructDecay("Upsilon(4S) -> eta:gg Upsilon:uu", "", path=mypath)
58reconstructDecay("Upsilon(4S):4c -> eta:gg Upsilon:uu", "", path=mypath)
59
60# Associates the MC truth to the reconstructed Upsilon(4S)
61matchMCTruth('Upsilon(4S)', path=mypath)
62matchMCTruth('Upsilon(4S):4c', path=mypath)
63
64# Perform four momentum constraint fit using OrcaKinFit
65fitKinematic4C("Upsilon(4S):4c", path=mypath)
66
67# Select variables that we want to store to ntuple
68muvars = vc.mc_truth + vc.pid + vc.kinematics
69gvars = vc.kinematics + vc.mc_truth + vc.inv_mass
70etaanduvars = vc.inv_mass + vc.kinematics + vc.mc_truth
71u4svars = vc.inv_mass + vc.kinematics + vc.mc_truth +\
72 vu.create_aliases(['FourCFitProb', 'FourCFitChi2'], 'extraInfo({variable})', "") + \
73 vu.create_aliases_for_selected(etaanduvars, 'Upsilon(4S) -> ^eta ^Upsilon') + \
74 vu.create_aliases_for_selected(muvars, 'Upsilon(4S) -> eta [Upsilon -> ^mu+ ^mu-]') + \
75 vu.create_aliases_for_selected(gvars, 'Upsilon(4S) -> [eta -> ^gamma ^gamma] Upsilon')
76
77u4svars_4c = u4svars + ['OrcaKinFitProb', 'OrcaKinFitChi2', 'OrcaKinFitErrorCode']
78
79u4svars_def = u4svars + ['chiProb']
80
81
82# Saving variables to ntuple
83output_file = 'B2A423-Orcakinfit_4CFit.root'
84variablesToNtuple('Upsilon(4S)', u4svars_def,
85 filename=output_file, treename='Upsilon4s', path=mypath)
86variablesToNtuple('Upsilon(4S):4c', u4svars_4c,
87 filename=output_file, treename='Upsilon4s_4c', path=mypath)
88
89
90# Process the events
91b2.process(mypath)
92# print out the summary
93print(b2.statistics)