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