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