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