Belle II Software  release-05-01-25
B2A404-Rave-VertexFit.py
1 #!/usr/bin/env python3
2 
3 
28 
29 import basf2 as b2
30 from modularAnalysis import inputMdst
31 from modularAnalysis import reconstructDecay
32 from modularAnalysis import matchMCTruth
33 from vertex import raveFit
34 from stdCharged import stdPi, stdK
35 from modularAnalysis import variablesToNtuple
36 import variables.collections as vc
37 import variables.utils as vu
38 
39 # create path
40 my_path = b2.create_path()
41 
42 # load input ROOT file
43 inputMdst(environmentType='default',
44  filename=b2.find_file('B02pi0D0_D2kpi_B2Dstarpi_Dstar2Dpi_D2kpi.root', 'examples', False),
45  path=my_path)
46 
47 
48 # use standard final state particle lists
49 #
50 # creates "pi+:all" ParticleList (and c.c.)
51 stdPi('all', path=my_path)
52 # creates "pi+:loose" ParticleList (and c.c.)
53 stdPi('loose', path=my_path)
54 # creates "K+:loose" ParticleList (and c.c.)
55 stdK('loose', path=my_path)
56 
57 # reconstruct D0 -> K- pi+ decay
58 # keep only candidates with 1.8 < M(Kpi) < 1.9 GeV
59 reconstructDecay('D0:kpi -> K-:loose pi+:loose', '1.8 < M < 1.9', path=my_path)
60 
61 # perform D0 vertex fit
62 # keep candidates only passing C.L. value of the fit > 0.0 (no cut)
63 raveFit('D0:kpi', 0.0, path=my_path)
64 
65 # reconstruct D*+ -> D0 pi+ decay
66 # keep only candidates with Q = M(D0pi) - M(D0) - M(pi) < 20 MeV
67 # and D* CMS momentum > 2.5 GeV
68 reconstructDecay('D*+ -> D0:kpi pi+:all',
69  '0.0 <= Q < 0.02 and 2.5 < useCMSFrame(p) < 5.5', path=my_path)
70 
71 # perform MC matching (MC truth association)
72 matchMCTruth('D*+', path=my_path)
73 
74 # perform D*+ kinematic vertex fit using the D0 and the pi+
75 # keep candidates only passing C.L. value of the fit > 0.0 (no cut)
76 raveFit('D*+', 0.0, path=my_path)
77 
78 # Select variables that we want to store to ntuple
79 
80 dstar_vars = vc.inv_mass + vc.mc_truth + \
81  vc.mc_flight_info + vc.flight_info
82 
83 fs_hadron_vars = vu.create_aliases_for_selected(
84  vc.pid + vc.track + vc.mc_truth,
85  'D*+ -> [D0 -> ^K- ^pi+] ^pi+')
86 
87 d0_vars = vu.create_aliases_for_selected(
88  vc.inv_mass + vc.mc_truth,
89  'D*+ -> ^D0 pi+', 'D0')
90 
91 
92 # Saving variables to ntuple
93 output_file = 'B2A404-Rave-VertexFit.root'
94 variablesToNtuple('D*+', dstar_vars + d0_vars + fs_hadron_vars,
95  filename=output_file, treename='dsttree', path=my_path)
96 
97 
98 # Process the events
99 b2.process(my_path)
100 
101 # print out the summary
102 print(b2.statistics)
variablesToNtuple
Definition: variablesToNtuple.py:1
variables.utils
Definition: utils.py:1
variables.collections
Definition: collections.py:1