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