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