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