Belle II Software development
B2A406-Rave-DecayStringVertexFit.py
1#!/usr/bin/env python3
2
3
10
11
30
31import basf2 as b2
32from modularAnalysis import inputMdst
33from modularAnalysis import reconstructDecay
34from modularAnalysis import matchMCTruth
35from vertex import raveFit
36from stdCharged import stdPi, stdK
37from modularAnalysis import variablesToNtuple
38import variables.collections as vc
39import variables.utils as vu
40
41# create path
42my_path = b2.create_path()
43
44# load input ROOT file
45inputMdst(filename=b2.find_file('B02pi0D0_D2kpi_B2Dstarpi_Dstar2Dpi_D2kpi.root', 'examples', False),
46 path=my_path)
47
48# use standard final state particle lists
49#
50# creates "pi+:all" ParticleList (and c.c.)
51stdPi('all', path=my_path)
52# creates "pi+:loose" ParticleList (and c.c.)
53stdPi('loose', path=my_path)
54# creates "K+:loose" ParticleList (and c.c.)
55stdK('loose', path=my_path)
56
57# reconstruct D0 -> K- pi+ decay
58# keep only candidates with 1.8 < M(Kpi) < 1.9 GeV
59reconstructDecay('D0:kpi -> K-:loose pi+:loose', '1.8 < M < 1.9', path=my_path)
60reconstructDecay('D0:st -> K-:loose pi+:loose', '1.8 < M < 1.9', path=my_path)
61reconstructDecay('D0:du -> K-:loose pi+:loose', '1.8 < M < 1.9', path=my_path)
62
63# perform D0 vertex fit
64# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
65raveFit('D0:kpi', 0.0, fit_type='massvertex', path=my_path)
66
67# perform D0 single track fit (production vertex)
68# D0 vertex and covariance matrix must be defined
69raveFit('D0:st', 0.0, path=my_path)
70# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
71raveFit('D0:st', 0.0, decay_string='^D0 -> K- pi+', constraint='ipprofile', path=my_path)
72
73# perform D0 vertex fit updating daughters
74# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
75raveFit('D0:du', 0.0, daughtersUpdate=True, path=my_path)
76
77# reconstruct 3 times the D*+ -> D0 pi+ decay
78# keep only candidates with Q = M(D0pi) - M(D0) - M(pi) < 20 MeV
79# and D* CMS momentum > 2 GeV
80reconstructDecay('D*+:1 -> D0:kpi pi+:all',
81 '0.0 <= Q < 0.02 and 2 < useCMSFrame(p) < 5.5', path=my_path)
82reconstructDecay('D*+:2 -> D0:kpi pi+:all',
83 '0.0 <= Q < 0.02 and 2 < useCMSFrame(p) < 5.5', path=my_path)
84reconstructDecay('D*+:3 -> D0:kpi pi+:all',
85 '0.0 <= Q < 0.02 and 2 < useCMSFrame(p) < 5.5', path=my_path)
86
87# perform MC matching (MC truth association)
88matchMCTruth('D*+:1', path=my_path)
89matchMCTruth('D*+:2', path=my_path)
90matchMCTruth('D*+:3', path=my_path)
91
92# perform D*+ kinematic vertex fit using the D0 and the pi+
93# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
94raveFit('D*+:1', 0.0, path=my_path)
95
96# perform D*+ kinematic beam spot constrained vertex fit using the D0 and the pi+
97# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
98raveFit('D*+:2', 0.0, constraint='ipprofile', path=my_path)
99
100# perform D*+ kinematic beam spot constrained vertex fit using only the pi+
101# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
102raveFit('D*+:3', 0.0, decay_string='D*+ -> D0 ^pi+', constraint='ipprofile', path=my_path)
103
104# Select variables that we want to store to ntuple
105dstar_vars = vc.inv_mass + vc.mc_truth + \
106 vc.mc_flight_info + vc.flight_info + vc.vertex
107
108fs_hadron_vars = vu.create_aliases_for_selected(
109 vc.pid + vc.track + vc.mc_truth,
110 'D*+ -> [D0 -> ^K- ^pi+] ^pi+')
111
112d0_vars = vu.create_aliases_for_selected(
113 vc.inv_mass + vc.mc_truth + vc.vertex,
114 'D*+ -> ^D0 pi+', 'D0')
115
116dstt = vc.kinematics + vc.vertex + vc.mc_vertex + vc.flight_info + \
117 vu.create_aliases_for_selected(
118 vc.kinematics,
119 '^D0 -> ^K- ^pi+')
120
121dstu = vc.kinematics + vu.create_aliases_for_selected(
122 vc.kinematics,
123 '^D0 -> ^K- ^pi+')
124
125# Saving variables to ntuple
126output_file = 'B2A406-Rave-DecayStringVertexFit.root'
127variablesToNtuple('D*+:1', dstar_vars + d0_vars + fs_hadron_vars,
128 filename=output_file, treename='dsttree1', path=my_path)
129variablesToNtuple('D*+:2', dstar_vars + d0_vars + fs_hadron_vars,
130 filename=output_file, treename='dsttree2', path=my_path)
131variablesToNtuple('D*+:3', dstar_vars + d0_vars + fs_hadron_vars,
132 filename=output_file, treename='dsttree3', path=my_path)
133variablesToNtuple('D0:st', dstt,
134 filename=output_file, treename='d0tree1', path=my_path)
135variablesToNtuple('D0:du', dstu,
136 filename=output_file, treename='d0tree2', path=my_path)
137
138
139# Process the events
140b2.process(my_path)
141
142# print out the summary
143print(b2.statistics)