Belle II Software  release-08-01-10
B2A303-MultipleDecays-Reconstruction.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
32 
33 import basf2 as b2
34 import modularAnalysis as ma
35 import variables.collections as vc
36 import variables.utils as vu
37 
38 # create path
39 my_path = b2.create_path()
40 
41 # load input ROOT file
42 ma.inputMdst(filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu.root', 'examples', False),
43  path=my_path)
44 
45 # create and fill final state ParticleLists
46 kaons = ('K-', '')
47 pions = ('pi-', '')
48 photons = ('gamma', '')
49 ma.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 ...
54 ma.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
59 ma.reconstructDecay(decayString='D0:ch1 -> K- pi+',
60  cut='1.8 < M < 1.9',
61  dmID=1,
62  path=my_path)
63 ma.reconstructDecay(decayString='D0:ch2 -> K- pi+ pi0',
64  cut='1.8 < M < 1.9',
65  dmID=2,
66  path=my_path)
67 ma.reconstructDecay(decayString='D0:ch3 -> K- pi+ pi+ pi-',
68  cut='1.8 < M < 1.9',
69  dmID=3,
70  path=my_path)
71 ma.reconstructDecay(decayString='D0:ch4 -> K- K+',
72  cut='1.8 < M < 1.9',
73  dmID=4,
74  path=my_path)
75 ma.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
81 ma.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
86 ma.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)
92 ma.matchMCTruth(list_name='B+:D0pi',
93  path=my_path)
94 
95 # Select variables that we want to store to ntuple
96 d_vars = vc.inv_mass + vc.kinematics
97 pi_vars = vc.kinematics
98 b_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
111 output_file = 'B2A303-MultipleDecays-Reconstruction.root'
112 ma.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
120 b2.process(my_path)
121 
122 # print out the summary
123 print(b2.statistics)