Belle II Software light-2406-ragdoll
B2A301-Dstar2D0Pi-Reconstruction.py
1#!/usr/bin/env python3
2
3
10
11
23
24import basf2 as b2
25import modularAnalysis as ma
26import variables.collections as vc
27import variables.utils as vu
28import stdCharged as stdc
29
30# create path
31my_path = b2.create_path()
32
33# load input ROOT file
34ma.inputMdst(filename=b2.find_file('Dst2D0pi.root', 'examples', False),
35 path=my_path)
36
37
38# use standard final state particle lists
39#
40# creates "pi+:all" ParticleList (and c.c.)
41stdc.stdPi(listtype='all', path=my_path)
42# creates "pi+:loose" ParticleList (and c.c.)
43stdc.stdPi(listtype='loose', path=my_path)
44# creates "K+:loose" ParticleList (and c.c.)
45stdc.stdK(listtype='loose', path=my_path)
46
47# reconstruct D0 -> K- pi+ decay
48# keep only candidates with 1.8 < M(Kpi) < 1.9 GeV
49ma.reconstructDecay(decayString='D0:kpi -> K-:loose pi+:loose', cut='1.8 < M < 1.9', path=my_path)
50
51# reconstruct D*+ -> D0 pi+ decay
52# keep only candidates with Q = M(D0pi) - M(D0) - M(pi) < 20 MeV
53ma.reconstructDecay(decayString='D*+ -> D0:kpi pi+:all', cut='0.0 < Q < 0.2', path=my_path)
54
55# perform MC matching (MC truth association)
56ma.matchMCTruth(list_name='D*+', path=my_path)
57
58# Select variables that we want to store to ntuple
59dstar_vars = vc.inv_mass + vc.mc_truth
60
61# We now want to select variables for all of the final state hadrons in the
62# decay products, that is, the K- and the two pi+.
63# You already know how to define these variables with the help of the
64# ``daughter`` metavariable: If we consider D^* -> D0 pi+, then we could access
65# information about the pion as daughter(1, variable).
66# Creating aliases for all of these variables would fill the next 100 lines
67# though, so we instead use the ``create_aliases_for_selected`` helper function:
68# We specify a list of variables and then a decay string, with particles
69# selected with a leading ``^``.
70# Again, for more information on how to create aliases, head over to
71# VariableManager/variableAliases.py.
72fs_hadron_vars = vu.create_aliases_for_selected(
73 list_of_variables=vc.pid + vc.track + vc.mc_truth,
74 decay_string='D*+ -> [D0 -> ^K- ^pi+] ^pi+')
75
76d0_vars = vu.create_aliases_for_selected(
77 list_of_variables=vc.inv_mass + vc.mc_truth,
78 decay_string='D*+ -> ^D0 pi+',
79 prefix='D0')
80
81
82# Saving variables to ntuple
83output_file = 'B2A301-Dstar2D0Pi-Reconstruction.root'
84ma.variablesToNtuple('D*+', dstar_vars + d0_vars + fs_hadron_vars,
85 filename=output_file, treename='dsttree', path=my_path)
86
87# Process the events
88b2.process(my_path)
89
90# print out the summary
91print(b2.statistics)