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