Belle II Software development
B2A303-MultipleDecays-Reconstruction.py
1#!/usr/bin/env python3
2
3
10
11
32
33import basf2 as b2
34import modularAnalysis as ma
35import variables.collections as vc
36import variables.utils as vu
37
38# create path
39my_path = b2.create_path()
40
41# load input ROOT file
42ma.inputMdst(filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu.root', 'examples', False),
43 path=my_path)
44
45# create and fill final state ParticleLists
46kaons = ('K-', '')
47pions = ('pi-', '')
48photons = ('gamma', '')
49ma.fillParticleListsFromMC(decayStringsWithCuts=[kaons, pions, photons],
50 path=my_path)
51
52# 1. reconstruct pi0 -> gamma gamma decay
53# InvM is the sum of daughter momenta whereas M is the initialised PDG mass ...
54ma.reconstructDecay(decayString='pi0 -> gamma gamma',
55 cut='0.1 < InvM < 0.15',
56 path=my_path)
57
58# 2. reconstruct D0 in multiple decay modes
59ma.reconstructDecay(decayString='D0:ch1 -> K- pi+',
60 cut='1.8 < M < 1.9',
61 dmID=1,
62 path=my_path)
63ma.reconstructDecay(decayString='D0:ch2 -> K- pi+ pi0',
64 cut='1.8 < M < 1.9',
65 dmID=2,
66 path=my_path)
67ma.reconstructDecay(decayString='D0:ch3 -> K- pi+ pi+ pi-',
68 cut='1.8 < M < 1.9',
69 dmID=3,
70 path=my_path)
71ma.reconstructDecay(decayString='D0:ch4 -> K- K+',
72 cut='1.8 < M < 1.9',
73 dmID=4,
74 path=my_path)
75ma.reconstructDecay(decayString='D0:ch5 -> pi+ pi-',
76 cut='1.8 < M < 1.9',
77 dmID=5,
78 path=my_path)
79
80# merge the D0 lists together into one single list
81ma.copyLists(outputListName='D0:all',
82 inputListNames=['D0:ch1', 'D0:ch2', 'D0:ch3', 'D0:ch4', 'D0:ch5'],
83 path=my_path)
84
85# 3. reconstruct B+ -> anti-D0 pi+ decay
86ma.reconstructDecay(decayString='B+:D0pi -> anti-D0:all pi+',
87 cut='5.24 < Mbc < 5.29 and abs(deltaE) < 1.0',
88 dmID=1,
89 path=my_path)
90
91# perform MC matching (MC truth association)
92ma.matchMCTruth(list_name='B+:D0pi',
93 path=my_path)
94
95# Select variables that we want to store to ntuple
96d_vars = vc.inv_mass + vc.kinematics
97pi_vars = vc.kinematics
98b_vars = vc.deltae_mbc + \
99 vc.mc_truth + \
100 vu.create_aliases_for_selected(list_of_variables=d_vars,
101 decay_string='B+ -> ^anti-D0 pi+',
102 prefix='D0') + \
103 vu.create_aliases_for_selected(list_of_variables=pi_vars,
104 decay_string='B+ -> anti-D0 ^pi+',
105 prefix='pi') + \
106 vu.create_aliases(list_of_variables=['decayModeID'],
107 wrapper='daughter(0,extraInfo({variable}))',
108 prefix="")
109
110# Saving variables to ntuple
111output_file = 'B2A303-MultipleDecays-Reconstruction.root'
112ma.variablesToNtuple(decayString='B+:D0pi',
113 variables=b_vars,
114 filename=output_file,
115 treename='bp',
116 path=my_path)
117
118
119# Process the events
120b2.process(my_path)
121
122# print out the summary
123print(b2.statistics)