Belle II Software  release-08-01-10
B2A305-Btag+SingleMuon-Reconstruction.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
47 
48 import basf2 as b2
49 import modularAnalysis as ma
50 import variables.collections as vc
51 import variables.utils as vu
52 import stdCharged as stdc
53 from stdPi0s import stdPi0s
54 
55 # create path
56 my_path = b2.create_path()
57 
58 # load input ROOT file
59 ma.inputMdst(filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu.root', 'examples', False),
60  path=my_path)
61 
62 # create and fill final state ParticleLists
63 # use standard lists
64 # creates "pi+:loose" ParticleList (and c.c.)
65 stdc.stdPi(listtype='loose', path=my_path)
66 # creates "K+:loose" ParticleList (and c.c.)
67 stdc.stdK(listtype='loose', path=my_path)
68 # creates "mu+:loose" ParticleList (and c.c.)
69 stdc.stdMu(listtype='loose', path=my_path)
70 
71 # creates "pi0:eff40_May2020Fit" ParticleList
72 stdPi0s(listtype='eff40_May2020Fit',
73  path=my_path)
74 
75 # 1. reconstruct D0 in multiple decay modes
76 ma.reconstructDecay(decayString='D0:ch1 -> K-:loose pi+:loose',
77  cut='1.8 < M < 1.9',
78  dmID=1,
79  path=my_path)
80 ma.reconstructDecay(decayString='D0:ch2 -> K-:loose pi+:loose pi0:eff40_May2020Fit',
81  cut='1.8 < M < 1.9',
82  dmID=2,
83  path=my_path)
84 ma.reconstructDecay(decayString='D0:ch3 -> K-:loose pi+:loose pi+:loose pi-:loose',
85  cut='1.8 < M < 1.9',
86  dmID=3,
87  path=my_path)
88 ma.reconstructDecay(decayString='D0:ch4 -> K-:loose K+:loose',
89  cut='1.8 < M < 1.9',
90  dmID=4,
91  path=my_path)
92 ma.reconstructDecay(decayString='D0:ch5 -> pi-:loose pi+:loose',
93  cut='1.8 < M < 1.9',
94  dmID=5,
95  path=my_path)
96 
97 # merge the D0 lists together into one single list
98 ma.copyLists(outputListName='D0:all',
99  inputListNames=['D0:ch1', 'D0:ch2', 'D0:ch3', 'D0:ch4', 'D0:ch5'],
100  path=my_path)
101 
102 # 2. reconstruct Btag+ -> anti-D0 pi+
103 ma.reconstructDecay(decayString='B+:tag -> anti-D0:all pi+:loose',
104  cut='5.2 < Mbc < 5.29 and abs(deltaE) < 1.0',
105  dmID=1,
106  path=my_path)
107 
108 ma.matchMCTruth(list_name='B+:tag',
109  path=my_path)
110 
111 # 3. reconstruct Upsilon(4S) -> Btag+ Bsig- -> Btag+ mu-
112 ma.reconstructDecay(decayString='Upsilon(4S) -> B-:tag mu+:loose',
113  cut="",
114  path=my_path)
115 
116 # perform MC matching (MC truth association)
117 ma.matchMCTruth(list_name='Upsilon(4S)',
118  path=my_path)
119 
120 # 5. build rest of the event
121 ma.buildRestOfEvent(target_list_name='Upsilon(4S)',
122  path=my_path)
123 
124 # 6. Reconstruct neutrino using missing momentum of the event
125 ma.fillParticleListFromROE('nu_mu:missing -> Upsilon(4S)', '', '',
126  useMissing=True, path=my_path)
127 
128 # 6. Select variables that we want to store to ntuple
129 d_vars = vc.mc_truth + vc.kinematics + vc.inv_mass
130 b_vars = vc.mc_truth + \
131  vc.deltae_mbc + \
132  vu.create_aliases_for_selected(list_of_variables=d_vars,
133  decay_string='B- -> ^D0 pi-') + \
134  vu.create_aliases(list_of_variables=['decayModeID'],
135  wrapper='daughter(0,extraInfo({variable}))',
136  prefix="D")
137 mu_vars = vc.mc_truth
138 nu_vars = d_vars
139 
140 u4s_vars = vc.mc_truth + \
141  vc.roe_multiplicities + \
142  vc.recoil_kinematics + \
143  vc.kinematics + \
144  vu.create_aliases_for_selected(list_of_variables=b_vars,
145  decay_string='Upsilon(4S) -> ^B- mu+') + \
146  vu.create_aliases_for_selected(list_of_variables=mu_vars,
147  decay_string='Upsilon(4S) -> B- ^mu+')
148 
149 
150 # 7. Saving variables to ntuple
151 rootOutputFile = 'B2A305-Btag+SingleMuon-Reconstruction.root'
152 ma.variablesToNtuple(decayString='nu_mu:missing',
153  variables=nu_vars,
154  filename=rootOutputFile,
155  treename='neutrino',
156  path=my_path)
157 ma.variablesToNtuple(decayString='B-:tag',
158  variables=b_vars,
159  filename=rootOutputFile,
160  treename='btag',
161  path=my_path)
162 ma.variablesToNtuple(decayString='Upsilon(4S)',
163  variables=u4s_vars,
164  filename=rootOutputFile,
165  treename='btagbsig',
166  path=my_path)
167 
168 
169 # Process the events
170 b2.process(my_path)
171 
172 # print out the summary
173 print(b2.statistics)