Browse Source

Beautify final_fit

Blaz Leban 3 years ago
parent
commit
f8883d7976
1 changed files with 7 additions and 7 deletions
  1. 7 7
      1-naloga-razpadi-higgsovega-bozona/final_fit.py

+ 7 - 7
1-naloga-razpadi-higgsovega-bozona/final_fit.py

@@ -10,7 +10,7 @@ labels = ['Background', 'Signal', 'Data']
 
 pldict = {}
 for label in labels:
-    with np.load('DATA/generated_histograms/mass_mm_higgs_' + label + '.npz', 'rb') as data:
+    with np.load('DATA/original_histograms/mass_mm_higgs_' + label + '.npz', 'rb') as data:
         bin_centers = data['bin_centers']
         bin_edges = data['bin_edges']
         bin_values = data['bin_values']
@@ -37,7 +37,7 @@ def Background(x, a, b, c, d, e, f, g, h, func=atlas_invMass_mumu):
     if chebyshev:
         # Choose Chebyshev polynomials as weights
         from numpy.polynomial.chebyshev import chebval
-        return chebval(x, [a, b, c, d, e, f, g]) * func(x)
+        return func(chebval(x, [a, b, c, d, e, f, g, h]), x)
     else:
         # Choose some weighting function
         return func(np.exp(a * x) + b * x**3 + c * x**2 + d * x + h, x)
@@ -66,7 +66,7 @@ ax2.bar(bin_centers, bin_values / Background(bin_centers, *popt) - 1, width=widt
 ax2.axhline(0, color='k', ls='--', alpha=0.7)
 ax2.set_xlabel(r'$m_{\mu \mu}$', fontsize=20)
 ax2.set_ylabel('(Data-Pred.)/Pred.', fontsize=20)
-ax2.set_xticks(bin_edges[::2])
+ax2.set_xticks(bin_edges[::4])
 ax2.tick_params(axis='both', which='major', labelsize=20)
 ax2.grid(True)
 
@@ -112,7 +112,7 @@ ax2.bar(bin_centers_masked + width / 2., bin_values_masked / Background(bin_cent
 ax2.axhline(0, color='k', ls='--', alpha=0.7)
 ax2.set_xlabel(r'$m_{\mu \mu}$', fontsize=20)
 ax2.set_ylabel('(Data-Pred.)/Pred.', fontsize=20)
-ax2.set_xticks(bin_edges[::2])
+ax2.set_xticks(bin_edges[::4])
 ax2.tick_params(axis='both', which='major', labelsize=20)
 ax2.grid(True)
 
@@ -131,7 +131,7 @@ plt.title('Extracted signal', fontsize=22)
 plt.scatter(bin_centers, extracted_signal, color='k', label='Extracted signal')
 plt.xlabel(r'$m_{\mu \mu}$', fontsize=20)
 plt.ylabel('Number of events', fontsize=20)
-plt.xticks(bin_edges[::2], bin_edges[::2].astype(int), size=20)
+plt.xticks(bin_edges[::4], bin_edges[::4].astype(int), size=20)
 plt.yticks(size=20)
 plt.legend(fontsize=20)
 plt.tight_layout()
@@ -172,7 +172,7 @@ for par, pop in zip(['A', r'$\alpha_L$', r'$\alpha_R$', r'$n_L$', r'$n_R$', r'$\
 plt.text(115, 75, string[:-1], size=20, bbox=dict(facecolor='none', edgecolor='gray', boxstyle='round,pad=0.5'))
 plt.xlabel(r'$m_{\mu \mu}$', fontsize=20)
 plt.ylabel('Number of events', fontsize=20)
-plt.xticks(bin_edges[::2], bin_edges[::2].astype(int), size=20)
+plt.xticks(bin_edges[::4], bin_edges[::4].astype(int), size=20)
 plt.yticks(size=20)
 plt.legend(fontsize=20)
 if save:
@@ -196,7 +196,7 @@ plt.scatter(bin_centers, extracted_signal, color='k', label='Extracted signal')
 plt.text(130, -200, r'$\alpha_{{scale}} = {:.3f}$'.format(*popt) + '\n' + r'$N_{{Higgs}} = {:d}$'.format(NHiggs), size=20, bbox=dict(facecolor='w', edgecolor='gray', boxstyle='round,pad=0.5'))
 plt.xlabel(r'$m_{\mu \mu}$', fontsize=20)
 plt.ylabel('Number of events', fontsize=20)
-plt.xticks(bin_edges[::2], bin_edges[::2].astype(int), size=20)
+plt.xticks(bin_edges[::4], bin_edges[::4].astype(int), size=20)
 plt.yticks(size=20)
 plt.legend(loc='upper right', fontsize=20)
 plt.tight_layout()