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