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