28 from matplotlib.ticker
import FormatStrFormatter
29 import matplotlib.pyplot
as plt
31 from ROOT
import Belle2
34 import matplotlib
as mpl
36 mpl.rcParams.update({
'font.size': 22})
37 mpl.rcParams[
'text.usetex'] =
True
38 mpl.rcParams[
'text.latex.preamble'] = [
r"\usepackage{amsmath}"]
40 if len(sys.argv) != 3:
41 sys.exit(
"Must provide 2 arguments: [Belle or Belle2] [samplesWildCards]"
44 belleOrBelle2 = sys.argv[1]
45 samplesWildCards = sys.argv[2]
48 workingDirectory =
'.'
50 if not b2.find_file(
'GenLevelVariablesPlots', silent=
True):
51 os.mkdir(workingDirectory +
'/GenLevelVariablesPlots')
53 sourceFiles = glob.glob(str(samplesWildCards))
55 tree = ROOT.TChain(
"tree")
56 for Inputfile
in sourceFiles:
57 tree.AddFile(Inputfile)
60 ROOT.TH1.SetDefaultSumw2()
64 HistoBelle2_PtMC = ROOT.TH1F(
'PtMCBelle2',
'MC Transverse Momentum', binsPt, 0, 5)
65 HistoBelle2_PtFit = ROOT.TH1F(
'PtFitBelle2',
'TrackFitResult Transverse Momentum', binsPt, 0, 5)
67 HistoBelle2_pseudoPD0MC = ROOT.TH1F(
'pseudoPD0MCBelle2',
'MC pseudo Momentum for D0', binsPt, 0, 5)
68 HistoBelle2_pseudoPD0Fit = ROOT.TH1F(
'pseudoPD0FitBelle2',
'Fit pseudo Momentum for D0', binsPt, 0, 5)
70 HistoBelle2_pseudoPZ0MC = ROOT.TH1F(
'pseudoPZ0MCBelle2',
'MC pseudo Momentum for Z0', binsPt, 0, 5)
71 HistoBelle2_pseudoPZ0Fit = ROOT.TH1F(
'pseudoPZ0FitBelle2',
'Fit pseudo Momentum for Z0', binsPt, 0, 5)
73 HistoBelle2_d0Error = ROOT.TH1F(
'd0ErrorBelle2',
'TrackFitResult Error on d0', binsPt, 0, 0.03)
74 HistoBelle2_z0Error = ROOT.TH1F(
'z0ErrorBelle2',
'TrackFitResult Error on z0', binsPt, 0, 0.03)
76 D0 =
'abs(TrackFitResults.m_tau[0][0])'
77 Z0 =
'abs(TrackFitResults.m_tau[0][3])'
78 X0 =
'sqrt(TrackFitResults.m_tau[0][0]**2 + TrackFitResults.m_tau[0][3]**2)'
80 mcX =
"MCParticles.m_productionVertex_x"
81 mcY =
"MCParticles.m_productionVertex_y"
82 mcZ =
"MCParticles.m_productionVertex_z"
84 mcD0 =
"sqrt(MCParticles.m_productionVertex_x*MCParticles.m_productionVertex_x + " + \
85 " MCParticles.m_productionVertex_y*MCParticles.m_productionVertex_y)"
86 mcZ0 =
"abs(MCParticles.m_productionVertex_z)"
87 mcX0 =
"sqrt(MCParticles.m_productionVertex_x*MCParticles.m_productionVertex_x + " + \
88 "MCParticles.m_productionVertex_y*MCParticles.m_productionVertex_y + " + \
89 "MCParticles.m_productionVertex_z*MCParticles.m_productionVertex_z)"
91 ptMC =
'sqrt(MCParticles.m_momentum_x**2 + MCParticles.m_momentum_y**2)'
92 ptFit =
'abs(0.003*1.5/TrackFitResults.m_tau[0][2])'
94 pMC =
'sqrt(MCParticles.m_momentum_x**2 + MCParticles.m_momentum_y**2 + + MCParticles.m_momentum_z**2)'
95 pFit =
'(abs(0.003*1.5/TrackFitResults.m_tau[0][2])*sqrt(1+TrackFitResults.m_tau[0][4]**2))'
96 chiProb =
'TrackFitResults.m_pValue'
98 pseudoPD0MC =
'sqrt(' + ptMC +
'**3/(' + pMC +
'*(1+(MCParticles.m_mass[0]/' + pMC +
')**2)))'
99 pseudoPD0Fit =
'sqrt(' + ptFit +
'**3/(' + pFit +
'*(1+(MCParticles.m_mass[0]/' + pFit +
')**2)))'
101 pseudoPZ0MC =
'sqrt(' + ptMC +
'**5/(' + pMC +
'**3*(1+(MCParticles.m_mass[0]/' + pMC +
')**2)))'
102 pseudoPZ0Fit =
'sqrt(' + ptFit +
'**5/(' + pFit +
'**3*(1+(MCParticles.m_mass[0]/' + pFit +
')**2)))'
109 particleConditions = {
110 'Electron': [
'e',
"11 ",
" MCParticles.m_pdg > 0 ",
" MCParticles.m_pdg < 0 "],
111 'Muon': [
r'\mu',
"13 ",
" MCParticles.m_pdg > 0 ",
" MCParticles.m_pdg < 0 "],
112 'Kaon': [
'K',
"321 ",
" MCParticles.m_pdg < 0 ",
" MCParticles.m_pdg > 0 "],
113 'Pion': [
r'\pi',
"211 ",
" MCParticles.m_pdg < 0 ",
" MCParticles.m_pdg > 0 "],
114 'Proton': [
'p',
"2212 ",
" MCParticles.m_pdg < 0 ",
" MCParticles.m_pdg > 0 "]}
117 Particles = [
"Electron",
"Muon",
"Kaon",
"Pion",
"Proton"]
122 def makePlotsForEachParticleKind(cutOnUpsilonFourS=""):
124 Makes plots showing the distribution of the impact parameters and vertices
125 for positively and negatively charged particles.
130 variablesPlotParamsDict = {
'ImpactXY': [D0, dBw, 0, 0.5,
r'$d_0\ [{\rm ' + unitImp +
'}]$',
r"{\rm " + unitImp +
r"}\, "],
131 'z0': [Z0, dBw, 0, 1.0,
r'$z_0\ [{\rm ' + unitImp +
'}]$',
r"{\rm " + unitImp +
r"}\, "],
132 'distance': [X0, dBw, 0, 1.5,
r'$\xi_0\ [{\rm ' + unitImp +
'}]$',
r"{\rm " + unitImp +
r"}\, "],
133 'mcGenX': [mcX, dBw, -0.05, 0.15,
r'$x_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
134 r"{\rm " + unitImp +
r"}\, "],
135 'mcGenY': [mcY, dBw, -0.075, 0.075,
r'$y_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
136 r"{\rm " + unitImp +
r"}\, "],
137 'mcGenZ': [mcZ, dBw, -0.6, 1,
r'$z_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
138 r"{\rm " + unitImp +
r"}\, "],
139 'mcGenImpactXY': [mcD0, dBw, 0, 0.1,
140 r'$\sqrt{x_{\rm MC}^2 + y_{\rm MC}^2}\ [{\rm ' + unitImp +
'}]$',
141 r"{\rm " + unitImp +
r"}\, "],
142 'mcGenz0': [mcZ0, dBw, 0, 1,
r'$|z_{\rm MC}|\ [{\rm ' + unitImp +
'}]$',
143 r"{\rm " + unitImp +
r"}\, "],
144 'mcGendistance': [mcX0, dBw, 0, 1,
145 r'$\sqrt{x_{\rm MC}^2 + y_{\rm MC}^2 + z_{\rm MC}^2}\ [{\rm ' + unitImp +
'}]$',
146 r"{\rm " + unitImp +
r"}\, "],
149 if belleOrBelle2 ==
"Belle":
152 variablesPlotParamsDict = {
158 r'$d_0\ [{\rm ' + unitImp +
'}]$',
159 r"{\rm " + unitImp +
r"}\, "],
165 r'$z_0\ [{\rm ' + unitImp +
'}]$',
166 r"{\rm " + unitImp +
r"}\, "],
172 r'$\xi_0\ [{\rm ' + unitImp +
'}]$',
173 r"{\rm " + unitImp +
r"}\, "],
179 r'$x_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
180 r"{\rm " + unitImp +
r"}\, "],
186 r'$y_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
187 r"{\rm " + unitImp +
r"}\, "],
193 r'$z_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
194 r"{\rm " + unitImp +
r"}\, "],
200 r'$\sqrt{x_{\rm MC}^2 + y_{\rm MC}^2}\ [{\rm ' + unitImp +
'}]$',
201 r"{\rm " + unitImp +
r"}\, "],
207 r'$|z_{\rm MC}|\ [{\rm ' + unitImp +
'}]$',
208 r"{\rm " + unitImp +
r"}\, "],
214 r'$\sqrt{x_{\rm MC}^2 + y_{\rm MC}^2 + z_{\rm MC}^2}\ [{\rm ' + unitImp +
'}]$',
215 r"{\rm " + unitImp +
r"}\, "],
218 withOrWithoutCut =
""
219 if cutOnUpsilonFourS !=
"":
220 withOrWithoutCut =
"WithUpsilonFourSCut"
222 variablesPlotParamsDict = {
'ImpactXY': [D0, dBw, 0, 1.0,
r'$d_0\ [{\rm ' + unitImp +
'}]$',
r"{\rm " + unitImp +
r"}\, "],
223 'z0': [Z0, dBw, 0, 1.0,
r'$z_0\ [{\rm ' + unitImp +
'}]$',
r"{\rm " + unitImp +
r"}\, "],
224 'distance': [X0, dBw, 0, 1.5,
r'$\xi_0\ [{\rm ' + unitImp +
'}]$',
r"{\rm " + unitImp +
r"}\, "],
225 'mcGenX': [mcX, dBw, 0, 1,
r'$x_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
226 r"{\rm " + unitImp +
r"}\, "],
227 'mcGenY': [mcY, dBw, -1, 1,
r'$y_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
228 r"{\rm " + unitImp +
r"}\, "],
229 'mcGenZ': [mcZ, dBw, -0.5, 1,
r'$z_{\rm MC}\ [{\rm ' + unitImp +
'}]$',
230 r"{\rm " + unitImp +
r"}\, "],
231 'mcGenImpactXY': [mcD0, dBw, 0, 1.0,
232 r'$\sqrt{x_{\rm MC}^2 + y_{\rm MC}^2}\ [{\rm ' + unitImp +
'}]$',
233 r"{\rm " + unitImp +
r"}\, "],
234 'mcGenz0': [mcZ0, dBw, 0, 0.4,
235 r'$|z_{\rm MC}|\ [{\rm ' + unitImp +
'}]$',
r"{\rm " + unitImp +
r"}\, "],
236 'mcGendistance': [mcX0, dBw, 0, 1.5,
237 r'$\sqrt{x_{\rm MC}^2 + y_{\rm MC}^2 + z_{\rm MC}^2}\ [{\rm ' +
239 r"{\rm " + unitImp +
r"}\, "],
242 for Particle
in Particles:
244 for inputVariable
in variablesPlotParamsDict:
248 nBins = variablesPlotParamsDict[inputVariable][1]
249 limXmin = variablesPlotParamsDict[inputVariable][2]
250 limXmax = variablesPlotParamsDict[inputVariable][3]
252 negativeHistogram = ROOT.TH1F(
254 "", nBins, limXmin, limXmax)
255 positiveHistogram = ROOT.TH1F(
257 "", nBins, limXmin, limXmax)
258 condition =
"MCParticles.m_status%2==1 && abs(MCParticles.m_pdg) == " + particleConditions[Particle][1] +
" && "
259 condition = condition + cutOnUpsilonFourS
260 condition = condition +
" abs(MCParticles.m_pdg[MCParticles.m_mother - 1])==511 && "
262 factorMultiplication =
''
264 if belleOrBelle2 !=
"Belle" or (belleOrBelle2 ==
"Belle" and cutOnUpsilonFourS !=
""):
265 factorMultiplication =
"*10 "
267 tree.Draw(variablesPlotParamsDict[inputVariable][0] +
268 factorMultiplication +
272 particleConditions[Particle][2])
274 tree.Draw(variablesPlotParamsDict[inputVariable][0] +
275 factorMultiplication +
279 particleConditions[Particle][3])
281 negativeScalingFactor = negativeHistogram.Integral()
282 positiveScalingFactor = positiveHistogram.Integral()
284 if negativeScalingFactor == 0:
285 negativeScalingFactor = 1
287 if positiveScalingFactor == 0:
288 positiveScalingFactor = 1
290 negativeHistogram.Scale(1 / negativeScalingFactor)
291 positiveHistogram.Scale(1 / positiveScalingFactor)
293 negativeArray = np.zeros((negativeHistogram.GetNbinsX(), 2))
294 positiveArray = np.zeros((positiveHistogram.GetNbinsX(), 2))
296 asymmetryArray = np.zeros((positiveHistogram.GetNbinsX(), 2))
297 asymmetryArrayUncertainties = np.zeros((positiveHistogram.GetNbinsX(), 2))
299 for i
in range(0, negativeHistogram.GetNbinsX()):
300 negativeArray[i] = np.array([negativeHistogram.GetBinCenter(i + 1), negativeHistogram.GetBinContent(i + 1)])
301 positiveArray[i] = np.array([positiveHistogram.GetBinCenter(i + 1), positiveHistogram.GetBinContent(i + 1)])
303 numerator = float(positiveArray[i][1] - negativeArray[i][1])
304 denominator = float(positiveArray[i][1] + negativeArray[i][1])
307 asymmetryArray[i] = np.array([negativeHistogram.GetBinCenter(i + 1), 0])
308 asymmetryArrayUncertainties[i] = np.array([negativeHistogram.GetBinCenter(i + 1), 0])
310 asymmetryArray[i] = np.array([negativeHistogram.GetBinCenter(i + 1), float(numerator / denominator)])
312 uncertainty = 2 * math.sqrt((negativeArray[i][1] * negativeHistogram.GetBinError(i + 1))**2 +
313 (positiveArray[i][1] * positiveHistogram.GetBinError(i + 1))**2) / \
314 (negativeArray[i][1] + positiveArray[i][1])**2
316 asymmetryArrayUncertainties[i] = np.array([negativeHistogram.GetBinCenter(i + 1), uncertainty])
318 fig1 = plt.figure(1, figsize=(11, 11))
320 ax1 = plt.axes([0.19, 0.37, 0.76, 0.60])
323 negativeArray[:, 0], weights=negativeArray[:, 1], bins=negativeHistogram.GetNbinsX(),
324 histtype=
'step', edgecolor=
'b', linewidth=4.5, linestyle=
'dashed',
326 label=
r'$' + particleConditions[Particle][0] +
'^{-} $')
328 ax1.hist(positiveArray[:, 0], weights=positiveArray[:, 1], bins=positiveHistogram.GetNbinsX(),
329 histtype=
'step', edgecolor=
'r', linewidth=4, alpha=0.9,
330 label=
r'$' + particleConditions[Particle][0] +
'^{+} $')
332 p1, = ax1.plot([], label=
r'$' + particleConditions[Particle][0] +
'^{-} $', linewidth=5.5, linestyle=
'dashed', c=
'b')
333 p2, = ax1.plot([], label=
r'$' + particleConditions[Particle][0] +
334 '^{+} $', linewidth=5, linestyle=
'solid', alpha=0.9, c=
'r')
336 binWidth = negativeHistogram.GetBinWidth(2)
338 binWidth =
'{:8.3f}'.format(binWidth)
341 ax1.set_ylabel(
r'${\rm Fraction\hspace{0.25em} of\hspace{0.25em} Events}\, /\, (\, ' + binWidth +
r'\, ' +
342 variablesPlotParamsDict[inputVariable][5] +
r')$', fontsize=35)
343 if inputVariable ==
'p' or inputVariable ==
'pt':
346 ax1.yaxis.set_major_formatter(FormatStrFormatter(
r'$%.2f$'))
348 ax1.set_xlim(limXmin, limXmax)
350 locs, labels = plt.xticks()
352 empty_string_labels = [
''] * len(labels)
353 plt.locator_params(axis=
'x', nbins=len(labels))
354 ax1.set_xticklabels(empty_string_labels)
355 ax1.tick_params(axis=
'y', labelsize=37)
357 ax1.legend([p1, p2], [
r'$' +
358 particleConditions[Particle][0] +
360 particleConditions[Particle][0] +
361 '^{+} $'], prop={
'size': 50}, loc=legendLocation, numpoints=1, handlelength=1)
364 ax2 = plt.axes([0.19, 0.15, 0.76, 0.2])
366 ax2.errorbar(asymmetryArray[:, 0], asymmetryArray[:, 1], xerr=float(negativeHistogram.GetBinWidth(2) / 2),
367 yerr=asymmetryArrayUncertainties[:, 1], elinewidth=2, mew=2, ecolor=
'k',
368 fmt=
'o', mfc=
'k', mec=
'k', markersize=6, label=
r'${\rm Data}$')
370 ax2.set_ylabel(
r'$\frac{f^{+}\; -\;\, f^{-}}{f^{+}\; +\;\, f^{-}}$', fontsize=50, labelpad=20)
371 ax2.yaxis.labelpad = 8
373 plt.yticks([-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75],
374 [
r'',
r'$-0.5$',
r'',
r'$0.0$',
r'',
r'$0.5$',
r''], rotation=0, size=25)
375 ax2.set_ylim(-0.75, 0.75)
377 plt.axhline(y=0.5, linewidth=2, color=
'tab:gray', linestyle=
'-')
378 plt.axhline(y=0.25, linewidth=2, color=
'tab:gray', linestyle=
'-')
379 plt.axhline(y=0, linewidth=2, color=
'tab:gray', linestyle=
'-')
380 plt.axhline(y=-0.25, linewidth=2, color=
'tab:gray', linestyle=
'-')
381 plt.axhline(y=-0.5, linewidth=2, color=
'tab:gray', linestyle=
'-')
383 xLabel = variablesPlotParamsDict[inputVariable][4]
385 ax2.xaxis.labelpad = 15
386 plt.locator_params(axis=
'x', nbins=len(labels))
387 ax2.tick_params(axis=
'x', labelsize=40)
389 ax2.set_xlim(limXmin, limXmax)
391 if inputVariable ==
'mcGenY' and belleOrBelle2 ==
"Belle2":
392 plt.xticks([-0.06, -0.04, -0.02, 0, 0.02, 0.04, 0.06],
393 [
'',
r'$-0.04$',
'',
r'$0.00$',
'',
r'$0.04$',
''], rotation=0, size=40)
395 ax2.set_xlabel(xLabel, fontsize=50)
396 plt.savefig(workingDirectory +
'/GenLevelVariablesPlots' +
'/' + belleOrBelle2 + withOrWithoutCut +
400 negativeHistogram.Delete()
401 positiveHistogram.Delete()
404 DecZ =
"MCParticles.m_decayVertex_z"
406 if belleOrBelle2 ==
"Belle2":
408 variablesPlotB0tag = {
'DecZ': [DecZ, dBw, -0.6, 1.5,
r"{\rm " + unitImp +
r"}\, "],
413 variablesPlotB0tag = {
'DecZ': [DecZ, dBw, -1.5, 1.5,
r"{\rm " + unitImp +
r"}\, "],
416 particleCondsB0tag = {
420 " MCParticles.m_pdg < 0 ",
421 " MCParticles.m_pdg > 0 ",
422 " !(MCParticles.m_pdg[MCParticles.m_firstDaughter-1] == 310 && MCParticles.m_pdg[MCParticles.m_firstDaughter] == 443) && ",
423 r'$(z_{\rm tag}^{\rm dec})^{\rm gen}\ [{\rm ' + unitImp +
'}]$'],
427 " MCParticles.m_pdg < 0 ",
428 " MCParticles.m_pdg > 0 ",
429 " (MCParticles.m_pdg[MCParticles.m_firstDaughter-1] == 310 && MCParticles.m_pdg[MCParticles.m_firstDaughter] == 443) && ",
430 r'$(z_{\rm sig}^{\rm dec})^{\rm gen}\ [{\rm ' + unitImp +
'}]$']}
433 def makeZtagDecayPlot(cutOnUpsilonFourS="", asymplot=True):
435 Plots the distribution of the decay z-vertex of the tag-side B0 meson.
438 withOrWithoutCut =
""
440 if cutOnUpsilonFourS !=
"":
441 withOrWithoutCut =
"WithUpsilonFourSCut"
443 variablesPlotB0tag[
'DecZ'] = [DecZ, dBw, -0.6, 1.5,
r"{\rm " + unitImp +
r"}\, "]
444 particleCondsB0tag[
'B0tag'][5] =
r'$(z_{\rm tag}^{\rm dec})^{\rm gen}\ [{\rm ' + unitImp +
r'}]$'
446 for Particle
in particleCondsB0tag:
447 inputVariable =
"DecZ"
449 print(
"Plotting " + Particle +
" z-decay Vertex")
451 nBins = variablesPlotB0tag[inputVariable][1]
452 limXmin = variablesPlotB0tag[inputVariable][2]
453 limXmax = variablesPlotB0tag[inputVariable][3]
463 condition =
"abs(MCParticles.m_pdg) == " + particleCondsB0tag[Particle][1] +
" && "
464 condition = condition + cutOnUpsilonFourS
465 condition = condition + particleCondsB0tag[Particle][4]
467 factorMultiplication =
''
469 if belleOrBelle2 !=
"Belle" or (belleOrBelle2 ==
"Belle" and cutOnUpsilonFourS !=
""):
470 factorMultiplication =
"*10 "
472 tree.Draw(variablesPlotB0tag[inputVariable][0] + factorMultiplication +
">> negative" + Particle +
475 tree.Draw(variablesPlotB0tag[inputVariable][0] + factorMultiplication +
">> positive" + Particle +
478 negativeScalingFactor = negativeHistogram.Integral()
479 positiveScalingFactor = positiveHistogram.Integral()
481 if negativeScalingFactor == 0:
482 negativeScalingFactor = 1
484 if positiveScalingFactor == 0:
485 positiveScalingFactor = 1
487 negativeHistogram.Scale(1 / negativeScalingFactor)
488 positiveHistogram.Scale(1 / positiveScalingFactor)
490 negativeArray = np.zeros((negativeHistogram.GetNbinsX(), 2))
491 positiveArray = np.zeros((positiveHistogram.GetNbinsX(), 2))
493 asymmetryArray = np.zeros((positiveHistogram.GetNbinsX(), 2))
494 asymmetryArrayUncertainties = np.zeros((positiveHistogram.GetNbinsX(), 2))
496 for i
in range(0, negativeHistogram.GetNbinsX()):
497 negativeArray[i] = np.array([negativeHistogram.GetBinCenter(i + 1), negativeHistogram.GetBinContent(i + 1)])
498 positiveArray[i] = np.array([positiveHistogram.GetBinCenter(i + 1), positiveHistogram.GetBinContent(i + 1)])
500 numerator = float(positiveArray[i][1] - negativeArray[i][1])
501 denominator = float(positiveArray[i][1] + negativeArray[i][1])
504 asymmetryArray[i] = np.array([negativeHistogram.GetBinCenter(i + 1), 0])
505 asymmetryArrayUncertainties[i] = np.array([negativeHistogram.GetBinCenter(i + 1), 0])
507 asymmetryArray[i] = np.array([negativeHistogram.GetBinCenter(i + 1), float(numerator / denominator)])
509 uncertainty = 2 * math.sqrt((negativeArray[i][1] * negativeHistogram.GetBinError(i + 1))**2 + (
510 positiveArray[i][1] * positiveHistogram.GetBinError(i + 1))**2) / (negativeArray[i][1] + positiveArray[i][1])**2
512 asymmetryArrayUncertainties[i] = np.array([negativeHistogram.GetBinCenter(i + 1), uncertainty])
514 fig1 = plt.figure(1, figsize=(11, 11))
516 ax1 = plt.axes([0.19, 0.37, 0.76, 0.60])
519 negativeArray[:, 0], weights=negativeArray[:, 1], bins=negativeHistogram.GetNbinsX(),
520 histtype=
'step', edgecolor=
'b', linewidth=4.5, linestyle=
'dashed',
522 label=
r'$' + particleCondsB0tag[Particle][0] +
'^{-} $')
524 ax1.hist(positiveArray[:, 0], weights=positiveArray[:, 1], bins=positiveHistogram.GetNbinsX(),
525 histtype=
'step', edgecolor=
'r', linewidth=4, alpha=0.9,
526 label=
r'$' + particleCondsB0tag[Particle][0] +
'^{+} $')
528 p1, = ax1.plot([], label=
r'$\bar{B}^0$', linewidth=4.5, linestyle=
'dashed', c=
'b')
529 p2, = ax1.plot([], label=
r'$B^0$', linewidth=4, linestyle=
'solid', alpha=0.9, c=
'r')
531 binWidth = negativeHistogram.GetBinWidth(2)
533 binWidth =
'{:8.3f}'.format(binWidth)
536 ax1.set_ylabel(
r'${\rm Fraction\hspace{0.25em} of\hspace{0.25em} Events}\, /\, (\, ' + binWidth +
r'\, ' +
537 variablesPlotB0tag[inputVariable][4] +
r')$', fontsize=35)
538 if inputVariable ==
'p' or inputVariable ==
'pt':
541 ax1.yaxis.set_major_formatter(FormatStrFormatter(
r'$%.2f$'))
543 ax1.set_xlim(limXmin, limXmax)
545 locs, labels = plt.xticks()
546 ax1.tick_params(axis=
'y', labelsize=37)
548 ax1.legend([p1, p2], [
r'$\bar{B}^0$',
r'$B^0$'], prop={
'size': 50}, loc=legendLocation, numpoints=1, handlelength=1)
550 xLabel = particleCondsB0tag[Particle][5]
553 ax1.xaxis.labelpad = 15
554 plt.locator_params(axis=
'x', nbins=len(labels))
555 ax1.tick_params(axis=
'x', labelsize=40)
556 ax1.set_xlim(limXmin, limXmax)
557 ax1.set_xlabel(xLabel, fontsize=50)
561 empty_string_labels = [
''] * len(labels)
562 plt.locator_params(axis=
'x', nbins=len(labels))
563 ax1.set_xticklabels(empty_string_labels)
565 ax2 = plt.axes([0.19, 0.15, 0.76, 0.2])
567 ax2.errorbar(asymmetryArray[:, 0], asymmetryArray[:, 1], xerr=float(negativeHistogram.GetBinWidth(2) / 2),
568 yerr=asymmetryArrayUncertainties[:, 1], elinewidth=2, mew=2, ecolor=
'k',
569 fmt=
'o', mfc=
'k', mec=
'k', markersize=6, label=
r'${\rm Data}$')
572 r'$\frac{f^{B^0}\; -\;\, f^{\overline{B}^0}}{f^{B^0}\; +\;\, f^{\overline{B}^0}}$',
575 ax2.yaxis.labelpad = 0
577 plt.yticks([-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75],
578 [
r'',
r'$-0.5$',
r'',
r'$0.0$',
r'',
r'$0.5$',
r''], rotation=0, size=25)
579 ax2.set_ylim(-0.75, 0.75)
581 plt.axhline(y=0.5, linewidth=2, color=
'tab:gray', linestyle=
'-')
582 plt.axhline(y=0.25, linewidth=2, color=
'tab:gray', linestyle=
'-')
583 plt.axhline(y=0, linewidth=2, color=
'tab:gray', linestyle=
'-')
584 plt.axhline(y=-0.25, linewidth=2, color=
'tab:gray', linestyle=
'-')
585 plt.axhline(y=-0.5, linewidth=2, color=
'tab:gray', linestyle=
'-')
587 ax2.xaxis.labelpad = 15
588 plt.locator_params(axis=
'x', nbins=len(labels))
589 ax2.tick_params(axis=
'x', labelsize=40)
590 ax2.set_xlim(limXmin, limXmax)
591 ax2.set_xlabel(xLabel, fontsize=50)
593 plt.savefig(workingDirectory +
'/GenLevelVariablesPlots' +
'/' +
594 belleOrBelle2 + withOrWithoutCut +
"_" + Particle +
"_" +
598 negativeHistogram.Delete()
599 positiveHistogram.Delete()
602 makePlotsForEachParticleKind(
"")
604 if belleOrBelle2 ==
"Belle":
605 makeZtagDecayPlot(
"")
606 makeZtagDecayPlot(
" abs(MCParticles.m_decayVertex_z[MCParticles.m_mother-1]) < 0.04 && ")
607 makePlotsForEachParticleKind(
" abs(MCParticles.m_decayVertex_z[MCParticles.m_mother[MCParticles.m_mother - 1]-1]) < 0.04 && ")
609 makeZtagDecayPlot(
"")
static std::string makeROOTCompatible(std::string str)
Remove special characters that ROOT dislikes in branch names, e.g.