29 from array
import array
30 import matplotlib.pyplot
as plt
31 from defaultEvaluationParameters
import r_size, r_subsample, rbins
34 import matplotlib
as mpl
36 mpl.rcParams[
'text.usetex'] =
True
41 workingFilesMC = str(sys.argv[1])
42 workingFilesData = str(sys.argv[2])
44 workingFilesMC = glob.glob(str(workingFilesMC))
45 workingFilesData = glob.glob(str(workingFilesData))
51 treenames = [str(sys.argv[3])]
53 mc_total_notTagged = 0
55 data_total_notTagged = 0
59 ROOT.RooMsgService.instance().setGlobalKillBelow(ROOT.RooFit.WARNING)
62 def efficiencyCalculator(mc, data, method):
66 mc_dataB0 = mc[np.where(mc[:, 1] > 0)]
67 mc_dataB0bar = mc[np.where(mc[:, 1] < 0)]
69 mc_totaldataB0 = np.absolute(mc_dataB0[:, 0])
70 mc_totaldataB0bar = np.absolute(mc_dataB0bar[:, 0])
72 mc_rvalueB0 = (np.histogram(mc_totaldataB0, rbins, weights=mc_totaldataB0)[0] / np.histogram(mc_totaldataB0, rbins)[0])
77 weights=mc_totaldataB0 *
82 mc_rvalueStdB0 = np.sqrt(abs(mc_rvalueMSB0 - mc_rvalueB0 * mc_rvalueB0))
83 mc_entriesB0 = np.histogram(mc_totaldataB0, rbins)[0]
89 weights=mc_totaldataB0bar)[0] /
97 weights=mc_totaldataB0bar *
98 mc_totaldataB0bar)[0] /
102 mc_rvalueStdB0bar = np.sqrt(abs(mc_rvalueMSB0bar - mc_rvalueB0bar * mc_rvalueB0bar))
103 mc_entriesB0bar = np.histogram(mc_totaldataB0bar, rbins)[0]
105 mc_total_entriesB0 = mc_totaldataB0.shape[0] + mc_total_notTagged / 2
106 mc_total_tagged_B0 = mc_totaldataB0.shape[0]
107 mc_event_fractionB0 = mc_entriesB0.astype(float) / mc_total_entriesB0
109 mc_total_entriesB0bar = mc_totaldataB0bar.shape[0] + mc_total_notTagged / 2
110 mc_total_tagged_B0bar = mc_totaldataB0bar.shape[0]
111 mc_event_fractionB0bar = mc_entriesB0bar.astype(float) / mc_total_entriesB0bar
113 mc_total_entries = mc_total_entriesB0 + mc_total_entriesB0bar
114 mc_total_tagged = mc_totaldataB0.shape[0] + mc_totaldataB0bar.shape[0]
115 mc_event_fractionTotal = (mc_entriesB0.astype(float) + mc_entriesB0bar.astype(float)) / mc_total_entries
117 mc_tagging_eff = mc_total_tagged / (mc_total_tagged + mc_total_notTagged)
118 mc_DeltaTagging_eff = math.sqrt(mc_total_tagged * mc_total_notTagged**2 +
119 mc_total_notTagged * mc_total_tagged**2) / (mc_total_entries**2)
121 mc_tot_eff_effB0bar = 0
122 mc_uncertainty_eff_effB0 = 0
123 mc_uncertainty_eff_effB0bar = 0
124 mc_uncertainty_eff_effAverage = 0
125 mc_diff_eff_Uncertainty = 0
126 mc_event_fractionDiff = array(
'f', [0] * r_size)
127 mc_rvalueB0Average = array(
'f', [0] * r_size)
128 mc_rvalueStdB0Average = array(
'f', [0] * r_size)
129 mc_wvalue = array(
'f', [0] * r_size)
130 mc_wvalueUncertainty = array(
'f', [0] * r_size)
131 mc_wvalueB0 = array(
'f', [0] * r_size)
132 mc_wvalueB0bar = array(
'f', [0] * r_size)
133 mc_wvalueDiff = array(
'f', [0] * r_size)
134 mc_wvalueDiffUncertainty = array(
'f', [0] * r_size)
135 mc_iEffEfficiency = array(
'f', [0] * r_size)
136 mc_iEffEfficiencyUncertainty = array(
'f', [0] * r_size)
137 mc_iEffEfficiencyB0Uncertainty = array(
'f', [0] * r_size)
138 mc_iEffEfficiencyB0barUncertainty = array(
'f', [0] * r_size)
139 mc_iDeltaEffEfficiency = array(
'f', [0] * r_size)
140 mc_iDeltaEffEfficiencyUncertainty = array(
'f', [0] * r_size)
142 print(
'****************** MEASURED EFFECTIVE EFFICIENCY FOR COMBINER USING ' + method +
' ***************************')
144 print(
'* --> DETERMINATION BASED ON MONTE CARLO *')
146 print(
'* ------------------------------------------------------------------------------------------------ *')
147 print(
'* r-interval <r> Efficiency Delta_Effcy w Delta_w *')
148 print(
'* ------------------------------------------------------------------------------------------------ *')
150 for i
in range(0, r_size - 1):
151 mc_rvalueB0Average[i] = (mc_rvalueB0[i] + mc_rvalueB0bar[i]) / 2
152 mc_rvalueStdB0Average[i] = math.sqrt(mc_rvalueStdB0[i]**2 / (mc_entriesB0[0] - 1) +
153 mc_rvalueStdB0bar[i]**2 / (mc_entriesB0bar[0] - 1)) / 2
154 mc_wvalueB0[i] = (1 - mc_rvalueB0[i]) / 2
155 mc_wvalueB0bar[i] = (1 - mc_rvalueB0bar[i]) / 2
156 mc_wvalueDiff[i] = mc_wvalueB0[i] - mc_wvalueB0bar[i]
157 mc_wvalueDiffUncertainty[i] = math.sqrt((mc_rvalueStdB0[i] / 2)**2 / (mc_entriesB0[0] - 1) +
158 (mc_rvalueStdB0bar[i] / 2)**2 / (mc_entriesB0bar[0] - 1))
159 mc_wvalue[i] = (mc_wvalueB0[i] + mc_wvalueB0bar[i]) / 2
160 mc_wvalueUncertainty[i] = mc_wvalueDiffUncertainty[i] / 2
163 mc_event_fractionDiff[i] = (mc_entriesB0[i] - mc_entriesB0bar[i]) / mc_total_entries
165 mc_iEffEfficiency[i] = mc_tagging_eff * (mc_event_fractionB0[i] * mc_rvalueB0[i] * mc_rvalueB0[i] +
166 mc_event_fractionB0bar[i] * mc_rvalueB0bar[i] * mc_rvalueB0bar[i]) / 2
168 mc_iEffEfficiencyB0Uncertainty[i] = mc_rvalueB0[i] * \
169 math.sqrt((2 * mc_total_entriesB0 * mc_entriesB0[i] * mc_rvalueStdB0[i])**2 / (mc_entriesB0[0] - 1) +
170 mc_rvalueB0[i]**2 * mc_entriesB0[i] *
171 (mc_total_entriesB0 * (mc_total_entriesB0 - mc_entriesB0[i]) +
172 mc_entriesB0[i] * mc_total_notTagged)) / (mc_total_entriesB0**2)
173 mc_iEffEfficiencyB0barUncertainty[i] = mc_rvalueB0bar[i] * \
174 math.sqrt((2 * mc_total_entriesB0bar * mc_entriesB0bar[i] * mc_rvalueStdB0bar[i])**2 / (mc_entriesB0bar[0] - 1) +
175 mc_rvalueB0bar[i]**2 * mc_entriesB0bar[i] *
176 (mc_total_entriesB0bar * (mc_total_entriesB0bar - mc_entriesB0bar[i]) +
177 mc_entriesB0bar[i] * mc_total_notTagged)) / (mc_total_entriesB0bar**2)
179 mc_iDeltaEffEfficiency[i] = mc_event_fractionB0[i] * mc_rvalueB0[i] * \
180 mc_rvalueB0[i] - mc_event_fractionB0bar[i] * mc_rvalueB0bar[i] * mc_rvalueB0bar[i]
182 mc_iDeltaEffEfficiencyUncertainty[i] = math.sqrt(
183 mc_iEffEfficiencyB0Uncertainty[i]**2 +
184 mc_iEffEfficiencyB0barUncertainty[i]**2)
186 mc_iEffEfficiencyUncertainty[i] = mc_iDeltaEffEfficiencyUncertainty[i] / 2
188 mc_diff_eff_Uncertainty = mc_diff_eff_Uncertainty + mc_iDeltaEffEfficiencyUncertainty[i]**2
191 mc_tot_eff_effB0 = mc_tot_eff_effB0 + mc_event_fractionB0[i] * mc_rvalueB0[i] * mc_rvalueB0[i]
192 mc_tot_eff_effB0bar = mc_tot_eff_effB0bar + mc_event_fractionB0bar[i] * mc_rvalueB0bar[i] * mc_rvalueB0bar[i]
193 mc_uncertainty_eff_effAverage = mc_uncertainty_eff_effAverage + mc_iEffEfficiencyUncertainty[i]**2
194 mc_uncertainty_eff_effB0 = mc_uncertainty_eff_effB0 + mc_iEffEfficiencyB0Uncertainty[i]**2
195 mc_uncertainty_eff_effB0bar = mc_uncertainty_eff_effB0bar + mc_iEffEfficiencyB0barUncertainty[i]**2
198 print(
'* ' +
'{:.3f}'.format(r_subsample[i]) +
' - ' +
'{:.3f}'.format(r_subsample[i + 1]) +
' ' +
199 '{:.3f}'.format(mc_rvalueB0Average[i]) +
' +- ' +
'{:.4f}'.format(mc_rvalueStdB0Average[i]) +
' ' +
200 '{:.4f}'.format(mc_event_fractionTotal[i]) +
' ' +
201 '{: .4f}'.format(mc_event_fractionDiff[i]) +
' ' +
202 '{:.4f}'.format(mc_wvalue[i]) +
' +- ' +
'{:.4f}'.format(mc_wvalueUncertainty[i]) +
' ' +
203 '{: .4f}'.format(mc_wvalueDiff[i]) +
' +- ' +
'{:.4f}'.format(mc_wvalueDiffUncertainty[i]) +
' *')
205 mc_average_eff_eff = (mc_tot_eff_effB0 + mc_tot_eff_effB0bar) / 2
206 mc_uncertainty_eff_effAverage = math.sqrt(mc_uncertainty_eff_effAverage)
207 mc_uncertainty_eff_effB0 = math.sqrt(mc_uncertainty_eff_effB0)
208 mc_uncertainty_eff_effB0bar = math.sqrt(mc_uncertainty_eff_effB0bar)
209 mc_diff_eff = mc_tot_eff_effB0 - mc_tot_eff_effB0bar
210 mc_diff_eff_Uncertainty = math.sqrt(mc_diff_eff_Uncertainty)
212 print(
'* ------------------------------------------------------------------------------------------------ *')
214 print(
'* __________________________________________________________________________________________ *')
216 print(
'* | TOTAL NUMBER OF TAGGED EVENTS = ' +
217 '{:<24}'.format(
"%.0f" % mc_total_tagged) +
'{:>36}'.format(
'| *'))
220 '* | TOTAL AVERAGE EFFICIENCY (q=+-1)= ' +
226 mc_DeltaTagging_eff *
231 '* | TOTAL AVERAGE EFFECTIVE EFFICIENCY (q=+-1)= ' +
237 mc_uncertainty_eff_effAverage *
242 '* | TOTAL AVERAGE EFFECTIVE EFFICIENCY ASYMMETRY (q=+-1)= ' +
248 mc_diff_eff_Uncertainty *
252 print(
'* | B0-TAGGER TOTAL EFFECTIVE EFFICIENCIES: ' +
253 '{:.2f}'.format(mc_tot_eff_effB0 * 100) +
" +-" +
'{: 4.2f}'.format(mc_uncertainty_eff_effB0 * 100) +
255 '{:.2f}'.format(mc_tot_eff_effB0bar * 100) +
" +-" +
'{: 4.2f}'.format(mc_uncertainty_eff_effB0bar * 100) +
256 ' % (q=-1) ' +
' | *')
258 print(
'* | FLAVOR PERCENTAGE (MC): ' +
259 '{:.2f}'.format(mc_total_tagged_B0 / mc_total_tagged * 100) +
' % (q=+1) ' +
260 '{:.2f}'.format(mc_total_tagged_B0bar / mc_total_tagged * 100) +
' % (q=-1) Diff=' +
261 '{:^5.2f}'.format((mc_total_tagged_B0 - mc_total_tagged_B0bar) / mc_total_tagged * 100) +
' % | *')
262 print(
'* |__________________________________________________________________________________________| *')
264 print(
'****************************************************************************************************')
266 print(
r'\begin{tabular}{ l r r r r r r r }')
268 print(
r'$r$- Interval & $\varepsilon_i\ $ & $w_i \pm \delta w_i\enskip\, $ ' +
269 r' & $\Delta w_i \pm \delta\Delta w_i $& $\varepsilon_{\text{eff}, i} \pm \delta\varepsilon_{\text{eff}, i}\enskip$ ' +
270 r' & & & $\Delta \varepsilon_{\text{eff}, i} \pm \delta\Delta \varepsilon_{\text{eff}, i} $\\ \hline\hline')
271 for i
in range(0, r_size - 1):
272 print(
'$ ' +
'{:.3f}'.format(r_subsample[i]) +
' - ' +
'{:.3f}'.format(r_subsample[i + 1]) +
'$ & $'
273 '{: 6.1f}'.format(mc_event_fractionTotal[i] * 100) +
'$ & $' +
274 '{: 7.3f}'.format(mc_wvalue[i] * 100) +
r" \pm " +
'{:2.3f}'.format(mc_wvalueUncertainty[i] * 100) +
r' $ & $' +
275 '{: 6.1f}'.format(mc_wvalueDiff[i] * 100) +
r" \pm " +
276 '{:2.3f}'.format(mc_wvalueDiffUncertainty[i] * 100) +
r'\, $ & $' +
277 '{: 8.4f}'.format(mc_iEffEfficiency[i] * 100) +
278 r" \pm " +
'{:2.4f}'.format(mc_iEffEfficiencyUncertainty[i] * 100) +
r'\, $ & & & $' +
279 '{: 6.4f}'.format(mc_iDeltaEffEfficiency[i] * 100) +
280 r" \pm " +
'{:2.4f}'.format(mc_iDeltaEffEfficiencyUncertainty[i] * 100) +
282 print(
r'\hline\hline')
284 r'\multicolumn{1}{r}{Total} & & \multicolumn{3}{r}{ $\varepsilon_\text{eff} = ' +
285 r'\sum_i \varepsilon_i \cdot \langle 1-2w_i\rangle^2 = ' +
291 mc_uncertainty_eff_effAverage *
294 print(
r'& & \multicolumn{2}{r}{ $\Delta \varepsilon_\text{eff} = ' +
295 '{: 6.2f}'.format(mc_diff_eff * 100) +
r" \pm " +
'{: 6.2f}'.format(mc_diff_eff_Uncertainty * 100) +
r'\ \quad\, $ }' +
298 print(
r'\end{tabular}')
302 data_totaldata = np.absolute(data[:, 0])
303 data_splotWeights = data[:, 1]
305 data_entries = np.histogram(data_totaldata, rbins, weights=data_splotWeights)[0]
306 data_rvalueB0Average = (np.histogram(data_totaldata, rbins, weights=data_totaldata * data_splotWeights)[0] / data_entries)
307 data_rvalueMSB0Average = (
311 weights=(data_totaldata)**2 *
312 data_splotWeights)[0] /
314 data_rvalueStdB0Average = np.sqrt(abs(data_rvalueMSB0Average - data_rvalueB0Average * data_rvalueB0Average))
316 data_total_tagged = 0
317 for iEntries
in data_entries:
318 data_total_tagged += iEntries
320 data_total_notTaggedWeighted = data_total_notTagged * data_total_tagged / data_totaldata.shape[0]
322 data_total_entries = data_total_tagged + data_total_notTaggedWeighted
323 data_event_fractionTotal = data_entries.astype(float) / data_total_entries
325 data_tagging_eff = data_total_tagged / data_total_entries
326 data_DeltaTagging_eff = math.sqrt(data_total_tagged * data_total_notTaggedWeighted**2 +
327 data_total_notTaggedWeighted * data_total_tagged**2) / (data_total_entries**2)
328 data_average_eff_eff = 0
329 data_uncertainty_eff_effAverage = 0
330 data_wvalue = array(
'f', [0] * r_size)
331 data_wvalueUncertainty = array(
'f', [0] * r_size)
332 data_iEffEfficiency = array(
'f', [0] * r_size)
333 data_iEffEfficiencyUncertainty = array(
'f', [0] * r_size)
335 print(
'****************** MEASURED EFFECTIVE EFFICIENCY FOR COMBINER USING ' + method +
' ***************************')
337 print(
'* --> DETERMINATION BASED ON DATA *')
339 print(
'* ------------------------------------------------------------------------------------------------ *')
340 print(
'* r-interval <r> Efficiency w *')
341 print(
'* ------------------------------------------------------------------------------------------------ *')
343 for i
in range(0, r_size - 1):
344 data_wvalue[i] = (1 - data_rvalueB0Average[i]) / 2
345 data_wvalueUncertainty[i] = (data_rvalueStdB0Average[i] / math.sqrt(data_entries[i] - 1)) / 2
348 data_iEffEfficiency[i] = data_tagging_eff * (data_event_fractionTotal[i] *
349 data_rvalueB0Average[i] * data_rvalueB0Average[i])
351 data_iEffEfficiencyUncertainty[i] = data_rvalueB0Average[i] * \
352 math.sqrt((2 * data_total_entries * data_entries[i] *
353 (data_rvalueStdB0Average[i] / math.sqrt(data_entries[i] - 1)))**2 +
354 data_rvalueB0Average[i]**2 * data_entries[i] *
355 (data_total_entries * (data_total_entries - data_entries[i]) +
356 data_entries[i] * data_total_notTaggedWeighted)) / (data_total_entries**2)
359 data_average_eff_eff = data_average_eff_eff + \
360 data_event_fractionTotal[i] * data_rvalueB0Average[i] * data_rvalueB0Average[i]
361 data_uncertainty_eff_effAverage = data_uncertainty_eff_effAverage + data_iEffEfficiencyUncertainty[i]**2
364 print(
'* ' +
'{:.3f}'.format(r_subsample[i]) +
' - ' +
'{:.3f}'.format(r_subsample[i + 1]) +
' ' +
365 '{:.3f}'.format(data_rvalueB0Average[i]) +
' +- ' +
'{:.4f}'.format(data_rvalueStdB0Average[i]) +
' ' +
366 '{:.4f}'.format(data_event_fractionTotal[i]) +
' ' +
367 '{:.4f}'.format(data_wvalue[i]) +
' +- ' +
'{:.4f}'.format(data_wvalueUncertainty[i]) +
' ' +
' *')
369 data_uncertainty_eff_effAverage = math.sqrt(data_uncertainty_eff_effAverage)
371 print(
'* ------------------------------------------------------------------------------------------------ *')
373 print(
'* __________________________________________________________________________________________ *')
375 print(
'* | TOTAL NUMBER OF TAGGED EVENTS = ' +
376 '{:<24}'.format(
"%.0f" % data_total_tagged) +
'{:>36}'.format(
'| *'))
379 '* | TOTAL AVERAGE EFFICIENCY (q=+-1)= ' +
385 data_DeltaTagging_eff *
390 '* | TOTAL AVERAGE EFFECTIVE EFFICIENCY (q=+-1)= ' +
392 data_average_eff_eff *
396 data_uncertainty_eff_effAverage *
399 print(
'* |__________________________________________________________________________________________| *')
401 print(
'****************************************************************************************************')
403 print(
r'\begin{tabular}{ l r r r r}')
405 print(
r'$r$- Interval & $\varepsilon_i\ $ & $w_i \pm \delta w_i\ $ ' +
406 r' & $\varepsilon_{\text{eff}, i} \pm \delta\varepsilon_{\text{eff}, i}$ ' +
408 for i
in range(0, len(rbins) - 1):
409 print(
'$ ' +
'{:.3f}'.format(r_subsample[i]) +
' - ' +
'{:.3f}'.format(r_subsample[i + 1]) +
'$ & $'
410 '{: 6.2f}'.format(data_event_fractionTotal[i] * 100) +
'$ & $' +
411 '{: 6.2f}'.format(data_wvalue[i] * 100) +
r" \pm " +
'{:2.2f}'.format(data_wvalueUncertainty[i] * 100) +
r'\, $ & $' +
412 '{: 7.3f}'.format(data_iEffEfficiency[i] * 100) +
413 r" \pm " +
'{:4.3f}'.format(data_iEffEfficiencyUncertainty[i] * 100) +
r'\, $ \\ ')
414 print(
r'\hline\hline')
416 r'\multicolumn{1}{r}{Total} & \multicolumn{3}{r}{ $\varepsilon_\text{eff} = ' +
417 r'\sum_i \varepsilon_i \cdot \langle 1-2w_i\rangle^2 = ' +
419 data_average_eff_eff *
423 data_uncertainty_eff_effAverage *
428 print(
r'\end{tabular}')
433 bins = list(range(-25, 26, 1))
434 for i
in range(0, len(bins)):
435 bins[i] = float(bins[i]) / 25
438 fig1 = plt.figure(1, figsize=(11, 8))
439 ax1 = plt.axes([0.21, 0.15, 0.76, 0.8])
441 qrDataPoints, qrDataBins = np.histogram(data[:, 0], bins=bins, weights=data_splotWeights)
442 qrDataPointsStd = np.sqrt(qrDataPoints)
444 qrDataPointsNorm, qrDataBins = np.histogram(data[:, 0], bins=bins, weights=data_splotWeights, density=1)
445 qrDataPointsStdNorm = qrDataPointsStd * qrDataPointsNorm / qrDataPoints
447 qrBincenters = 0.5 * (qrDataBins[1:] + qrDataBins[:-1])
449 p3 = ax1.errorbar(qrBincenters, qrDataPointsNorm, xerr=0.02, yerr=qrDataPointsStdNorm, elinewidth=2, mew=2, ecolor=
'k',
450 fmt=
'o', mfc=
'k', markersize=6, label=
r'${\rm Data}$')
452 ax1.hist(mc[:, 0], bins=bins, density=1, histtype=
'step',
453 edgecolor=
'b', linewidth=4, linestyle=
'dashed', label=
r'${\rm MC}$')
455 p2, = ax1.plot([], label=
r'${\rm MC}$', linewidth=4, linestyle=
'dashed', c=
'b')
461 ax1.set_ylabel(
r'${\rm Fraction\ \ of\ \ Events\ /\ (\, 0.04\, )}$', fontsize=35)
462 ax1.set_xlabel(
r'$(q\cdot r)_{\rm ' + methodLabel +
'}$', fontsize=35)
463 plt.xticks([-1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1],
464 [
r'$-1$',
r'',
r'$-0.5$',
r'',
r'$0$',
r'',
r'$0.5$',
r'',
r'$1$'], rotation=0, size=40)
465 ax1.tick_params(axis=
'y', labelsize=35)
466 ax1.legend([p3, p2], [
r'${\rm Data}$',
r'${\rm MC}$'], prop={
'size': 35}, loc=0, numpoints=1)
469 if qrDataPointsNorm[np.argmax(qrDataPointsNorm)] < 1.4:
472 ax1.set_xlim(-1.005, 1.005)
473 plt.savefig(PATH +
'/QR_B0_B0bar' + methodLabel +
'.pdf')
478 fig2 = plt.figure(2, figsize=(11, 8))
479 ax1 = plt.axes([0.21, 0.15, 0.76, 0.8])
481 qrDataPointsCont, qrDataBins = np.histogram(data[:, 0], bins=bins, weights=data[:, 2])
482 qrDataPointsContStd = np.sqrt(qrDataPointsCont)
484 qrDataPointsContNorm, qrDataBins = np.histogram(data[:, 0], bins=bins, weights=data[:, 2], density=1)
485 qrDataPointsContStdNorm = qrDataPointsContStd * qrDataPointsContNorm / qrDataPointsCont
487 qrBincenters = 0.5 * (qrDataBins[1:] + qrDataBins[:-1])
489 p3 = ax1.errorbar(qrBincenters, qrDataPointsContNorm, xerr=0.02, yerr=qrDataPointsContStdNorm, elinewidth=2, mew=2, ecolor=
'k',
490 fmt=
'o', mfc=
'k', mec=
'#990000', markersize=6, label=
r'${\rm Data}$')
492 ax1.set_ylabel(
r'${\rm Fraction\ \ of\ \ Events\ /\ (\, 0.04\, )}$', fontsize=35)
493 ax1.set_xlabel(
r'$(q\cdot r)_{\rm ' + methodLabel +
'}$', fontsize=35)
494 plt.xticks([-1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1],
495 [
r'$-1$',
r'',
r'$-0.5$',
r'',
r'$0$',
r'',
r'$0.5$',
r'',
r'$1$'], rotation=0, size=40)
496 ax1.tick_params(axis=
'y', labelsize=35)
497 ax1.legend([p3], [
r'${\rm Data}$'], prop={
'size': 35}, loc=1, numpoints=1)
500 if qrDataPointsContNorm[np.argmax(qrDataPointsContNorm)] < 1.4:
503 ax1.set_xlim(-1.005, 1.005)
504 plt.savefig(PATH +
'/QR_B0_B0bar' + methodLabel +
'Continuum.pdf')
507 data_total_tagged_Continuum = 0
508 for iEntries
in qrDataPointsCont:
509 data_total_tagged_Continuum += iEntries
511 print(
'****************************************************************************************************')
512 print(
'* TOTAL NUMBER OF TAGGED CONTINUUM EVENTS = ' +
513 '{:<24}'.format(
"%.0f" % data_total_tagged_Continuum) +
'{:>28}'.format(
' *'))
517 mcHistW = ROOT.TH1F(
"mcHistW",
"mcHistW", int(r_size - 2), r_subsample)
518 dataHistW = ROOT.TH1F(
"dataHistW",
"dataHistW", int(r_size - 2), r_subsample)
520 mcHistEff = ROOT.TH1F(
"mcHistEff",
"mcHistEff", int(r_size - 2), r_subsample)
521 dataHistEff = ROOT.TH1F(
"dataHistEff",
"dataHistEff", int(r_size - 2), r_subsample)
523 print(
'****************************************************************************************************')
525 print(
'* --> TEST OF COMPATIBILITY BETWEEN DATA AND MC *')
527 for i
in range(0, len(rbins) - 1):
529 mcHistW.SetBinContent(i + 1, mc_wvalue[i])
530 mcHistW.SetBinError(i + 1, mc_wvalueUncertainty[i])
532 dataHistW.SetBinContent(i + 1, data_wvalue[i])
533 dataHistW.SetBinError(i + 1, data_wvalueUncertainty[i])
535 mcHistEff.SetBinContent(i + 1, mc_iEffEfficiency[i])
536 mcHistEff.SetBinError(i + 1, mc_iEffEfficiencyUncertainty[i])
538 dataHistEff.SetBinContent(i + 1, data_iEffEfficiency[i])
539 dataHistEff.SetBinError(i + 1, data_iEffEfficiencyUncertainty[i])
541 residualsW = array(
'd', [0] * r_size)
542 residualsEff = array(
'd', [0] * r_size)
544 print(
'* TEST ON w *')
547 chi2W = dataHistW.Chi2Test(mcHistW,
"WW CHI2 P", residualsW)
548 print(
"1-CL for NDF = 7 is = ", ROOT.TMath.Prob(chi2W, 7))
550 print(
'* TEST ON EFFECTIVE EFFICIENCY *')
552 chi2Eff = dataHistEff.Chi2Test(mcHistEff,
"WW P", residualsEff)
553 print(
"1-CL for NDF = 7 is = ", ROOT.TMath.Prob(chi2Eff, 7))
555 print(
'****************************************************************************************************')
559 qrMCPoints, qrDataBins = np.histogram(mc[:, 0], bins=bins)
560 qrMCPointsStd = np.sqrt(qrMCPoints)
561 qrMCPointsNorm, qrDataBins = np.histogram(mc[:, 0], bins=bins, density=1)
562 qrMCPointsStdNorm = qrMCPointsStd * qrMCPointsNorm / qrMCPoints
564 qrDataMCResiduals = (qrDataPointsNorm - qrMCPointsNorm) \
565 / np.sqrt(qrDataPointsStdNorm * qrDataPointsStdNorm + qrMCPointsStdNorm * qrMCPointsStdNorm)
567 fig3 = plt.figure(3, figsize=(11, 11))
568 ax1 = plt.axes([0.21, 0.37, 0.76, 0.60])
571 p3 = ax1.errorbar(qrBincenters, qrDataPointsNorm, xerr=0.02, yerr=qrDataPointsStdNorm,
572 elinewidth=2, mew=2, ecolor=
'k',
573 fmt=
'o', mfc=
'k', mec=
'#006600', markersize=6, label=
r'${\rm Data}$')
575 ax1.hist(mc[:, 0], bins=bins, density=1, histtype=
'step',
576 edgecolor=
'b', linewidth=4, linestyle=
'dashed', label=
r'${\rm MC}$')
578 p2, = ax1.plot([], label=
r'${\rm MC}$', linewidth=4, linestyle=
'dashed', c=
'b')
580 ax1.set_ylabel(
r'${\rm Fraction\ \ of\ \ Events\ /\ (\, 0.04\, )}$', fontsize=35, labelpad=20)
582 ax1.tick_params(axis=
'y', labelsize=35)
583 ax1.legend([p3, p2], [
r'${\rm Data}$',
r'${\rm MC}$'], prop={
'size': 35}, loc=1, numpoints=1)
586 if qrDataPointsNorm[np.argmax(qrDataPointsNorm)] < 1.4:
588 plt.yticks([0, 0.25, 0.5, 0.75, 1.0, 1.25],
589 [
r'$0.00$',
r'$0.25$',
r'$0.5$',
r'$0.75$',
r'$1.00$',
r'$1.25$'], rotation=0, size=35)
590 ax1.set_xlim(-1.005, 1.005)
591 plt.xticks([-1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1],
592 [
r'',
r'',
r'',
r'',
r'',
r'',
r'',
r'',
r''], rotation=0, size=35)
594 ax2 = plt.axes([0.21, 0.15, 0.76, 0.2])
595 ax2.errorbar(qrBincenters, qrDataMCResiduals, xerr=0.02, yerr=1, elinewidth=2, mew=2, ecolor=
'k',
596 fmt=
'o', mfc=
'k', mec=
'#006600', markersize=6, label=
r'${\rm Data}$')
597 ax2.set_ylabel(
r'${\rm Normalized}$' +
'\n' +
r'${\rm Residuals}$', fontsize=35, labelpad=20)
598 ax2.set_xlabel(
r'$(q\cdot r)_{\rm ' + methodLabel +
'}$', fontsize=35)
599 plt.xticks([-1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1],
600 [
r'$-1$',
r'',
r'$-0.5$',
r'',
r'$0$',
r'',
r'$0.5$',
r'',
r'$1$'], rotation=0, size=35)
601 plt.yticks([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],
602 [
r'',
r'$-4$',
r'',
r'$-2$',
r'',
r'$0$',
r'',
r'$2$',
r'',
r'$4$',
r''], rotation=0, size=25)
605 ax2.set_xlim(-1.005, 1.005)
608 plt.axhline(y=3, xmin=-1.005, xmax=1.005, linewidth=2, color=
'#006600', linestyle=
'-')
610 plt.axhline(y=1, xmin=-1.005, xmax=1.005, linewidth=2, color=
'b', linestyle=
'-')
611 plt.axhline(y=-1, xmin=-1.005, xmax=1.005, linewidth=2, color=
'b', linestyle=
'-')
613 plt.axhline(y=-3, xmin=-1.005, xmax=1.005, linewidth=2, color=
'#006600', linestyle=
'-')
615 plt.savefig(PATH +
'/QR_B0_B0bar' + methodLabel +
'WithRes.pdf')
621 def plotWithResiduals(rooFitFrame, rooRealVar, dots, modelCurve, units, nameOfPlot, legend, removeArtifacts):
625 rooFitFrame.GetXaxis().SetTitle(
"")
626 rooFitFrame.GetXaxis().SetLabelSize(0)
628 rooFitFrame.GetYaxis().SetTitleSize(0.072)
629 rooFitFrame.GetYaxis().SetTitleOffset(0.98)
630 rooFitFrame.GetYaxis().SetLabelSize(0.055)
632 pointsHist = ROOT.RooHist()
638 xValDot = ROOT.Double(-1.E30)
639 yValDot = ROOT.Double(-1.E30)
641 iDotPoint = ROOT.RooRealVar(
"iDotPoint",
"", 0.)
642 iModelPoint = ROOT.RooRealVar(
"iModelPoint",
"", 0.)
643 iDotError = ROOT.RooRealVar(
"iDotError",
"", 0.)
645 iResidual = ROOT.RooFormulaVar(
"yComb",
"",
"(@0 - @1)/@2", ROOT.RooArgList(iDotPoint, iModelPoint, iDotError))
647 while iBin < dots.GetN() - 1:
648 dots.GetPoint(iBin, xValDot, yValDot)
650 iDotPoint.setVal(yValDot)
651 iModelPoint.setVal(modelCurve.interpolate(xValDot))
652 iDotError.setVal(float(dots.GetErrorYlow(iBin) + dots.GetErrorYhigh(iBin)))
654 if np.isnan(iResidual.getVal())
is not True:
656 residualValue = iResidual.getVal()
659 if abs(residualValue) > 3:
666 pointsHist.addBinWithXYError(xValDot, residualValue,
667 dots.GetErrorXlow(iBin),
668 dots.GetErrorXhigh(iBin),
673 pointsHist.SetMarkerStyle(dots.GetMarkerStyle())
674 pointsHist.SetMarkerSize(dots.GetMarkerSize())
676 rooFitFrameRes = rooRealVar.frame()
680 rooFitFrameRes.SetTitle(
"")
681 rooFitFrameRes.GetXaxis().SetTitle(rooRealVar.GetTitle() +
" " + units)
682 rooFitFrameRes.GetXaxis().SetTitleSize(0.2)
683 rooFitFrameRes.GetXaxis().SetTitleOffset(0.9)
685 rooFitFrameRes.GetXaxis().SetTickSize(0.07)
686 rooFitFrameRes.GetYaxis().SetTickSize(0.024)
688 rooFitFrameRes.GetYaxis().SetTitle(
"#splitline{Normalized}{ Residuals}")
689 rooFitFrameRes.GetYaxis().SetTitleSize(0.16)
690 rooFitFrameRes.GetYaxis().SetTitleOffset(0.4)
692 rooFitFrameRes.GetXaxis().SetLabelSize(0.125)
693 rooFitFrameRes.GetYaxis().SetLabelSize(0.120)
695 rooFitFrameRes.SetAxisRange(-5, 5,
"Y")
696 rooFitFrameRes.GetYaxis().SetNdivisions(10)
697 rooFitFrameRes.GetYaxis().ChangeLabel(1, -1, 0.)
698 rooFitFrameRes.GetYaxis().ChangeLabel(3, -1, 0.)
699 rooFitFrameRes.GetYaxis().ChangeLabel(5, -1, 0.)
700 rooFitFrameRes.GetYaxis().ChangeLabel(7, -1, 0.)
701 rooFitFrameRes.GetYaxis().ChangeLabel(9, -1, 0.)
702 rooFitFrameRes.GetYaxis().ChangeLabel(11, -1, 0.)
704 gLine1 = ROOT.TLine(5.2, 3, 5.295, 3)
705 gLine2 = ROOT.TLine(5.2, 1, 5.295, 1)
706 gLine3 = ROOT.TLine(5.2, -1, 5.295, -1)
707 gLine4 = ROOT.TLine(5.2, -3, 5.295, -3)
708 gLine1.SetLineColor(ROOT.kGreen + 3)
709 gLine2.SetLineColor(ROOT.kBlue)
710 gLine3.SetLineColor(ROOT.kBlue)
711 gLine4.SetLineColor(ROOT.kGreen + 3)
713 gLine1.SetLineWidth(2)
714 gLine2.SetLineWidth(2)
715 gLine3.SetLineWidth(2)
716 gLine4.SetLineWidth(2)
720 c1 = ROOT.TCanvas(
"c1",
"c1", 700, 640)
721 c1.SetBottomMargin(0)
724 Pad1 = ROOT.TPad(
"p1",
"p1", 0, 0.277, 1, 1, 0)
725 Pad2 = ROOT.TPad(
"p2",
"p2", 0, 0, 1, 0.276, 0)
729 Pad1.SetLeftMargin(0.15)
730 Pad1.SetBottomMargin(0.02)
731 Pad1.SetTopMargin(0.06)
733 Pad2.SetLeftMargin(0.15)
734 Pad2.SetBottomMargin(0.4)
735 Pad2.SetTopMargin(0.01)
738 rooFitFrameRes.Draw()
743 pointsHist.Draw(
"P SAME")
753 nameOfPlot = nameOfPlot +
"WithResiduals.pdf"
754 c1.SaveAs(nameOfPlot)
758 for treename
in treenames:
762 tdat = ROOT.TChain(treename)
763 tMC = ROOT.TChain(treename)
765 for iFile
in workingFilesData:
768 for iFile
in workingFilesMC:
771 histo_notTaggedEventsMC = ROOT.TH1F(
'notTaggedEventsMC',
772 'Histogram for not tagged events',
775 histo_notTaggedEventsData = ROOT.TH1F(
'notTaggedEventsData',
776 'Histogram for not tagged events',
780 'FBDT_qrCombined>>notTaggedEventsMC',
781 'abs(qrMC) == 0 && isSignal == 1 && FBDT_qrCombined < -1')
784 'FBDT_qrCombined>>notTaggedEventsData',
785 'FBDT_qrCombined < -1')
787 mc_total_notTagged = histo_notTaggedEventsMC.GetEntries()
788 data_total_notTagged = histo_notTaggedEventsData.GetEntries()
790 B0_mbc = ROOT.RooRealVar(
"Mbc",
"#it{m}_{bc}", 0, 5.2, 5.295,
"GeV/#it{c}^{2}")
791 B0_deltaE = ROOT.RooRealVar(
"deltaE",
"#Delta#it{E}", 0, -0.15, 0.15,
"GeV/#it{c}^{2}")
793 B0_FBDT_qrCombined = ROOT.RooRealVar(
"FBDT_qrCombined",
"FBDT_qrCombined", 0, -1.01, 1.01)
794 B0_FANN_qrCombined = ROOT.RooRealVar(
"FANN_qrCombined",
"FANN_qrCombined", 0, -1.01, 1.01)
796 B0_qrMC = ROOT.RooRealVar(
"qrMC",
"qrMC", 0., -100, 100)
798 argSet = ROOT.RooArgSet(B0_mbc, B0_deltaE)
799 argSet.add(B0_FBDT_qrCombined)
800 argSet.add(B0_FANN_qrCombined)
803 cutData =
"abs(FBDT_qrCombined) < 1.01"
804 cutMC =
"abs(qrMC) ==1 && abs(FBDT_qrCombined) < 1.01"
806 data = ROOT.RooDataSet(
813 mc = ROOT.RooDataSet(
820 fitMC = ROOT.RooDataSet(
"fitMC",
"fitMC", ROOT.RooArgSet(B0_mbc, B0_FBDT_qrCombined, B0_FANN_qrCombined, B0_qrMC),
"")
821 fitData = ROOT.RooDataSet(
"fitData",
"fitData", ROOT.RooArgSet(B0_mbc, B0_FBDT_qrCombined, B0_FANN_qrCombined),
"")
826 data_total_Tagged = fitData.numEntries()
827 data_total_notTagged = histo_notTaggedEventsData.GetEntries()
829 maxBo_mbc = tdat.GetMaximum(
"Mbc")
830 print(
"maximum B0_mbc = ", maxBo_mbc)
832 B0_mbc.setRange(
"fitRange", 5.2, maxBo_mbc)
836 mbcMuGauss1 = ROOT.RooRealVar(
"mbcMuGauss1",
"mbcMuGauss1", 5.27943e+00, 5.27, 5.2893,
"GeV")
837 mbcSigmaGauss1 = ROOT.RooRealVar(
"mbcSigmaGauss1",
"mbcSigmaGauss1", 2.62331e-03, 0, 0.1,
"GeV")
838 mbcGauss1 = ROOT.RooGaussModel(
"mbcGauss1",
"mbcGauss1", B0_mbc, mbcMuGauss1, mbcSigmaGauss1)
840 mbcMu2Shift = ROOT.RooRealVar(
"mbcMu2Shift",
"mbcMu2Shift", 7.62270e-03, -0.01, 0.01)
841 mbcSig2Factor = ROOT.RooRealVar(
"mbcSig2Factor",
"mbcSig2Factor", 2.83547e-01, 0, 1)
842 mbcMuGauss2 = ROOT.RooFormulaVar(
"mbcMuGauss2",
"mbcMuGauss2",
"@0-@1", ROOT.RooArgList(mbcMuGauss1, mbcMu2Shift))
843 mbcSigmaGauss2 = ROOT.RooFormulaVar(
"mbcSigmaGauss2",
"mbcSigmaGauss2",
"@0/@1", ROOT.RooArgList(mbcSigmaGauss1, mbcSig2Factor))
844 mbcGauss2 = ROOT.RooGaussModel(
"mbcGauss2",
"mbcGauss2", B0_mbc, mbcMuGauss2, mbcSigmaGauss2)
846 mbcFracGauss2 = ROOT.RooRealVar(
"mbcFracGauss2",
"mbcFracGauss2", 9.93351e-01, 0.0, 1.)
848 mbcSignalModel = ROOT.RooAddModel(
849 "mbcSignalModel",
"mbcSignalModel", ROOT.RooArgList(
850 mbcGauss1, mbcGauss2), ROOT.RooArgList(mbcFracGauss2))
852 mcFit = mbcSignalModel.fitTo(
854 ROOT.RooFit.Minos(ROOT.kFALSE), ROOT.RooFit.Extended(ROOT.kFALSE),
855 ROOT.RooFit.NumCPU(8), ROOT.RooFit.Save())
857 mbcMu2Shift.setConstant()
858 mbcSig2Factor.setConstant()
859 mbcFracGauss2.setConstant()
861 mbcSignalArgset1 = ROOT.RooArgSet(mbcGauss1)
862 mbcSignalArgset2 = ROOT.RooArgSet(mbcGauss2)
864 mbcLogFrameMC = B0_mbc.frame()
865 fitMC.plotOn(mbcLogFrameMC, ROOT.RooFit.LineWidth(4))
866 mbcSignalModel.plotOn(mbcLogFrameMC)
867 mbcSignalModel.plotOn(
869 ROOT.RooFit.Components(mbcSignalArgset1),
870 ROOT.RooFit.LineColor(ROOT.kRed + 2), ROOT.RooFit.LineWidth(4))
871 mbcSignalModel.plotOn(
873 ROOT.RooFit.Components(mbcSignalArgset2),
874 ROOT.RooFit.LineColor(ROOT.kGreen + 3), ROOT.RooFit.LineWidth(4))
876 mbcLogFrameMC.SetTitle(
"")
877 mbcXtitle = B0_mbc.GetTitle() +
" [GeV/#it{c}^{2}]"
878 mbcLogFrameMC.GetXaxis().SetTitle(mbcXtitle)
879 mbcLogFrameMC.GetXaxis().SetTitleSize(0.05)
880 mbcLogFrameMC.GetXaxis().SetLabelSize(0.045)
881 mbcLogFrameMC.GetYaxis().SetTitleSize(0.05)
882 mbcLogFrameMC.GetYaxis().SetTitleOffset(1.5)
883 mbcLogFrameMC.GetYaxis().SetLabelSize(0.045)
885 c1 = ROOT.TCanvas(
"c1",
"c1", 1400, 1100)
887 Pad = ROOT.TPad(
"p1",
"p1", 0, 0, 1, 1, 0, 0, 0)
888 Pad.SetLeftMargin(0.15)
889 Pad.SetBottomMargin(0.15)
895 nPlot = PATH +
"/B0_mbcMC.pdf"
901 mbcSignYield = ROOT.RooRealVar(
"mbcSignYield",
"mbcSignYield", 1.53208e+03, 0.0, 20000)
902 mbcContYield = ROOT.RooRealVar(
"mbcContYield",
"mbcContYield", 1.13456e+03, 0.0, 20000)
904 mbcArgusMax = ROOT.RooRealVar(
"mbcArgusMax",
"mbcArgusMax", maxBo_mbc,
"GeV")
905 mbcArgusC = ROOT.RooRealVar(
"mbcArgusC",
"mbcArgusC", -4.65996e+01, -100, 0)
906 mbcArgusPow = ROOT.RooRealVar(
"mbcArgusPow",
"mbcArgusPow", 5.13442e-01, -2, 2,
"GeV")
907 mbcArgus = ROOT.RooArgusBG(
"mbcArgus",
"mbcArgus", B0_mbc, mbcArgusMax, mbcArgusC, mbcArgusPow)
909 mbcModel = ROOT.RooAddPdf(
910 "mbcModel",
"mbcModel", ROOT.RooArgList(
911 mbcSignalModel, mbcArgus), ROOT.RooArgList(
912 mbcSignYield, mbcContYield))
914 dataFit = mbcModel.fitTo(
916 ROOT.RooFit.Minos(ROOT.kFALSE), ROOT.RooFit.Extended(ROOT.kFALSE),
917 ROOT.RooFit.NumCPU(8), ROOT.RooFit.Save())
919 mbcMuGauss1.setConstant()
920 mbcSigmaGauss1.setConstant()
921 mbcArgusC.setConstant()
922 mbcArgusPow.setConstant()
926 sData = ROOT.RooStats.SPlot(
"sData",
"SPlot using B0_mbc", fitData, mbcModel, ROOT.RooArgList(mbcSignYield, mbcContYield))
931 print(
"Check SWeights:")
933 print(
"Yield of mbcSignYield is ", mbcSignYield.getVal(),
". From sWeights it is ",
934 sData.GetYieldFromSWeight(
"mbcSignYield"))
936 print(
"Yield of mbcContYield is ", mbcContYield.getVal(),
". From sWeights it is ",
937 sData.GetYieldFromSWeight(
"mbcContYield"))
944 dataFitExtended = mbcModel.fitTo(
945 fitData, ROOT.RooFit.Extended(),
946 ROOT.RooFit.Minos(ROOT.kFALSE), ROOT.RooFit.Extended(ROOT.kFALSE),
947 ROOT.RooFit.NumCPU(8), ROOT.RooFit.Save())
951 mbcArgset1 = ROOT.RooArgSet(mbcArgus)
952 mbcArgset2 = ROOT.RooArgSet(mbcSignalModel)
955 mbcFrame = B0_mbc.frame()
956 fitData.plotOn(mbcFrame)
957 mbcModel.plotOn(mbcFrame, ROOT.RooFit.LineWidth(4))
960 ROOT.RooFit.Components(mbcArgset1),
961 ROOT.RooFit.LineColor(
963 ROOT.RooFit.LineStyle(5),
964 ROOT.RooFit.LineWidth(4))
967 ROOT.RooFit.Components(mbcArgset2),
968 ROOT.RooFit.LineColor(
970 ROOT.RooFit.LineStyle(7),
971 ROOT.RooFit.LineWidth(4))
973 mbcFrame.SetTitle(
"")
974 mbcFrame.GetXaxis().SetTitle(mbcXtitle)
975 mbcFrame.SetTitleOffset(0.9,
"X")
976 mbcFrame.GetXaxis().SetTitleSize(0.075)
977 mbcFrame.GetXaxis().SetLabelSize(0.045)
978 mbcFrame.GetYaxis().SetTitleSize(0.06)
979 mbcFrame.GetYaxis().SetTitleOffset(0.95)
980 mbcFrame.GetYaxis().SetLabelSize(0.045)
982 c1 = ROOT.TCanvas(
"c1",
"c1", 10, 15, 700, 500)
983 c1.SetLeftMargin(0.15)
984 c1.SetRightMargin(0.04)
985 c1.SetTopMargin(0.03)
986 c1.SetBottomMargin(0.15)
995 nPlot = PATH +
"/B0_mbc.pdf"
1000 mbcFrameMC = B0_mbc.frame()
1001 mbcFrameMC.SetTitle(
"")
1003 fitMC.plotOn(mbcFrameMC)
1004 mbcSignalModel.plotOn(mbcFrameMC, ROOT.RooFit.LineColor(ROOT.kGreen + 3), ROOT.RooFit.LineStyle(7), ROOT.RooFit.LineWidth(4))
1006 dotsMC = mbcFrameMC.getHist(
"h_fitMC")
1007 modelCurveMC = mbcFrameMC.getCurve(
"mbcSignalModel_Norm[Mbc]")
1009 dotsMC.SetFillColor(ROOT.kWhite)
1010 modelCurveMC.SetFillColor(ROOT.kWhite)
1014 lMC = ROOT.TLegend(0.25, 0.63, 0.5, 0.89)
1015 lMC.AddEntry(dotsMC,
"Belle MC")
1016 lMC.AddEntry(modelCurveMC,
'Signal')
1018 lMC.SetTextSize(0.055)
1020 plotWithResiduals(mbcFrameMC, B0_mbc, dotsMC, modelCurveMC,
"[GeV/#it{c}^{2}]",
"mbcMC", lMC,
True)
1024 dots = mbcFrame.getHist(
"h_fitData")
1025 modelCurve = mbcFrame.getCurve(
"mbcModel_Norm[Mbc]")
1026 signalCurve = mbcFrame.getCurve(
"mbcModel_Norm[Mbc]_Comp[mbcSignalModel]")
1027 continuumCurve = mbcFrame.getCurve(
"mbcModel_Norm[Mbc]_Comp[mbcArgus]")
1029 dots.SetFillColor(ROOT.kWhite)
1030 modelCurve.SetFillColor(ROOT.kWhite)
1031 signalCurve.SetFillColor(ROOT.kWhite)
1032 continuumCurve.SetFillColor(ROOT.kWhite)
1034 legend = ROOT.TLegend(0.25, 0.43, 0.5, 0.89)
1035 legend.AddEntry(dots,
"Belle data")
1036 legend.AddEntry(modelCurve,
'Fit result')
1037 legend.AddEntry(signalCurve,
"Signal")
1038 legend.AddEntry(continuumCurve,
'Continuum')
1040 legend.SetTextSize(0.055)
1042 plotWithResiduals(mbcFrame, B0_mbc, dots, modelCurve,
"[GeV/#it{c}^{2}]",
"Mbc", legend,
False)
1044 signalData = ROOT.RooDataSet(
"signalData",
"signalData", fitData, fitData.get(),
"",
"mbcSignYield_sw")
1046 print(
"Variable Names")
1048 qrSigFrame = B0_FBDT_qrCombined.frame()
1049 signalData.plotOn(qrSigFrame, ROOT.RooFit.DataError(ROOT.RooAbsData.SumW2))
1051 qrSigFrame.SetTitle(
"")
1053 qrSigFrame.GetXaxis().SetTitle(mbcXtitle)
1054 qrSigFrame.GetXaxis().SetTitleSize(0.05)
1055 qrSigFrame.GetXaxis().SetLabelSize(0.045)
1056 qrSigFrame.GetYaxis().SetTitleSize(0.05)
1057 qrSigFrame.GetYaxis().SetTitleOffset(1.5)
1058 qrSigFrame.GetYaxis().SetLabelSize(0.045)
1060 c1 = ROOT.TCanvas(
"c1",
"c1", 1400, 1100)
1062 Pad = ROOT.TPad(
"p1",
"p1", 0, 0, 1, 1, 0, 0, 0)
1063 Pad.SetLeftMargin(0.15)
1064 Pad.SetBottomMargin(0.15)
1070 nPlot = PATH +
"/B0_qrSignal.pdf"
1074 continuumData = ROOT.RooDataSet(
"continuumData",
"continuumData", fitData, fitData.get(),
"",
"mbcContYield_sw")
1076 qrContFrame = B0_FBDT_qrCombined.frame()
1077 continuumData.plotOn(qrContFrame, ROOT.RooFit.DataError(ROOT.RooAbsData.SumW2))
1079 qrContFrame.SetTitle(
"")
1081 qrContFrame.GetXaxis().SetTitle(mbcXtitle)
1082 qrContFrame.GetXaxis().SetTitleSize(0.05)
1083 qrContFrame.GetXaxis().SetLabelSize(0.045)
1084 qrContFrame.GetYaxis().SetTitleSize(0.05)
1085 qrContFrame.GetYaxis().SetTitleOffset(1.5)
1086 qrContFrame.GetYaxis().SetLabelSize(0.045)
1088 c1 = ROOT.TCanvas(
"c1",
"c1", 1400, 1100)
1090 Pad = ROOT.TPad(
"p1",
"p1", 0, 0, 1, 1, 0, 0, 0)
1091 Pad.SetLeftMargin(0.15)
1092 Pad.SetBottomMargin(0.15)
1097 nPlot = PATH +
"/B0_qrContinuum.pdf"
1105 sPlotResultsFBDT = np.zeros((fitData.numEntries(), 3))
1106 sPlotResultsFANN = np.zeros((fitData.numEntries(), 3))
1107 for i
in range(fitData.numEntries()):
1108 row = fitData.get(i)
1109 sPlotResultsFBDT[i][0] = row.getRealValue(
'FBDT_qrCombined', 0, ROOT.kTRUE)
1110 sPlotResultsFBDT[i][1] = row.getRealValue(
'mbcSignYield_sw', 0, ROOT.kTRUE)
1111 sPlotResultsFBDT[i][2] = row.getRealValue(
'mbcContYield_sw', 0, ROOT.kTRUE)
1112 sPlotResultsFANN[i][0] = row.getRealValue(
'FANN_qrCombined', 0, ROOT.kTRUE)
1113 sPlotResultsFANN[i][1] = row.getRealValue(
'mbcSignYield_sw', 0, ROOT.kTRUE)
1114 sPlotResultsFANN[i][2] = row.getRealValue(
'mbcContYield_sw', 0, ROOT.kTRUE)
1116 mcSPlotFBDT = np.zeros((fitMC.numEntries(), 2))
1117 mcSPlotFANN = np.zeros((fitMC.numEntries(), 2))
1118 for i
in range(fitMC.numEntries()):
1120 mcSPlotFBDT[i][0] = row.getRealValue(
'FBDT_qrCombined', 0, ROOT.kTRUE)
1121 mcSPlotFBDT[i][1] = row.getRealValue(
'qrMC', 0, ROOT.kTRUE)
1122 mcSPlotFANN[i][0] = row.getRealValue(
'FANN_qrCombined', 0, ROOT.kTRUE)
1123 mcSPlotFANN[i][1] = row.getRealValue(
'qrMC', 0, ROOT.kTRUE)
1125 efficiencyCalculator(mcSPlotFBDT, sPlotResultsFBDT,
"FBDT")
1126 efficiencyCalculator(mcSPlotFANN, sPlotResultsFANN,
"FANN")