Belle II Software light-2406-ragdoll
B2A407-KFit-FourCFit.py
1#!/usr/bin/env python3
2
3
10
11
26
27
28#
29# Import and mdst loading
30#
31
32import basf2 as b2
33from modularAnalysis import inputMdst
34from modularAnalysis import fillParticleList
35from modularAnalysis import reconstructDecay
36from vertex import kFit
37from modularAnalysis import matchMCTruth
38from modularAnalysis import variablesToNtuple
39from stdPhotons import stdPhotons
40import variables.collections as vc
41import variables.utils as vu
42
43# create path
44my_path = b2.create_path()
45
46# load input ROOT file
47inputMdst(filename=b2.find_file('Y4SEventToetaY1S-evtgen_100.root', 'examples', False),
48 path=my_path)
49
50
51# Creates a list of good pions and kaons with some PID and IP cut
52stdPhotons('loose', path=my_path)
53fillParticleList('mu+:pid', 'muonID>0.1', path=my_path)
54
55
56# Reconstructs eta -> gamma gamma
57reconstructDecay("eta:gg -> gamma:loose gamma:loose", "", path=my_path)
58# Reconstructs Upsilon -> u+ u-
59reconstructDecay("Upsilon:uu -> mu+:pid mu-:pid", "M>2.", path=my_path)
60
61# Reconstructs Upsilon(4S) -> Upsilon eta
62reconstructDecay("Upsilon(4S) -> eta:gg Upsilon:uu", "", path=my_path)
63
64# Associates the MC truth to the reconstructed particles
65matchMCTruth('Upsilon(4S)', path=my_path)
66
67# Perform four momentum constraint fit using KFit.
68# Reject the candidates with failed fit.
69kFit("Upsilon(4S)", 0.0, 'fourC', path=my_path)
70
71# Perform four momentum constraint fit using KFit and update the Daughters
72# Reject the candidates with failed fit.
73# kFit("Upsilon(4S)", 0.0, 'fourC', daughtersUpdate=True, path=my_path)
74
75# Select variables that we want to store to ntuple
76muvars = vc.mc_truth + vc.pid + vc.kinematics
77gvars = vc.kinematics + vc.mc_truth
78etaanduvars = vc.inv_mass + vc.kinematics + vc.mc_truth
79u4svars = vc.inv_mass + vc.kinematics + vc.mc_truth + \
80 vu.create_aliases(['FourCFitProb', 'FourCFitChi2'], 'extraInfo({variable})', "") + \
81 vu.create_aliases_for_selected(etaanduvars, 'Upsilon(4S) -> ^eta ^Upsilon') + \
82 vu.create_aliases_for_selected(muvars, 'Upsilon(4S) -> eta [Upsilon -> ^mu+ ^mu-]') + \
83 vu.create_aliases_for_selected(gvars, 'Upsilon(4S) -> [eta -> ^gamma ^gamma] Upsilon')
84
85# Saving variables to ntuple
86output_file = 'B2A407-KFit-FourCFit.root'
87variablesToNtuple('Upsilon(4S)', u4svars,
88 filename=output_file, treename='Upsilon4s', path=my_path)
89
90#
91# Process and print statistics
92#
93
94# Process the events
95b2.process(my_path)
96# print out the summary
97print(b2.statistics)