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