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