Belle II Software  release-08-01-10
B2A411-HelixErrorScaler.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
30 
31 import basf2 as b2
32 import modularAnalysis as ma
33 from vertex import kFit
34 from stdCharged import stdMu
35 from stdV0s import stdKshorts, scaleErrorKshorts
36 import variables.collections as vc
37 import variables.utils as vu
38 
39 # create path
40 my_path = b2.create_path()
41 
42 # load input ROOT file
43 ma.inputMdst(filename=b2.find_file('B02JpsiKs_Jpsi2mumu_Ks2pipi.root', 'examples', False),
44  path=my_path)
45 
46 # load standard mu and K_S0 particle lists
47 stdMu('loose', path=my_path)
48 stdKshorts(path=my_path)
49 
50 # create a new list of mu and K_S0 with scaled error
51 ma.scaleError('mu+:scaled', 'mu+:loose', path=my_path)
52 scaleErrorKshorts(path=my_path)
53 
54 # reconstruct B0 -> J/psi K_S0 decay
55 ma.reconstructDecay('J/psi:default -> mu+:loose mu-:loose', '3.05 < M < 3.15', path=my_path)
56 ma.reconstructDecay('B0:default -> J/psi:default K_S0:merged', '5.27 < Mbc < 5.29 and abs(deltaE)<0.1', path=my_path)
57 ma.reconstructDecay('J/psi:scaled -> mu+:scaled mu-:scaled', '3.05 < M < 3.15', path=my_path)
58 ma.reconstructDecay('B0:scaled -> J/psi:scaled K_S0:scaled', '5.27 < Mbc < 5.29 and abs(deltaE)<0.1', path=my_path)
59 
60 # perform B0 vertex fit only using the muons
61 kFit('B0:default', 0., decay_string='B0 -> [J/psi -> ^mu+ ^mu-] K_S0', path=my_path)
62 kFit('B0:scaled', 0., decay_string='B0 -> [J/psi -> ^mu+ ^mu-] K_S0', path=my_path)
63 
64 # MC matching
65 ma.matchMCTruth('B0:default', path=my_path)
66 ma.matchMCTruth('B0:scaled', path=my_path)
67 
68 # select variables to be saved
69 B0_vars = vc.mc_truth + vc.vertex + vc.mc_vertex
70 B0_vars += ['LBoost', 'LBoostErr', 'mcLBoost']
71 helices = [a + b for a in ['d0', 'phi0', 'omega', 'z0', 'tanLambda'] for b in ['', 'Err', 'Pull']]
72 B0_vars += vu.create_aliases_for_selected(helices, 'B0 -> [J/psi -> ^mu+ ^mu-] [K_S0 -> ^pi+ ^pi-]')
73 B0_vars += vu.create_aliases_for_selected(['isFromV0'], 'B0 -> J/psi ^K_S0')
74 
75 # save variables
76 outputfile = 'scaleHelixError_output.root'
77 ma.variablesToNtuple('B0:default', B0_vars,
78  filename=outputfile, treename='B0_default', path=my_path)
79 ma.variablesToNtuple('B0:scaled', B0_vars,
80  filename=outputfile, treename='B0_scaled', path=my_path)
81 
82 # process the events
83 b2.process(my_path)
84 
85 # print out the summary
86 print(b2.statistics)