|
@@ -3,7 +3,7 @@ import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
from filval.result_set import ResultSet
|
|
from filval.result_set import ResultSet
|
|
-from filval.histogram import hist, hist_add, hist_norm, hist_scale, hist2d
|
|
|
|
|
|
+from filval.histogram import hist, hist_integral, hist2d, hist2d_percent_contour
|
|
from filval.plotting import (decl_plot, render_plots, hist_plot, hist2d_plot,
|
|
from filval.plotting import (decl_plot, render_plots, hist_plot, hist2d_plot,
|
|
Plot, generate_dashboard, simple_plot)
|
|
Plot, generate_dashboard, simple_plot)
|
|
|
|
|
|
@@ -14,58 +14,151 @@ def center_text(x, y, txt, **kwargs):
|
|
transform=plt.gca().transAxes, **kwargs)
|
|
transform=plt.gca().transAxes, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
+def hist_integral_ratio(num, den):
|
|
|
|
+ num_int = hist_integral(num, times_bin_width=False)
|
|
|
|
+ den_int = hist_integral(den, times_bin_width=False)
|
|
|
|
+
|
|
|
|
+ ratio = num_int / den_int
|
|
|
|
+ error = np.sqrt(den_int) / den_int # TODO: Check this definition of error
|
|
|
|
+ return ratio, error
|
|
|
|
+
|
|
@decl_plot
|
|
@decl_plot
|
|
-def plot_residuals(rs, layer, hit, variable, subdet, plot_cuts=True):
|
|
|
|
- matching_cuts = [
|
|
|
|
- dict(
|
|
|
|
- dPhiMaxHighEt=0.05,
|
|
|
|
- dPhiMaxHighEtThres=20.0,
|
|
|
|
- dPhiMaxLowEtGrad=-0.002,
|
|
|
|
- dRzMaxHighEt=9999.0,
|
|
|
|
- dRzMaxHighEtThres=0.0,
|
|
|
|
- dRzMaxLowEtGrad=0.0,
|
|
|
|
- ),
|
|
|
|
- dict(
|
|
|
|
- dPhiMaxHighEt=0.003,
|
|
|
|
- dPhiMaxHighEtThres=0.0,
|
|
|
|
- dPhiMaxLowEtGrad=0.0,
|
|
|
|
- dRzMaxHighEt=0.05,
|
|
|
|
- dRzMaxHighEtThres=30.0,
|
|
|
|
- dRzMaxLowEtGrad=-0.002,
|
|
|
|
- ),
|
|
|
|
- dict(
|
|
|
|
- dPhiMaxHighEt=0.003,
|
|
|
|
- dPhiMaxHighEtThres=0.0,
|
|
|
|
- dPhiMaxLowEtGrad=0.0,
|
|
|
|
- dRzMaxHighEt=0.05,
|
|
|
|
- dRzMaxHighEtThres=30.0,
|
|
|
|
- dRzMaxLowEtGrad=-0.002,
|
|
|
|
- )
|
|
|
|
- ]
|
|
|
|
|
|
+def plot_residuals(rs, layer, hit, variable, subdet, plot_cuts=True, cut_sel='tight'):
|
|
|
|
+ matching_cuts = {
|
|
|
|
+ 'extra-narrow': [
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.025,
|
|
|
|
+ dPhiMaxHighEtThres=20.0,
|
|
|
|
+ dPhiMaxLowEtGrad=-0.002,
|
|
|
|
+ dRzMaxHighEt=9999.0,
|
|
|
|
+ dRzMaxHighEtThres=0.0,
|
|
|
|
+ dRzMaxLowEtGrad=0.0,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.0015,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.025,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.0015,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.025,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ 'narrow': [
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.05,
|
|
|
|
+ dPhiMaxHighEtThres=20.0,
|
|
|
|
+ dPhiMaxLowEtGrad=-0.002,
|
|
|
|
+ dRzMaxHighEt=9999.0,
|
|
|
|
+ dRzMaxHighEtThres=0.0,
|
|
|
|
+ dRzMaxLowEtGrad=0.0,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.003,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.05,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.003,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.05,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ 'wide': [
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.10,
|
|
|
|
+ dPhiMaxHighEtThres=20.0,
|
|
|
|
+ dPhiMaxLowEtGrad=-0.002,
|
|
|
|
+ dRzMaxHighEt=9999.0,
|
|
|
|
+ dRzMaxHighEtThres=0.0,
|
|
|
|
+ dRzMaxLowEtGrad=0.0,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.006,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.10,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.006,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.10,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ 'extra-wide': [
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.15,
|
|
|
|
+ dPhiMaxHighEtThres=20.0,
|
|
|
|
+ dPhiMaxLowEtGrad=-0.002,
|
|
|
|
+ dRzMaxHighEt=9999.0,
|
|
|
|
+ dRzMaxHighEtThres=0.0,
|
|
|
|
+ dRzMaxLowEtGrad=0.0,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.009,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.15,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ ),
|
|
|
|
+ dict(
|
|
|
|
+ dPhiMaxHighEt=0.009,
|
|
|
|
+ dPhiMaxHighEtThres=0.0,
|
|
|
|
+ dPhiMaxLowEtGrad=0.0,
|
|
|
|
+ dRzMaxHighEt=0.15,
|
|
|
|
+ dRzMaxHighEtThres=30.0,
|
|
|
|
+ dRzMaxLowEtGrad=-0.002,
|
|
|
|
+ )
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
|
|
h = hist2d(getattr(rs, f'{variable}_{subdet}_L{layer}_H{hit}_v_Et'))
|
|
h = hist2d(getattr(rs, f'{variable}_{subdet}_L{layer}_H{hit}_v_Et'))
|
|
|
|
|
|
def calc_window(et):
|
|
def calc_window(et):
|
|
idx = min(hit-1, 2)
|
|
idx = min(hit-1, 2)
|
|
- high_et = matching_cuts[idx][f'{variable}MaxHighEt']
|
|
|
|
- high_et_thres = matching_cuts[idx][f'{variable}MaxHighEtThres']
|
|
|
|
- low_et_grad = matching_cuts[idx][f'{variable}MaxLowEtGrad']
|
|
|
|
|
|
+ cuts = matching_cuts[cut_sel]
|
|
|
|
+ high_et = cuts[idx][f'{variable}MaxHighEt']
|
|
|
|
+ high_et_thres = cuts[idx][f'{variable}MaxHighEtThres']
|
|
|
|
+ low_et_grad = cuts[idx][f'{variable}MaxLowEtGrad']
|
|
return high_et + min(0, et-high_et_thres)*low_et_grad
|
|
return high_et + min(0, et-high_et_thres)*low_et_grad
|
|
|
|
|
|
hist2d_plot(h, colorbar=True)
|
|
hist2d_plot(h, colorbar=True)
|
|
|
|
|
|
|
|
+ xs, ys = hist2d_percent_contour(h, .90, 'x')
|
|
|
|
+ plt.plot(xs, ys, color='green', label='90\% contour')
|
|
|
|
+ xs, ys = hist2d_percent_contour(h, .995, 'x')
|
|
|
|
+ plt.plot(xs, ys, color='darkgreen', label='99.5\% contour')
|
|
|
|
+
|
|
if plot_cuts:
|
|
if plot_cuts:
|
|
ets = h[3][:, 0]
|
|
ets = h[3][:, 0]
|
|
cuts = [calc_window(et) for et in ets]
|
|
cuts = [calc_window(et) for et in ets]
|
|
plt.plot(cuts, ets, color='red', label='Cut Value')
|
|
plt.plot(cuts, ets, color='red', label='Cut Value')
|
|
- plt.legend()
|
|
|
|
|
|
+ plt.legend(loc='upper right')
|
|
|
|
|
|
plt.xlabel({'dPhi': r'$\delta \phi$ (rads)',
|
|
plt.xlabel({'dPhi': r'$\delta \phi$ (rads)',
|
|
'dRz': r'$\delta R/z$ (cm)'}[variable])
|
|
'dRz': r'$\delta R/z$ (cm)'}[variable])
|
|
plt.ylabel('$E_T$ (GeV)')
|
|
plt.ylabel('$E_T$ (GeV)')
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
@decl_plot
|
|
@decl_plot
|
|
def plot_seed_eff(rs):
|
|
def plot_seed_eff(rs):
|
|
r"""## ECAL-Driven Seeding Efficiency
|
|
r"""## ECAL-Driven Seeding Efficiency
|
|
@@ -107,6 +200,7 @@ def plot_tracking_eff(rs):
|
|
ax_pt = plt.subplot(221)
|
|
ax_pt = plt.subplot(221)
|
|
ax_eta = plt.subplot(222)
|
|
ax_eta = plt.subplot(222)
|
|
ax_phi = plt.subplot(223)
|
|
ax_phi = plt.subplot(223)
|
|
|
|
+ ax_eta_pt = plt.subplot(224)
|
|
|
|
|
|
errors = True
|
|
errors = True
|
|
plt.sca(ax_pt)
|
|
plt.sca(ax_pt)
|
|
@@ -127,6 +221,12 @@ def plot_tracking_eff(rs):
|
|
plt.xlabel(r"Sim-Track $\phi$")
|
|
plt.xlabel(r"Sim-Track $\phi$")
|
|
plt.ylim((0, 1.1))
|
|
plt.ylim((0, 1.1))
|
|
|
|
|
|
|
|
+ plt.sca(ax_eta_pt)
|
|
|
|
+ hist2d_plot(hist2d(rs.tracking_eff_v_eta_pt))
|
|
|
|
+ plt.xlabel(r"Sim-Track $\eta$")
|
|
|
|
+ plt.ylabel(r"Sim-Track $p_T$")
|
|
|
|
+ plt.colorbar()
|
|
|
|
+
|
|
|
|
|
|
@decl_plot
|
|
@decl_plot
|
|
def plot_seed_purity(rs, ext=""):
|
|
def plot_seed_purity(rs, ext=""):
|
|
@@ -184,22 +284,19 @@ def plot_track_purity(rs, ext=""):
|
|
hist_plot(get_hist("tracking_pur_v_pt"), include_errors=errors)
|
|
hist_plot(get_hist("tracking_pur_v_pt"), include_errors=errors)
|
|
center_text(0.5, 0.3, r'$|\eta|<2.4$')
|
|
center_text(0.5, 0.3, r'$|\eta|<2.4$')
|
|
plt.xlabel(r"GSF-Track $p_T$")
|
|
plt.xlabel(r"GSF-Track $p_T$")
|
|
- if not ext:
|
|
|
|
- plt.ylim((0, 1.1))
|
|
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
|
|
plt.sca(ax_eta)
|
|
plt.sca(ax_eta)
|
|
hist_plot(get_hist("tracking_pur_v_eta"), include_errors=errors)
|
|
hist_plot(get_hist("tracking_pur_v_eta"), include_errors=errors)
|
|
center_text(0.5, 0.3, r'$p_T>20$')
|
|
center_text(0.5, 0.3, r'$p_T>20$')
|
|
plt.xlabel(r"GSF-Track $\eta$")
|
|
plt.xlabel(r"GSF-Track $\eta$")
|
|
- if not ext:
|
|
|
|
- plt.ylim((0, 1.1))
|
|
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
|
|
plt.sca(ax_phi)
|
|
plt.sca(ax_phi)
|
|
hist_plot(get_hist("tracking_pur_v_phi"), include_errors=errors)
|
|
hist_plot(get_hist("tracking_pur_v_phi"), include_errors=errors)
|
|
center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
plt.xlabel(r"GSF-Track $\phi$")
|
|
plt.xlabel(r"GSF-Track $\phi$")
|
|
- if not ext:
|
|
|
|
- plt.ylim((0, 1.1))
|
|
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
|
|
|
|
|
|
@decl_plot
|
|
@decl_plot
|
|
@@ -212,50 +309,44 @@ def plot_hit_vs_layer(rs, region):
|
|
plt.ylabel('Hit \#')
|
|
plt.ylabel('Hit \#')
|
|
|
|
|
|
|
|
|
|
-if __name__ == '__main__':
|
|
|
|
- rs = ResultSet('seeds', '../hists/new_seeding.root')
|
|
|
|
|
|
+def single_cut_plots(cut_sel):
|
|
|
|
+ rs = ResultSet(f'{cut_sel}-window', f'../hists/{cut_sel}-window.root')
|
|
|
|
|
|
- # Next, declare all of the (sub)plots that will be assembled into full
|
|
|
|
- # figures later
|
|
|
|
- seed_eff = plot_seed_eff, (rs, )
|
|
|
|
|
|
+ seed_eff = plot_seed_eff, (rs,)
|
|
tracking_eff = plot_tracking_eff, (rs,)
|
|
tracking_eff = plot_tracking_eff, (rs,)
|
|
|
|
|
|
- seed_pur = plot_seed_purity, rs
|
|
|
|
- seed_pur_num = plot_seed_purity, (rs,), {'ext': '_num'}
|
|
|
|
- seed_pur_den = plot_seed_purity, (rs,), {'ext': '_den'}
|
|
|
|
|
|
+ seed_pur = plot_seed_purity, (rs,)
|
|
|
|
|
|
track_pur = plot_track_purity, (rs,)
|
|
track_pur = plot_track_purity, (rs,)
|
|
- track_pur_num = plot_track_purity, (rs,), {'ext': '_num'}
|
|
|
|
- track_pur_den = plot_track_purity, (rs,), {'ext': '_den'}
|
|
|
|
|
|
+ track_pur_seed_match = plot_track_purity, (rs,), dict(ext='2')
|
|
|
|
|
|
- BPIX_residuals_L1_H1_dPhi = plot_residuals, (rs, 1, 1, 'dPhi', 'BPIX')
|
|
|
|
- BPIX_residuals_L2_H2_dPhi = plot_residuals, (rs, 2, 2, 'dPhi', 'BPIX')
|
|
|
|
- BPIX_residuals_L3_H3_dPhi = plot_residuals, (rs, 3, 3, 'dPhi', 'BPIX')
|
|
|
|
|
|
+ BPIX_residuals_L1_H1_dPhi = plot_residuals, (rs, 1, 1, 'dPhi', 'BPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ BPIX_residuals_L2_H2_dPhi = plot_residuals, (rs, 2, 2, 'dPhi', 'BPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ BPIX_residuals_L3_H3_dPhi = plot_residuals, (rs, 3, 3, 'dPhi', 'BPIX'), dict(cut_sel=cut_sel)
|
|
|
|
|
|
BPIX_residuals_L1_H1_dRz = plot_residuals, (rs, 1, 1, 'dRz', 'BPIX'), {'plot_cuts': False}
|
|
BPIX_residuals_L1_H1_dRz = plot_residuals, (rs, 1, 1, 'dRz', 'BPIX'), {'plot_cuts': False}
|
|
- BPIX_residuals_L2_H2_dRz = plot_residuals, (rs, 2, 2, 'dRz', 'BPIX')
|
|
|
|
- BPIX_residuals_L3_H3_dRz = plot_residuals, (rs, 3, 3, 'dRz', 'BPIX')
|
|
|
|
|
|
+ BPIX_residuals_L2_H2_dRz = plot_residuals, (rs, 2, 2, 'dRz', 'BPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ BPIX_residuals_L3_H3_dRz = plot_residuals, (rs, 3, 3, 'dRz', 'BPIX'), dict(cut_sel=cut_sel)
|
|
|
|
|
|
- FPIX_residuals_L1_H1_dPhi = plot_residuals, (rs, 1, 1, 'dPhi', 'FPIX')
|
|
|
|
- FPIX_residuals_L2_H2_dPhi = plot_residuals, (rs, 2, 2, 'dPhi', 'FPIX')
|
|
|
|
- FPIX_residuals_L3_H3_dPhi = plot_residuals, (rs, 3, 3, 'dPhi', 'FPIX')
|
|
|
|
|
|
+ FPIX_residuals_L1_H1_dPhi = plot_residuals, (rs, 1, 1, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ FPIX_residuals_L2_H2_dPhi = plot_residuals, (rs, 2, 2, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ FPIX_residuals_L3_H3_dPhi = plot_residuals, (rs, 3, 3, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
|
|
FPIX_residuals_L1_H1_dRz = plot_residuals, (rs, 1, 1, 'dRz', 'FPIX'), {'plot_cuts': False}
|
|
FPIX_residuals_L1_H1_dRz = plot_residuals, (rs, 1, 1, 'dRz', 'FPIX'), {'plot_cuts': False}
|
|
- FPIX_residuals_L2_H2_dRz = plot_residuals, (rs, 2, 2, 'dRz', 'FPIX')
|
|
|
|
- FPIX_residuals_L3_H3_dRz = plot_residuals, (rs, 3, 3, 'dRz', 'FPIX')
|
|
|
|
|
|
+ FPIX_residuals_L2_H2_dRz = plot_residuals, (rs, 2, 2, 'dRz', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ FPIX_residuals_L3_H3_dRz = plot_residuals, (rs, 3, 3, 'dRz', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
|
|
- FPIX_residuals_L1_H2_dPhi = plot_residuals, (rs, 1, 2, 'dPhi', 'FPIX')
|
|
|
|
- FPIX_residuals_L1_H3_dPhi = plot_residuals, (rs, 1, 3, 'dPhi', 'FPIX')
|
|
|
|
- FPIX_residuals_L2_H3_dPhi = plot_residuals, (rs, 2, 3, 'dPhi', 'FPIX')
|
|
|
|
|
|
+ FPIX_residuals_L1_H2_dPhi = plot_residuals, (rs, 1, 2, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ FPIX_residuals_L1_H3_dPhi = plot_residuals, (rs, 1, 3, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ FPIX_residuals_L2_H3_dPhi = plot_residuals, (rs, 2, 3, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
|
|
- FPIX_residuals_L1_H2_dRz = plot_residuals, (rs, 1, 2, 'dPhi', 'FPIX')
|
|
|
|
- FPIX_residuals_L1_H3_dRz = plot_residuals, (rs, 1, 3, 'dPhi', 'FPIX')
|
|
|
|
- FPIX_residuals_L2_H3_dRz = plot_residuals, (rs, 2, 3, 'dPhi', 'FPIX')
|
|
|
|
|
|
+ FPIX_residuals_L1_H2_dRz = plot_residuals, (rs, 1, 2, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ FPIX_residuals_L1_H3_dRz = plot_residuals, (rs, 1, 3, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
+ FPIX_residuals_L2_H3_dRz = plot_residuals, (rs, 2, 3, 'dPhi', 'FPIX'), dict(cut_sel=cut_sel)
|
|
|
|
|
|
hit_vs_layer_barrel = plot_hit_vs_layer, (rs, 'barrel')
|
|
hit_vs_layer_barrel = plot_hit_vs_layer, (rs, 'barrel')
|
|
hit_vs_layer_forward = plot_hit_vs_layer, (rs, 'forward')
|
|
hit_vs_layer_forward = plot_hit_vs_layer, (rs, 'forward')
|
|
|
|
|
|
- # Now assemble the plots into figures.
|
|
|
|
plots = [
|
|
plots = [
|
|
Plot(BPIX_residuals_L1_H1_dPhi, 'Phi Residuals Layer 1 Hit 1 - BPIX'),
|
|
Plot(BPIX_residuals_L1_H1_dPhi, 'Phi Residuals Layer 1 Hit 1 - BPIX'),
|
|
Plot(BPIX_residuals_L2_H2_dPhi, 'Phi Residuals Layer 2 Hit 2 - BPIX'),
|
|
Plot(BPIX_residuals_L2_H2_dPhi, 'Phi Residuals Layer 2 Hit 2 - BPIX'),
|
|
@@ -282,15 +373,228 @@ if __name__ == '__main__':
|
|
Plot(tracking_eff, 'GSF Tracking Efficiency'),
|
|
Plot(tracking_eff, 'GSF Tracking Efficiency'),
|
|
Plot(hit_vs_layer_barrel, 'Hit vs Layer - Barrel'),
|
|
Plot(hit_vs_layer_barrel, 'Hit vs Layer - Barrel'),
|
|
Plot(hit_vs_layer_forward, 'Hit vs Layer - Forward'),
|
|
Plot(hit_vs_layer_forward, 'Hit vs Layer - Forward'),
|
|
|
|
+ Plot(seed_pur, 'ECAL-Driven Seeding Purity'),
|
|
Plot(track_pur, 'GSF Track Purity'),
|
|
Plot(track_pur, 'GSF Track Purity'),
|
|
- Plot(track_pur_num, 'GSF Track Purity Numerator'),
|
|
|
|
- Plot(track_pur_den, 'GSF Track Purity Denominator'),
|
|
|
|
|
|
+ Plot(track_pur_seed_match , 'GSF Track Purity (Seed Truth Match)'),
|
|
|
|
+ simple_plot(rs.gsf_tracks_nmatch_sim_tracks, log='y'),
|
|
]
|
|
]
|
|
|
|
|
|
- # Finally, render and save the plots and generate the html+bootstrap
|
|
|
|
- # dashboard to view them
|
|
|
|
render_plots(plots, to_disk=False)
|
|
render_plots(plots, to_disk=False)
|
|
generate_dashboard(plots, 'Seeding Efficiency',
|
|
generate_dashboard(plots, 'Seeding Efficiency',
|
|
- output='eff_plots.html',
|
|
|
|
|
|
+ output=f'{rs.sample_name}.html',
|
|
source=__file__,
|
|
source=__file__,
|
|
config=rs.config)
|
|
config=rs.config)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@decl_plot
|
|
|
|
+def plot_seed_roc_curve(rss):
|
|
|
|
+ def get_num_den(rs, basename):
|
|
|
|
+ num = hist(getattr(rs, f'{basename}_num'))
|
|
|
|
+ den = hist(getattr(rs, f'{basename}_den'))
|
|
|
|
+ return hist_integral_ratio(num, den)
|
|
|
|
+ for rs in rss:
|
|
|
|
+ eff, eff_err = get_num_den(rs, 'seed_eff_v_phi')
|
|
|
|
+ pur, pur_err = get_num_den(rs, 'seed_pur_v_phi')
|
|
|
|
+ plt.errorbar([pur], [eff], xerr=[pur_err], yerr=[eff_err], label=rs.sample_name)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
|
|
+ plt.axis('equal')
|
|
|
|
+ plt.xlim((0.8, 1.0))
|
|
|
|
+ plt.ylim((0.8, 1.0))
|
|
|
|
+ plt.xlabel('ECAL-Driven Seeding Purity')
|
|
|
|
+ plt.ylabel('ECAL-Driven Seeding Efficiency')
|
|
|
|
+ plt.grid()
|
|
|
|
+ plt.legend()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@decl_plot
|
|
|
|
+def plot_seed_eff_all(rss):
|
|
|
|
+ ax_pt = plt.subplot(221)
|
|
|
|
+ ax_eta = plt.subplot(222)
|
|
|
|
+ ax_phi = plt.subplot(223)
|
|
|
|
+ errors = True
|
|
|
|
+ for rs in rss:
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ hist_plot(hist(rs.seed_eff_v_pt), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ hist_plot(hist(rs.seed_eff_v_eta), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ hist_plot(hist(rs.seed_eff_v_phi), include_errors=errors, label=rs.sample_name)
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ center_text(0.5, 0.3, r'$|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"Sim-Track $p_T$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$')
|
|
|
|
+ plt.xlabel(r"Sim-Track $\eta$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+ plt.legend(loc='lower right')
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"Sim-Track $\phi$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@decl_plot
|
|
|
|
+def plot_seed_pur_all(rss):
|
|
|
|
+ ax_pt = plt.subplot(221)
|
|
|
|
+ ax_eta = plt.subplot(222)
|
|
|
|
+ ax_phi = plt.subplot(223)
|
|
|
|
+ errors = True
|
|
|
|
+ for rs in rss:
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ hist_plot(hist(rs.seed_pur_v_pt), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ hist_plot(hist(rs.seed_pur_v_eta), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ hist_plot(hist(rs.seed_pur_v_phi), include_errors=errors, label=rs.sample_name)
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ center_text(0.5, 0.3, r'$|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"Seed $p_T$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$')
|
|
|
|
+ plt.xlabel(r"Seed $\eta$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+ plt.legend(loc='lower right')
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"Seed $\phi$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@decl_plot
|
|
|
|
+def plot_tracking_roc_curve(rss, ext=''):
|
|
|
|
+ def get_num_den(rs, basename):
|
|
|
|
+ num = hist(getattr(rs, f'{basename}{ext}_num'))
|
|
|
|
+ den = hist(getattr(rs, f'{basename}{ext}_den'))
|
|
|
|
+ return hist_integral_ratio(num, den)
|
|
|
|
+ for rs in rss:
|
|
|
|
+ eff, eff_err = get_num_den(rs, 'tracking_eff_v_phi')
|
|
|
|
+ pur, pur_err = get_num_den(rs, 'tracking_pur_v_phi')
|
|
|
|
+ plt.errorbar([pur], [eff], xerr=[pur_err], yerr=[eff_err], label=rs.sample_name)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
|
|
+ plt.axis('equal')
|
|
|
|
+ plt.xlim((0.8, 1.0))
|
|
|
|
+ plt.ylim((0.8, 1.0))
|
|
|
|
+ plt.xlabel('GSF-Track Purity')
|
|
|
|
+ plt.ylabel('GSF-Track Efficiency')
|
|
|
|
+ plt.grid()
|
|
|
|
+ plt.legend()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@decl_plot
|
|
|
|
+def plot_tracking_eff_all(rss, ext=''):
|
|
|
|
+ ax_pt = plt.subplot(221)
|
|
|
|
+ ax_eta = plt.subplot(222)
|
|
|
|
+ ax_phi = plt.subplot(223)
|
|
|
|
+ errors = True
|
|
|
|
+ for rs in rss:
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ hist_plot(hist(getattr(rs, f'tracking_eff_v_pt{ext}')), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ hist_plot(hist(getattr(rs, f'tracking_eff_v_eta{ext}')), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ hist_plot(hist(getattr(rs, f'tracking_eff_v_phi{ext}')), include_errors=errors, label=rs.sample_name)
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ center_text(0.5, 0.3, r'$|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"Sim-Track $p_T$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$')
|
|
|
|
+ plt.xlabel(r"Sim-Track $\eta$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+ plt.legend(loc='lower right')
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"Sim-Track $\phi$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@decl_plot
|
|
|
|
+def plot_tracking_pur_all(rss, ext=''):
|
|
|
|
+ ax_pt = plt.subplot(221)
|
|
|
|
+ ax_eta = plt.subplot(222)
|
|
|
|
+ ax_phi = plt.subplot(223)
|
|
|
|
+ errors = True
|
|
|
|
+ for rs in rss:
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ hist_plot(hist(getattr(rs, f'tracking_pur_v_pt{ext}')), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ hist_plot(hist(getattr(rs, f'tracking_pur_v_eta{ext}')), include_errors=errors, label=rs.sample_name)
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ hist_plot(hist(getattr(rs, f'tracking_pur_v_phi{ext}')), include_errors=errors, label=rs.sample_name)
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_pt)
|
|
|
|
+ center_text(0.5, 0.3, r'$|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"GSF-Track $p_T$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_eta)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$')
|
|
|
|
+ plt.xlabel(r"GSF-Track $\eta$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+ plt.legend(loc='lower right')
|
|
|
|
+
|
|
|
|
+ plt.sca(ax_phi)
|
|
|
|
+ center_text(0.5, 0.3, r'$p_T>20$ and $|\eta|<2.4$')
|
|
|
|
+ plt.xlabel(r"GSF-Track $\phi$")
|
|
|
|
+ plt.ylim((0, 1.1))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@decl_plot
|
|
|
|
+def plot_ecal_rel_res(rss):
|
|
|
|
+ for rs in rss:
|
|
|
|
+ hist_plot(hist(rs.ecal_energy_resolution), label=rs.sample_name)
|
|
|
|
+ plt.xlabel(r"ECAL $E_T$ relative error")
|
|
|
|
+ plt.legend()
|
|
|
|
+
|
|
|
|
+def all_cut_plots(cuts):
|
|
|
|
+ rss = [ResultSet(f'{cut_sel}-window', f'../hists/{cut_sel}-window.root') for cut_sel in cuts]
|
|
|
|
+
|
|
|
|
+ tracking_roc_curve = plot_tracking_roc_curve, (rss,)
|
|
|
|
+ tracking_eff_all = plot_tracking_eff_all, (rss,)
|
|
|
|
+ tracking_pur_all = plot_tracking_pur_all, (rss,)
|
|
|
|
+ tracking_roc_curve2 = plot_tracking_roc_curve, (rss, '2')
|
|
|
|
+ tracking_eff_all2 = plot_tracking_eff_all, (rss, '2')
|
|
|
|
+ tracking_pur_all2 = plot_tracking_pur_all, (rss, '2')
|
|
|
|
+
|
|
|
|
+ seed_roc_curve = plot_seed_roc_curve, (rss,)
|
|
|
|
+ seed_eff_all = plot_seed_eff_all, (rss,)
|
|
|
|
+ seed_pur_all = plot_seed_pur_all, (rss,)
|
|
|
|
+
|
|
|
|
+ ecal_rel_res = plot_ecal_rel_res, (rss,)
|
|
|
|
+
|
|
|
|
+ plots = [
|
|
|
|
+ Plot(tracking_roc_curve, 'Tracking ROC Curve'),
|
|
|
|
+ Plot(tracking_eff_all, 'Tracking Efficiency'),
|
|
|
|
+ Plot(tracking_pur_all, 'Tracking Purity'),
|
|
|
|
+ Plot(tracking_roc_curve2, 'Tracking ROC Curve (Seed Matched)'),
|
|
|
|
+ Plot(tracking_eff_all2, 'Tracking Efficiency (Seed Matched)'),
|
|
|
|
+ Plot(tracking_pur_all2, 'Tracking Purity (Seed Matched)'),
|
|
|
|
+ Plot(seed_roc_curve, 'Seeding ROC Curve'),
|
|
|
|
+ Plot(seed_eff_all, 'ECAL-Driven Seeding Efficiency'),
|
|
|
|
+ Plot(seed_pur_all, 'ECAL-Driven Seeding Purity'),
|
|
|
|
+ Plot(ecal_rel_res, 'ECAL ET Relative Resolution'),
|
|
|
|
+ ]
|
|
|
|
+
|
|
|
|
+ render_plots(plots, to_disk=False)
|
|
|
|
+ generate_dashboard(plots, 'Comparisons',
|
|
|
|
+ output='comparisons.html',
|
|
|
|
+ source=__file__,
|
|
|
|
+ config=rss[0].config)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+ cuts = ['extra-narrow', 'narrow', 'wide', 'extra-wide']
|
|
|
|
+ all_cut_plots(cuts)
|
|
|
|
+ for cut in cuts:
|
|
|
|
+ single_cut_plots(cut)
|