Browse Source

Introduces new version of filval plotting routines, as well as new plots
for even/odd ladder resolutions for SC extrapolated tracks

Caleb Fangmeier 7 years ago
parent
commit
eedd54167a
4 changed files with 243 additions and 295 deletions
  1. 207 270
      analysis/plots.py
  2. 33 24
      analysis/templates/dashboard.htm
  3. 1 1
      filval
  4. 2 0
      mk_tags.sh

+ 207 - 270
analysis/plots.py

@@ -5,277 +5,139 @@ import matplotlib.pyplot as plt
 
 from filval.result_set import ResultSet
 from filval.histogram_utils import hist, hist2d, hist_slice
-from filval.plotter import make_plot, plot_registry, hist_plot, hist2d_plot
+from filval.plotter import (decl_plot, save_plots, hist_plot, hist2d_plot, Plot)
 
 
-@make_plot(scale=0.85)
-def first_hits_v_eta(rs):
+@decl_plot
+def plot_residual(rs, var, layer, hit, projection=None):
     r'''
-    Plots of $\Delta \phi$, $\Delta z$, and $\Delta r$ vs $\eta$ between RecHit and SimHit for
-    the first matched hit in the seed.
+    Plots of $\Delta \phi$, $\Delta z$, or $\Delta r$ (vs $\eta$) between RecHit
+    and SimHit for the nth hit in the matched seed.
     '''
-
-    plt.subplot(321)
-    hist2d_plot(hist2d(rs.dphi_v_eta_first_hits_in_B1),
-                ylabel=r"$\Delta \phi_1$(rad)",
-                title="BPIX - Layer 1")
-
-    plt.subplot(322)
-    hist2d_plot(hist2d(rs.dphi_v_eta_first_hits_in_B2),
-                title="BPIX - Layer 2")
-
-    plt.subplot(323)
-    hist2d_plot(hist2d(rs.dz_v_eta_first_hits_in_B1),
-                ylabel=r"$\Delta \textrm{z}_1$(cm)",
-                )
-
-    plt.subplot(324)
-    hist2d_plot(hist2d(rs.dz_v_eta_first_hits_in_B2))
-
-    plt.subplot(325)
-    hist2d_plot(hist2d(rs.dr_v_eta_first_hits_in_B1),
-                ylabel=r"$\Delta r_1$(cm)",
-                xlabel=r"$\eta$"
-                )
-
-    plt.subplot(326)
-    hist2d_plot(hist2d(rs.dr_v_eta_first_hits_in_B2),
-                xlabel=r"$\eta$"
-                )
-
-
-@make_plot(scale=0.85)
-def second_hits_v_eta(rs):
-    plt.subplot(321)
-    hist2d_plot(hist2d(rs.dphi_v_eta_second_hits_in_B2),
-                ylabel=r"$\Delta \phi_2$(rad)",
-                title="BPIX - Layer 2")
-
-    plt.subplot(322)
-    hist2d_plot(hist2d(rs.dphi_v_eta_second_hits_in_B3),
-                title="BPIX - Layer 3")
-
-    plt.subplot(323)
-    hist2d_plot(hist2d(rs.dz_v_eta_second_hits_in_B2),
-                ylabel=r"$\Delta \textrm{z}_2$(cm)")
-
-    plt.subplot(324)
-    hist2d_plot(hist2d(rs.dz_v_eta_second_hits_in_B3))
-
-    plt.subplot(325)
-    hist2d_plot(hist2d(rs.dr_v_eta_second_hits_in_B2),
-                ylabel=r"$\Delta r_2$(cm)",
-                xlabel=r"$\eta$")
-
-    plt.subplot(326)
-    hist2d_plot(hist2d(rs.dr_v_eta_second_hits_in_B3),
-                xlabel=r"$\eta$")
-
-
-@make_plot(scale=0.85)
-def first_hits(rs):
-    plt.subplot(321)
-    hist_plot(hist(rs.dphi_v_eta_first_hits_in_B1.ProjectionY()),
-              include_errors=True, xlabel=r"$\Delta \phi_1$(rad)",
-              title="BPIX - Layer 1")
-
-    plt.subplot(322)
-    hist_plot(hist(rs.dphi_v_eta_first_hits_in_B2.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta \phi_1$(rad)",
-              title="BPIX - Layer 2")
-
-    plt.subplot(323)
-    hist_plot(hist(rs.dz_v_eta_first_hits_in_B1.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta z_1$(cm)")
-
-    plt.subplot(324)
-    hist_plot(hist(rs.dz_v_eta_first_hits_in_B2.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta z_1$(cm)")
-
-    plt.subplot(325)
-    hist_plot(hist(rs.dr_v_eta_first_hits_in_B1.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta r_1$(cm)")
-
-    plt.subplot(326)
-    hist_plot(hist(rs.dr_v_eta_first_hits_in_B2.ProjectionY()),
-              include_errors=True,
-              xlabel="r$\Delta r_1$(cm)")
-
-
-@make_plot(scale=0.85)
-def second_hits(rs):
-    plt.subplot(321)
-    hist_plot(hist(rs.dphi_v_eta_second_hits_in_B2.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta \phi_2$(rad)",
-              title="BPIX - Layer 2")
-
-    plt.subplot(322)
-    hist_plot(hist(rs.dphi_v_eta_second_hits_in_B3.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta \phi_2$(rad)",
-              title="BPIX - Layer 3")
-
-    plt.subplot(323)
-    hist_plot(hist(rs.dz_v_eta_second_hits_in_B2.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta z_2$(cm)")
-
-    plt.subplot(324)
-    hist_plot(hist(rs.dz_v_eta_second_hits_in_B3.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta z_2$(cm)")
-
-    plt.subplot(325)
-    hist_plot(hist(rs.dr_v_eta_second_hits_in_B2.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta r_2$(cm)")
-
-    plt.subplot(326)
-    hist_plot(hist(rs.dr_v_eta_second_hits_in_B3.ProjectionY()),
-              include_errors=True,
-              xlabel=r"$\Delta r_2$(cm)")
-
-
-@make_plot(scale=0.85)
-def delta_phi_z_v_ladder(rs):
-    def even_odd_plot(even, odd, var, scale, unit, **kwargs):
-        even_dist = even.ProjectionY()
-        odd_dist = odd.ProjectionY()
-        hist_plot(hist(even_dist), include_errors=True, label="even ladders")
-        hist_plot(hist(odd_dist), include_errors=True, color='r', label="odd ladders",
-                  **kwargs)
-
-        even_mean = even_dist.GetMean()*scale
-        odd_mean = odd_dist.GetMean()*scale
-        axes = plt.gca()
-        txt = r"$ \hat{{\Delta {0} }}_{{1,\textrm{{ {1} }} }}={2:4.2g}${3}"
-        axes.text(0.05, .7, txt.format(var, "odd", odd_mean, unit), transform=axes.transAxes)
-        axes.text(0.05, .6, txt.format(var, "even", even_mean, unit), transform=axes.transAxes)
-    plt.subplot(221)
-    even_odd_plot(rs.dphi_v_eta_first_hits_in_B1_even_ladder, rs.dphi_v_eta_first_hits_in_B1_odd_ladder,
-                  r"\phi", 10**6, "urad", xlabel=r"$\Delta \phi_1$(rad)", title="BPIX - Layer 1")
-
-    plt.subplot(222)
-    even_odd_plot(rs.dphi_v_eta_first_hits_in_B2_even_ladder, rs.dphi_v_eta_first_hits_in_B2_odd_ladder,
-                  r"\phi", 10**6, "urad", xlabel=r"$\Delta \phi_1$(rad)", title="BPIX - Layer 2")
+    h = {('z', 'B1', 1): rs.dz_v_eta_first_hits_in_B1,
+         ('z', 'B2', 1): rs.dz_v_eta_first_hits_in_B2,
+         ('phi', 'B1', 1): rs.dphi_v_eta_first_hits_in_B1,
+         ('phi', 'B2', 1): rs.dphi_v_eta_first_hits_in_B2,
+         ('z', 'B2', 2): rs.dz_v_eta_second_hits_in_B2,
+         ('z', 'B3', 2): rs.dz_v_eta_second_hits_in_B3,
+         ('phi', 'B2', 2): rs.dphi_v_eta_second_hits_in_B2,
+         ('phi', 'B3', 2): rs.dphi_v_eta_second_hits_in_B3,
+         }[(var, layer, hit)]
+    varlabel = {('z', 1): r"$\Delta z_1(\mu \mathrm{m})$",
+                ('z', 2): r"$\Delta z_2(\mu \mathrm{m})$",
+                ('phi', 1): r"$\Delta \phi_1(\mathrm{millirad})$",
+                ('phi', 2): r"$\Delta \phi_2(\mathrm{millirad})$"
+                }[(var, hit)]
+    scale = {'z': 10**4,  # cm -> um
+             'phi': 10**3  # rad -> millirad
+             }[var]
+    if projection == 'y':  # projecting onto var axis
+        h = h.ProjectionY()
+        hist_plot(hist(h, rescale_x=scale), xlabel=varlabel)
+    elif projection == 'x':  # projecting onto eta axis
+        h = h.ProjectionX()
+        hist_plot(hist(h), xlabel=r'$\eta$')
+    else:
+        hist2d_plot(hist2d(h, rescale_y=scale), ylabel=varlabel, xlabel=r"$\eta$")
+    plt.text(0.9, 0.9, layer,
+             bbox={'facecolor': 'white', 'alpha': 0.7},
+             transform=plt.gca().transAxes)
+
+
+@decl_plot
+def plot_residuals_v_ladder(rs, var, layer):
+    even, odd = {('phi', 'B1'): (rs.dphi_v_eta_first_hits_in_B1_even_ladder, rs.dphi_v_eta_first_hits_in_B1_odd_ladder),
+                 ('phi', 'B2'): (rs.dphi_v_eta_first_hits_in_B2_even_ladder, rs.dphi_v_eta_first_hits_in_B2_odd_ladder),
+                 ('z', 'B1'): (rs.dz_v_eta_first_hits_in_B1_even_ladder, rs.dz_v_eta_first_hits_in_B1_odd_ladder),
+                 ('z', 'B2'): (rs.dz_v_eta_first_hits_in_B2_even_ladder, rs.dz_v_eta_first_hits_in_B2_odd_ladder),
+                 }[(var, layer)]
+    unit = {'phi': 'urad',
+            'z': 'um',
+            }[var]
+    fmt_var = {'phi': r'\phi',
+               'z': 'z',
+               }[var]
+    scale = {'phi': 10**6,
+             'z': 10**4,
+             }[var]
+    xlabel = {'phi': r'$\Delta \phi_1$(rad)',
+              'z': r"$\Delta z_1$(cm)",
+              }[var]
+    even = even.ProjectionY()
+    odd = odd.ProjectionY()
+    hist_plot(hist(even), include_errors=True, label='even ladders')
+    hist_plot(hist(odd), include_errors=True, color='r', label='odd ladders')
+    plt.xlabel(xlabel)
+
+    even_mean = even.GetMean()*scale
+    odd_mean = odd.GetMean()*scale
+    txt = r'$ \hat{{\Delta {0} }}_{{1,\textrm{{ {1} }} }}={2:4.2g}${3}'
+    plt.text(0.05, .8, txt.format(fmt_var, 'odd', odd_mean, unit), transform=plt.gca().transAxes)
+    plt.text(0.05, .7, txt.format(fmt_var, 'even', even_mean, unit), transform=plt.gca().transAxes)
     plt.legend()
 
-    plt.subplot(223)
-    even_odd_plot(rs.dz_v_eta_first_hits_in_B1_even_ladder, rs.dz_v_eta_first_hits_in_B1_odd_ladder,
-                  "z", 10**4, "um", xlabel=r"$\Delta z_1$(cm)")
-
-    plt.subplot(224)
-    even_odd_plot(rs.dz_v_eta_first_hits_in_B2_even_ladder, rs.dz_v_eta_first_hits_in_B2_odd_ladder,
-                  "z", 10**4, "um", xlabel=r"$\Delta z_1$(cm)")
-
 
-@make_plot(scale=0.85)
-def sc_extrapolation_first(rs):
+@decl_plot
+def sc_extrapolation_first(rs, var, layer, hit, even_odd, log=False, norm=None, cut=None):
     ''' Raphael's plots '''
-    norm = 1
     errors = True
 
-    def preproc(h):
-        return hist_slice(hist(h.ProjectionY()), (-0.07, 0.07))
-    plt.subplot(221)
-    hist_plot(hist(rs.sc_first_hits_in_B1_dz.ProjectionY()),
-              include_errors=errors,
-              norm=norm,
-              log=False,
-              xlabel=r"$\Delta z_1$(cm)",
-              title="BPIX - Layer 1")
-
-    plt.subplot(222)
-    hist_plot(hist(rs.sc_first_hits_in_B2_dz.ProjectionY()),
-              include_errors=errors,
-              norm=norm,
-              log=False,
-              xlabel=r"$\Delta z_1$(cm)",
-              title="BPIX - Layer 2")
-
-    plt.subplot(223)
-    hist_plot(preproc(rs.sc_first_hits_in_B1_dphi),
-              include_errors=errors,
-              norm=norm,
-              log=False,
-              # ylim=(0.5E-3, 5),
-              xlabel=r"$\Delta \phi_1$(rad)",
-              # xlim=(-0.06, 0.06)
-              )
-
-    plt.subplot(224)
-    hist_plot(preproc(rs.sc_first_hits_in_B2_dphi),
-              include_errors=errors,
+    # def preproc(h):
+    #     return hist_slice(hist(h.ProjectionY()), (-0.07, 0.07))
+    # hist_plot(hist(rs.sc_first_hits_in_B1_dz.ProjectionY()),
+    #           include_errors=errors,
+    #           norm=norm,
+    #           log=log,
+    #           xlabel=r"$\Delta z_1$(cm)",
+    #           title="BPIX - Layer 1")
+
+    h = {('phi', 'B1', 1, 'either'): rs.sc_first_hits_in_B1_dphi_either,
+         ('phi', 'B2', 1, 'either'): rs.sc_first_hits_in_B2_dphi_either,
+         ('z', 'B1', 1, 'either'): rs.sc_first_hits_in_B1_dz_either,
+         ('z', 'B2', 1, 'either'): rs.sc_first_hits_in_B2_dz_either,
+         ('phi', 'B2', 2, 'either'): rs.sc_second_hits_in_B2_dphi_either,
+         ('phi', 'B3', 2, 'either'): rs.sc_second_hits_in_B3_dphi_either,
+         ('z', 'B2', 2, 'either'): rs.sc_second_hits_in_B2_dz_either,
+         ('z', 'B3', 2, 'either'): rs.sc_second_hits_in_B3_dz_either,
+
+         ('phi', 'B1', 1, 'even'): rs.sc_first_hits_in_B1_dphi_even,
+         ('phi', 'B2', 1, 'even'): rs.sc_first_hits_in_B2_dphi_even,
+         ('z', 'B1', 1, 'even'): rs.sc_first_hits_in_B1_dz_even,
+         ('z', 'B2', 1, 'even'): rs.sc_first_hits_in_B2_dz_even,
+         ('phi', 'B2', 2, 'even'): rs.sc_second_hits_in_B2_dphi_even,
+         ('phi', 'B3', 2, 'even'): rs.sc_second_hits_in_B3_dphi_even,
+         ('z', 'B2', 2, 'even'): rs.sc_second_hits_in_B2_dz_even,
+         ('z', 'B3', 2, 'even'): rs.sc_second_hits_in_B3_dz_even,
+
+         ('phi', 'B1', 1, 'odd'): rs.sc_first_hits_in_B1_dphi_odd,
+         ('phi', 'B2', 1, 'odd'): rs.sc_first_hits_in_B2_dphi_odd,
+         ('z', 'B1', 1, 'odd'): rs.sc_first_hits_in_B1_dz_odd,
+         ('z', 'B2', 1, 'odd'): rs.sc_first_hits_in_B2_dz_odd,
+         ('phi', 'B2', 2, 'odd'): rs.sc_second_hits_in_B2_dphi_odd,
+         ('phi', 'B3', 2, 'odd'): rs.sc_second_hits_in_B3_dphi_odd,
+         ('z', 'B2', 2, 'odd'): rs.sc_second_hits_in_B2_dz_odd,
+         ('z', 'B3', 2, 'odd'): rs.sc_second_hits_in_B3_dz_odd,
+         }[(var, layer, hit, even_odd)]
+    scale = {'phi': 10**6,
+             'z': 10**4,
+             }[var]
+    varlabel = {('z', 1): r"$\Delta z_1(\mu \mathrm{m})$",
+                ('z', 2): r"$\Delta z_2(\mu \mathrm{m})$",
+                ('phi', 1): r"$\Delta \phi_1(\mathrm{millirad})$",
+                ('phi', 2): r"$\Delta \phi_2(\mathrm{millirad})$"
+                }[(var, hit)]
+
+    h = hist(h.ProjectionY(), rescale_x=scale)
+    if cut:
+        h = hist_slice(h, (-cut, cut))
+    hist_plot(h,
+              include_errors=True,
+              log=log,
               norm=norm,
-              log=False,
-              # ylim=(0.5E-3, 5),
-              xlabel=r"$\Delta \phi_1$(rad)",
-              # xlim=(-0.06, 0.06)
-              )
-
+              xlabel=varlabel)
 
-@make_plot(scale=0.85)
-def sc_extrapolation_second(rs):
-    from scipy.stats import norm
 
-    def gauss(x, A, mu, sigma):
-        return A*norm.pdf(x, mu, sigma)
-
-    def gauss2(x, A1, mu1, sigma1, A2, mu2, sigma2):
-        return (A1*norm.pdf(x, mu1, sigma1) +
-                A2*norm.pdf(x, mu2, sigma2))
-
-    integral = 1
-    errors = True
-
-    def preproc(h, slice_=None):
-        h = hist(h.ProjectionY())
-        if slice_:
-            h = hist_slice(h, slice_)
-        return h
-
-    plt.subplot(221)
-    hist_plot(preproc(rs.sc_second_hits_in_B2_dz),
-              include_errors=errors,
-              norm=integral,
-              log=False,
-              fit=(gauss2, (1, 0, 0.025, 1, 0, 0.005)),
-              xlabel=r"$\Delta z_2$(cm)",
-              title="BPIX - Layer 2")
-
-    plt.subplot(222)
-    hist_plot(preproc(rs.sc_second_hits_in_B3_dz),
-              include_errors=errors,
-              norm=integral,
-              log=False,
-              fit=(gauss2, (1, 0, 0.025, 1, 0, 0.005)),
-              xlabel=r"$\Delta z_2$(cm)",
-              title="BPIX - Layer 3")
-
-    plt.subplot(223)
-    hist_plot(preproc(rs.sc_second_hits_in_B2_dphi, (-0.09, 0.09)),
-              include_errors=errors,
-              norm=integral,
-              log=False,
-              fit=(gauss2, (1, 0, 0.015, 1, 0, 0.005)),
-              xlabel=r"$\Delta \phi_2$(rad)")
-
-    plt.subplot(224)
-    hist_plot(preproc(rs.sc_second_hits_in_B3_dphi, (-0.09, 0.09)),
-              include_errors=errors,
-              norm=integral,
-              log=False,
-              fit=(gauss2, (1, 0, 0.025, 1, 0, 0.005)),
-              xlabel=r"$\Delta \phi_2$(rad)")
-
-
-
-def generate_dashboard():
+def generate_dashboard(plots):
     from jinja2 import Environment, PackageLoader, select_autoescape
     from os.path import join
     from urllib.parse import quote
@@ -290,15 +152,16 @@ def generate_dashboard():
             template = env.get_template(template_name)
             tempout.write(template.render(**kwargs))
 
-
     def get_by_n(l, n=2):
         l = list(l)
         while l:
             yield l[:n]
             l = l[n:]
 
-    render_to_file('dashboard.htm', plots=get_by_n(plot_registry.values(), 3),
-                   quote=quote)
+    render_to_file('dashboard.htm', plots=get_by_n(plots, 3),
+                   outdir="figures/",
+                   quote=quote,
+                   enumerate=enumerate)
 
 
 if __name__ == '__main__':
@@ -308,12 +171,86 @@ if __name__ == '__main__':
         raise ValueError("please supply root file")
     rs = ResultSet("DY2LL", sys.argv[1])
 
-    first_hits_v_eta(rs)
-    second_hits_v_eta(rs)
-    first_hits(rs)
-    second_hits(rs)
-    delta_phi_z_v_ladder(rs)
-    sc_extrapolation_first(rs)
-    sc_extrapolation_second(rs)
-
-    generate_dashboard()
+    # Next, declare all of the (sub)plots that will be assembled into full
+    # figures later
+    dphi1_v_eta_B1 = (plot_residual, (rs, 'phi', 'B1', 1), {})
+    dphi1_v_eta_B2 = (plot_residual, (rs, 'phi', 'B2', 1), {})
+    dz1_v_eta_B1 = (plot_residual, (rs, 'z', 'B1', 1), {})
+    dz1_v_eta_B2 = (plot_residual, (rs, 'z', 'B2', 1), {})
+
+    dphi2_v_eta_B2 = (plot_residual, (rs, 'phi', 'B2', 2), {})
+    dphi2_v_eta_B3 = (plot_residual, (rs, 'phi', 'B3', 2), {})
+    dz2_v_eta_B2 = (plot_residual, (rs, 'z', 'B2', 2), {})
+    dz2_v_eta_B3 = (plot_residual, (rs, 'z', 'B3', 2), {})
+
+    projectY = {'projection': 'y'}
+    dphi1_B1 = (plot_residual, (rs, 'phi', 'B1', 1), projectY)
+    dphi1_B2 = (plot_residual, (rs, 'phi', 'B2', 1), projectY)
+    dz1_B1 = (plot_residual, (rs, 'z', 'B1', 1), projectY)
+    dz1_B2 = (plot_residual, (rs, 'z', 'B2', 1), projectY)
+
+    dphi2_B2 = (plot_residual, (rs, 'phi', 'B2', 2), projectY)
+    dphi2_B3 = (plot_residual, (rs, 'phi', 'B3', 2), projectY)
+    dz2_B2 = (plot_residual, (rs, 'z', 'B2', 2), projectY)
+    dz2_B3 = (plot_residual, (rs, 'z', 'B3', 2), projectY)
+
+    projectX = {'projection': 'x'}
+    eta1_B1 = (plot_residual, (rs, 'phi', 'B1', 1), projectX)
+    eta1_B2 = (plot_residual, (rs, 'phi', 'B2', 1), projectX)
+    eta2_B2 = (plot_residual, (rs, 'phi', 'B2', 2), projectX)
+    eta2_B3 = (plot_residual, (rs, 'phi', 'B3', 2), projectX)
+
+    dphi1_v_ladder_B1 = (plot_residuals_v_ladder, (rs, 'phi', 'B1'), {})
+    dphi1_v_ladder_B2 = (plot_residuals_v_ladder, (rs, 'phi', 'B2'), {})
+    dz1_v_ladder_B1 = (plot_residuals_v_ladder, (rs, 'z', 'B1'), {})
+    dz1_v_ladder_B2 = (plot_residuals_v_ladder, (rs, 'z', 'B2'), {})
+
+    dphi1_sc_ex_B1 = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'either'), {'log': True, 'norm': 1.0})
+    dphi1_sc_ex_B2 = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'either'), {'log': True, 'norm': 1.0})
+    dz1_sc_ex_B1 = (sc_extrapolation_first, (rs, 'z', 'B1', 1, 'either'), {'norm': 1.0})
+    dz1_sc_ex_B2 = (sc_extrapolation_first, (rs, 'z', 'B2', 1, 'either'), {'norm': 1.0})
+
+    dphi1_sc_ex_B1_even = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'even'), {'log': True, 'norm': 1.0})
+    dphi1_sc_ex_B2_even = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'even'), {'log': True, 'norm': 1.0})
+    dz1_sc_ex_B1_even = (sc_extrapolation_first, (rs, 'z', 'B1', 1, 'even'), {'norm': 1.0})
+    dz1_sc_ex_B2_even = (sc_extrapolation_first, (rs, 'z', 'B2', 1, 'even'), {'norm': 1.0})
+
+    dphi1_sc_ex_B1_odd = (sc_extrapolation_first, (rs, 'phi', 'B1', 1, 'odd'), {'log': True, 'norm': 1.0})
+    dphi1_sc_ex_B2_odd = (sc_extrapolation_first, (rs, 'phi', 'B2', 1, 'odd'), {'log': True, 'norm': 1.0})
+    dz1_sc_ex_B1_odd = (sc_extrapolation_first, (rs, 'z', 'B1', 1, 'odd'), {'norm': 1.0})
+    dz1_sc_ex_B2_odd = (sc_extrapolation_first, (rs, 'z', 'B2', 1, 'odd'), {'norm': 1.0})
+
+    # Now assemble the plots into figures.
+    plots = [Plot([[dphi1_v_eta_B1, dphi1_v_eta_B2],
+                   [dz1_v_eta_B1,   dz1_v_eta_B2  ]],
+                  'res1_v_eta'),
+             Plot([[dphi2_v_eta_B2, dphi2_v_eta_B3],
+                   [dz2_v_eta_B2,   dz2_v_eta_B3  ]],
+                  'res2_v_eta'),
+             Plot([[dphi1_B1, dphi1_B2],
+                   [dz1_B1,   dz1_B2  ]],
+                  'res1'),
+             Plot([[eta1_B1, eta1_B2],
+                   [eta2_B2, eta2_B3  ]],
+                  'eta_dist'),
+             Plot([[dphi2_B2, dphi2_B3],
+                   [dz2_B2,   dz2_B3  ]],
+                  'res2'),
+             Plot([[dphi1_v_ladder_B1, dphi1_v_ladder_B2],
+                   [dz1_v_ladder_B1,   dz1_v_ladder_B2]],
+                  'res_v_ladder'),
+             Plot([[dphi1_sc_ex_B1, dphi1_sc_ex_B2],
+                   [dz1_sc_ex_B1, dz1_sc_ex_B2]],
+                  'sc_ex_1'),
+             Plot([[dphi1_sc_ex_B1_even, dphi1_sc_ex_B2_even],
+                   [dz1_sc_ex_B1_even, dz1_sc_ex_B2_even]],
+                  'sc_ex_1_even'),
+             Plot([[dphi1_sc_ex_B1_odd, dphi1_sc_ex_B2_odd],
+                   [dz1_sc_ex_B1_odd, dz1_sc_ex_B2_odd]],
+                  'sc_ex_1_odd'),
+             ]
+
+    # Finally, render and save the plots and generate the html+bootstrap
+    # dashboard to view them
+    save_plots(plots)
+    generate_dashboard(plots)

+ 33 - 24
analysis/templates/dashboard.htm

@@ -19,40 +19,49 @@ MathJax.Hub.Config({
 </head>
 <body>
 <div class="container-fluid">
-  {% for plot_row in plots %}
+{% for r, plot_row in enumerate(plots) %}
   <div class="row">
-    {% for plot in plot_row %}
+  {% for c, plot in enumerate(plot_row) %}
     <div class="col-md-4">
       <div class="well">
-        {% if plot.title %}
+    {% if plot.title %}
         <h3 class="text-center">{{ plot.title }}</h3>
-        {% endif %}
-        <a href="{{ plot.filename }}"><img src="{{ plot.filename }}" style="width:100%"></a>
+    {% endif %}
+        <a href="{{ outdir+plot.name+".png" }}"><img src="{{ outdir+plot.name+".png" }}" style="width:100%"></a>
         <div class="caption">
           <p class="text-center"> {{ plot.name }} </p>
-          {% if plot.desc %}
-          <hr>
-          <p class="text-left">{{ plot.desc|safe }}</p>
-          <hr>
-          {% endif %}
-          {% if plot.args %}
-          <p class="text-left"><strong>Plot Arguments</strong></p>
-          <table class="table table-hover">
-            <tbody>
-              {% for key, val in plot.args.items() %}
-              <tr>
-                <td>{{ key }}</td> <td>{{ val }}</td>
-              </tr>
-              {% endfor %}
-            </tbody>
-          </table>
-          {% endif %}
+          <div class="panel-group" id="accordion">
+    {% for id, ((i,j), doc) in enumerate(plot.docs.items()) %}
+            <div class="panel-heading">
+              <h4 class="panel-title">
+                <button data-toggle="collapse" data-parent="#accordion" class="btn btn-info" href="#collapse{{r}}-{{c}}-{{id}}">
+                  Plot at ({{i+1}}, {{j+1}})</button>
+              </h4>
+            </div>
+            <div id="collapse{{r}}-{{c}}-{{id}}" class="panel-collapse collapse">
+              <div class="panel-body">
+                <p class="text-left">{{ doc|safe }}</p>
+                <hr>
+                <p class="text-left"><strong>Plot Arguments</strong></p>
+                <table class="table table-hover">
+                  <tbody>
+      {% for key, val in plot.argdict[(i,j)].items() %}
+                    <tr>
+                      <td>{{ key }}</td> <td>{{ val }}</td>
+                    </tr>
+      {% endfor %}
+                  </tbody>
+                </table>
+              </div>
+            </div>
+    {% endfor %}
+          </div>
         </div>
       </div>
     </div>
-    {% endfor %}
-  </div>
   {% endfor %}
+  </div>
+{% endfor %}
 </div>
 </body>
 </html>

+ 1 - 1
filval

@@ -1 +1 @@
-Subproject commit 8fe4cbd0fe9636e6a421d18df688bc942455551b
+Subproject commit beb797bd8c0e9052921923841a9a8f2756338c95

+ 2 - 0
mk_tags.sh

@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+ctags -R analysis -R filval -R $(root-config --incdir)