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