Belle II Software light-2406-ragdoll
B2A404-Rave-VertexFit.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
49# use standard final state particle lists
50#
51# creates "pi+:all" ParticleList (and c.c.)
52stdPi('all', path=my_path)
53# creates "pi+:loose" ParticleList (and c.c.)
54stdPi('loose', path=my_path)
55# creates "K+:loose" ParticleList (and c.c.)
56stdK('loose', path=my_path)
57
58# reconstruct D0 -> K- pi+ decay
59# keep only candidates with 1.8 < M(Kpi) < 1.9 GeV
60reconstructDecay('D0:kpi -> 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)
64raveFit('D0:kpi', 0.0, path=my_path)
65
66# reconstruct D*+ -> D0 pi+ decay
67# keep only candidates with Q = M(D0pi) - M(D0) - M(pi) < 20 MeV
68# and D* CMS momentum > 2.5 GeV
69reconstructDecay('D*+ -> D0:kpi pi+:all',
70 '0.0 <= Q < 0.02 and 2.5 < useCMSFrame(p) < 5.5', path=my_path)
71
72# perform MC matching (MC truth association)
73matchMCTruth('D*+', path=my_path)
74
75# perform D*+ kinematic vertex fit using the D0 and the pi+
76# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
77raveFit('D*+', 0.0, path=my_path)
78
79# Select variables that we want to store to ntuple
80
81dstar_vars = vc.inv_mass + vc.mc_truth + \
82 vc.mc_flight_info + vc.flight_info
83
84fs_hadron_vars = vu.create_aliases_for_selected(
85 vc.pid + vc.track + vc.mc_truth,
86 'D*+ -> [D0 -> ^K- ^pi+] ^pi+')
87
88d0_vars = vu.create_aliases_for_selected(
89 vc.inv_mass + vc.mc_truth,
90 'D*+ -> ^D0 pi+', 'D0')
91
92
93# Saving variables to ntuple
94output_file = 'B2A404-Rave-VertexFit.root'
95variablesToNtuple('D*+', dstar_vars + d0_vars + fs_hadron_vars,
96 filename=output_file, treename='dsttree', path=my_path)
97
98
99# Process the events
100b2.process(my_path)
101
102# print out the summary
103print(b2.statistics)