Преглед на файлове

Updates to plotting routines

Caleb Fangmeier преди 6 години
родител
ревизия
61f2283c03
променени са 3 файла, в които са добавени 33 реда и са изтрити 15 реда
  1. 29 13
      plotting/eff_plots.py
  2. 1 1
      plotting/filval-python
  3. 3 1
      plotting/publish.py

+ 29 - 13
plotting/eff_plots.py

@@ -3,7 +3,7 @@ import numpy as np
 import matplotlib.pyplot as plt
 
 from filval.result_set import ResultSet
-from filval.histogram import hist, hist_integral, hist2d, hist2d_percent_contour
+from filval.histogram import hist, hist_integral, hist_rebin, hist_norm, hist2d, hist2d_percent_contour
 from filval.plotting import (decl_plot, render_plots, hist_plot, hist2d_plot,
                              Plot, generate_dashboard, simple_plot)
 
@@ -235,8 +235,8 @@ def hist_integral_ratio(num, den):
 @decl_plot
 def plot_residuals(rs, layer, hit, variable, subdet, cut_sel=None):
 
-    h_real = hist2d(getattr(rs, f'{variable}_{subdet}_L{layer}_H{hit}_v_Et'))
-    h_fake = hist2d(getattr(rs, f'{variable}_{subdet}_L{layer}_H{hit}_v_Et_fake'))
+    h_real = hist2d(getattr(rs, f'{variable}_{subdet}_L{layer}_H{hit}_v_Et_TrackMatched'))
+    h_fake = hist2d(getattr(rs, f'{variable}_{subdet}_L{layer}_H{hit}_v_Et_NoMatch'))
 
 
     def do_plot(h):
@@ -750,7 +750,7 @@ def plot_ecal_rel_res(rss):
 
 
 @decl_plot
-def plot_res_contour(rss, hit_number, var, layers):
+def plot_res_contour(rss, hit_number, var, layers, ext='_TrackMatched'):
     from itertools import chain
     _, axs = plt.subplots(2, 3)
     axs_all = list(chain(*axs))
@@ -761,7 +761,7 @@ def plot_res_contour(rss, hit_number, var, layers):
         h = None
         for layer in layers:
             subdet = 'BPIX' if layer[0]=='B' else 'FPIX'
-            h = hist2d(getattr(rs, f'{var}_{subdet}_L{layer[1]}_H{hit_number}_v_Et'))
+            h = hist2d(getattr(rs, f'{var}_{subdet}_L{layer[1]}_H{hit_number}_v_Et{ext}'))
             pass
             xs, ys = hist2d_percent_contour(h, .99, 'x')
             plt.plot(xs, ys, label=f'{subdet} - L{layer[1]}')
@@ -772,9 +772,12 @@ def plot_res_contour(rss, hit_number, var, layers):
 
     max_x = 0
     for ax, rs in zip(axs_all, rss):
-        do_plot(ax, rs)
-        _, x_up = ax.get_xlim()
-        max_x = max((max_x, x_up))
+        try:
+            do_plot(ax, rs)
+            _, x_up = ax.get_xlim()
+            max_x = max((max_x, x_up))
+        except KeyError:
+            pass
 
     plt.sca(axs[0][-1])
     plt.legend(loc='best')
@@ -783,6 +786,19 @@ def plot_res_contour(rss, hit_number, var, layers):
         ax.set_xlim((None, max_x))
 
 
+@decl_plot
+def number_of_seeds(rss):
+    from filval.histogram import hist_mean
+
+    for rs in rss:
+        h = hist_rebin(hist(rs.n_seeds), 50, -0.5, 200.5)
+        h = hist_norm(h)
+        mean = int(hist_mean(h))
+        hist_plot(h, label=f'{rs.sample_name} ($\\mu={mean:d}$)')
+    plt.xlabel('Number of Seeds Produced')
+    plt.legend()
+
+
 def all_cut_plots(cuts):
     rss = [ResultSet(f'{cut_sel}', f'../hists/{cut_sel}.root') for cut_sel in cuts]
 
@@ -823,6 +839,7 @@ def all_cut_plots(cuts):
         Plot(res_contour_dRz_H2, 'dRz  Residual 99% Contours - Hit 2'),
         Plot(res_contour_dphi_H3, 'dPhi Residual 99% Contours - Hit 3'),
         Plot(res_contour_dRz_H3, 'dRz  Residual 99% Contours - Hit 3'),
+        Plot((number_of_seeds, (rss,)), 'Number of Electron Seeds'),
     ]
 
     render_plots(plots, to_disk=to_disk)
@@ -840,12 +857,11 @@ if __name__ == '__main__':
         'narrow-window',
         'wide-window',
         'extra-wide-window',
-        'nwp-window',
-        'nwp-tight-window',
-        'nwp-eta-breakdown',
+        # 'nwp-window',
+        # 'nwp-tight-window',
+        # 'nwp-eta-breakdown',
     ]
-    all_cut_plots(all_cuts + ['old-seeding'])
-    single_cut_plots('extra-wide-window')
+    all_cut_plots(all_cuts+['old-seeding'])
     # for cut in all_cuts:
     #     single_cut_plots(cut)
 

+ 1 - 1
plotting/filval-python

@@ -1 +1 @@
-Subproject commit a181009b251c6b28d21a65c6d480c116e72384e1
+Subproject commit 14749a106da96a39d35c923ae91a7c5a957794d9

+ 3 - 1
plotting/publish.py

@@ -1,12 +1,14 @@
 #!/usr/bin/env python
 from datetime import datetime as dt
 from subprocess import run
+from glob import glob
 
 dir_name = f'seeding_studies_{dt.strftime(dt.now(), "%Y_%m_%d_%H")}'
 remote = 'caleb@fangmeier.tech:/var/www/eg/'
 run(('rm', '-rf', dir_name))
 run(('mkdir', '-p', dir_name+'/output'))
-run(('cp', '-r', '../hists', dir_name))
+for gdir in glob('../hists*'):
+    run(('cp', '-r', gdir, dir_name))
 run(('cp', '-r', 'output', dir_name))
 
 run(('scp', '-r', dir_name, remote))