瀏覽代碼

Moves dashboard template into filval

Caleb Fangmeier 6 年之前
父節點
當前提交
0d9439f70b
共有 5 個文件被更改,包括 34 次插入268 次删除
  1. 1 0
      .idea/vcs.xml
  2. 1 1
      filval
  3. 0 112
      plots.py
  4. 0 123
      templates/dashboard.htm
  5. 32 32
      yields.py

+ 1 - 0
.idea/vcs.xml

@@ -2,5 +2,6 @@
 <project version="4">
   <component name="VcsDirectoryMappings">
     <mapping directory="$PROJECT_DIR$" vcs="Git" />
+    <mapping directory="$PROJECT_DIR$/filval" vcs="Git" />
   </component>
 </project>

+ 1 - 1
filval

@@ -1 +1 @@
-Subproject commit 7824f845e477f6b37413bed3bfcc2df78eb84d51
+Subproject commit dc3a8bf6f559cb14e9c0643fe79df23436a0320d

+ 0 - 112
plots.py

@@ -1,112 +0,0 @@
-#!/usr/bin/env python
-import sys
-
-import matplotlib.pyplot as plt
-
-from filval.result_set import ResultSet
-from filval.histogram_utils import hist, hist2d, hist_slice, hist_add
-from filval.plotter import (decl_plot, render_plots, hist_plot, hist2d_plot, Plot)
-
-def generate_dashboard(plots, output='dashboard.htm'):
-    from jinja2 import Environment, PackageLoader, select_autoescape
-    from os.path import join
-    from urllib.parse import quote
-
-    env = Environment(
-        loader=PackageLoader('plots', 'templates'),
-        autoescape=select_autoescape(['htm', 'html', 'xml']),
-    )
-    env.globals.update({'quote': quote,
-                        'enumerate': enumerate,
-                        'zip': zip,
-                        })
-
-    def render_to_file(template_name, **kwargs):
-        with open(join('output', template_name), 'w') as tempout:
-            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(plots, 3),
-                   outdir="figures/")
-
-
-@decl_plot
-def plot_eff(rs, old):
-    r''' '''
-    if old:
-        accept = hist(rs.accept_eff)
-        reco = hist(rs.reco_eff)
-        id_ = hist(rs.id_eff_old)
-        ult = hist(rs.ult_eff_old)
-    else:
-        accept = hist(rs.accept_eff)
-        reco = hist(rs.reco_eff)
-        id_ = hist(rs.id_eff)
-        ult = hist(rs.ult_eff)
-    hist_plot(accept, include_errors=True, stats=False,
-              color='k', label='acceptance eff wrt gen')
-    hist_plot(reco, include_errors=True, stats=False,
-              color='g', label='reco eff wrt accept')
-    hist_plot(id_, include_errors=True, stats=False,
-              color='b', label='id eff wrt reco')
-    hist_plot(ult, include_errors=True, stats=False,
-              color='r', label='id eff wrt gen')
-    plt.xlabel('$p_T$(GeV)')
-    plt.legend()
-
-
-@decl_plot
-def plot_eta(rs):
-    r''' '''
-    gen_eta = hist(rs.gen_eta)
-    pf_eta = hist(rs.pf_eta)
-    hist_plot(gen_eta, include_errors=True, stats=False,
-              color='r', label='gen taus')
-    hist_plot(pf_eta, include_errors=True, stats=False,
-              color='g', label='pf taus(no id req)')
-    plt.xlabel(r'$\eta$')
-    plt.legend()
-
-
-if __name__ == '__main__':
-    # First create a ResultSet object which loads all of the objects from output.root
-    # into memory and makes them available as attributes
-    # if len(sys.argv) != 2:
-    #     raise ValueError("please supply root file")
-    rs_ft = ResultSet("ft", 'tau_ft.root')
-    rs_dy = ResultSet("dy", 'tau_dy.root')
-
-    # Next, declare all of the (sub)plots that will be assembled into full
-    # figures later
-    eff_ft = (plot_eff, (rs_ft, False), {})
-    eff_dy = (plot_eff, (rs_dy, False), {})
-
-    eff_ft_old = (plot_eff, (rs_ft, True), {})
-    eff_dy_old = (plot_eff, (rs_dy, True), {})
-
-    eta_ft = (plot_eta, (rs_ft,), {})
-    eta_dy = (plot_eta, (rs_dy,), {})
-
-    # Now assemble the plots into figures.
-    plots = [
-        Plot([[eff_ft],
-              [eff_dy]],
-             'eff_byTightIsolationMVArun2v1DBdR03oldDMwLT'),
-        Plot([[eff_ft_old],
-              [eff_dy_old]],
-             'eff_byTightIsolationMVArun2v1DBoldDMwLT'),
-        Plot([[eta_ft],
-              [eta_dy]],
-             'eta'),
-    ]
-
-    # Finally, render and save the plots and generate the html+bootstrap
-    # dashboard to view them
-    render_plots(plots, to_disk=False)
-    generate_dashboard(plots)

+ 0 - 123
templates/dashboard.htm

@@ -1,123 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <title>{{ title }}</title>
-  <meta charset="utf-8">
-  <meta name="viewport" content="width=device-width, initial-scale=2">
-  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
-  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
-  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-
-  <script src="https://tttt.fangmeier.tech/hl/shCore.js"         type="text/javascript"></script>
-  <script src="https://tttt.fangmeier.tech/hl/shBrushPython.js" type="text/javascript"></script>
-  <link href="https://tttt.fangmeier.tech/hl/shCore.css"          rel="stylesheet" type="text/css" />
-  <link href="https://tttt.fangmeier.tech/hl/shThemeDefault.css"  rel="stylesheet" type="text/css" />
-  <script src="https://tttt.fangmeier.tech/hl/shAutoloader.js" type="text/javascript"></script>
-
-<script type="text/x-mathjax-config">
-MathJax.Hub.Config({
-  config: ["MMLorHTML.js"],
-  jax: ["input/TeX", "output/HTML-CSS", "output/NativeMML"],
-  extensions: ["MathMenu.js", "MathZoom.js"]
-});
-</script>
-<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML-full"> </script>
-</head>
-<body>
-<div class="container-fluid">
-{% for r, plot_row in enumerate(plots) %}
-  <div class="row">
-  {% for c, plot in enumerate(plot_row) %}
-    <div class="col-md-4">
-      <div class="well">
-    {% if plot.title %}
-        <h3 class="text-center">{{ plot.title }}</h3>
-    {% endif %}
-        <div>
-          <a href="#" title="{{ plot.name }}">
-            <img src="data:img/png;base64,{{ plot.data }}" style="width:100%" class="thumbnail img-responsive">
-          </a>
-        </div>
-        <div class="caption">
-          <p class="text-center"> {{ plot.name }} </p>
-          <div class="panel-group" id="accordion">
-    {% for id, (i,j) in enumerate(plot.docs.keys()) %}
-            <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">
-      {% for doc, argdict in zip(plot.docs[(i,j)], plot.argdicts[(i,j)]) %}
-                <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 argdict.items() %}
-                    <tr>
-                      <td>{{ key }}</td> <td>{{ val }}</td>
-                    </tr>
-        {% endfor %}
-                  </tbody>
-                </table>
-      {% endfor %}
-              </div>
-            </div>
-    {% endfor %}
-          </div>
-        </div>
-      </div>
-    </div>
-  {% endfor %}
-  </div>
-{% endfor %}
-  <div class="row">
-    <div class="col-12-lg">
-      <div class="panel-group" id="accordion">
-        <div class="panel-heading">
-          <h4 class="panel-title" style="text-align:center">
-            <button data-toggle="collapse" data-parent="#accordion" class="btn btn-default" href="#collapseSrc">Figure Source Code</button>
-          </h4>
-        </div>
-        <div id="collapseSrc" class="panel-collapse collapse">
-          <div class="panel-body">
-<script type="syntaxhighlighter" class="brush: python"><![CDATA[ {{ source|safe}} ]]></script>
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-</div>
-<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
-  <div class="modal-dialog modal-lg">
-    <div class="modal-content">
-      <div class="modal-header">
-        <button type="button" class="close" data-dismiss="modal">×</button>
-        <h3 class="modal-title">Heading</h3>
-      </div>
-      <div class="modal-body">
-
-      </div>
-   </div>
-  </div>
-</div>
-</body>
-<style>
-.modal-dialog {width:900px;}
-.thumbnail {margin-bottom:6px;}
-.modal-title {text-align:center;}
-</style>
-<script>
-$('.thumbnail').click(function(){
-    $('.modal-body').empty();
-    var title = $(this).parent('a').attr("title");
-    $('.modal-title').html(title);
-    $($(this).parents('div').html()).appendTo('.modal-body');
-    $('#myModal').modal({show:true});
-});
-SyntaxHighlighter.all()
-</script>
-</html>

+ 32 - 32
yields.py

@@ -211,38 +211,38 @@ if __name__ == '__main__':
 
     # Now assemble the plots into figures.
     plots = [
-        Plot([[yield_tau]],
-             'Yield With Tau'),
-        Plot([[yield_notau]],
-             'Yield Without Tau'),
-        Plot([[yield_tau_stack]],
-             'Yield With Tau Stacked'),
-        Plot([[yield_notau_stack]],
-             'Yield Without Tau Stacked'),
-        Plot([[yield_tau_stack],
-              [yield_notau_stack]],
-             'Event Yield, top: with tau, bottom: no tau'),
-        Plot([[sig_strength_tau],
-              [sig_strength_notau]],
-             'Signal Strength'),
-        Plot([[ft_lep_multi]],
-             'Lepton Multiplicity - TTTT'),
-        Plot([[ttw_lep_multi]],
-             'Lepton Multiplicity - TTW'),
-        Plot([[ttz_lep_multi]],
-             'Lepton Multiplicity - TTZ'),
-        Plot([[tth_lep_multi]],
-             'Lepton Multiplicity - TTH'),
-        Plot([[ft_event_obs]],
-             'TTTT - Event Observables'),
-        Plot([[ttw_event_obs]],
-             'TTW - Event Observables'),
-        Plot([[ttz_event_obs]],
-             'TTZ - Event Observables'),
-        Plot([[tth_event_obs]],
-             'TTH - Event Observables'),
-        Plot([[event_obs_stack]],
-             'Event Observables'),
+        # Plot([[yield_tau]],
+        #      'Yield With Tau'),
+        # Plot([[yield_notau]],
+        #      'Yield Without Tau'),
+        # Plot([[yield_tau_stack]],
+        #      'Yield With Tau Stacked'),
+        # Plot([[yield_notau_stack]],
+        #      'Yield Without Tau Stacked'),
+        # Plot([[yield_tau_stack],
+        #       [yield_notau_stack]],
+        #      'Event Yield, top: with tau, bottom: no tau'),
+        # Plot([[sig_strength_tau],
+        #       [sig_strength_notau]],
+        #      'Signal Strength'),
+        # Plot([[ft_lep_multi]],
+        #      'Lepton Multiplicity - TTTT'),
+        # Plot([[ttw_lep_multi]],
+        #      'Lepton Multiplicity - TTW'),
+        # Plot([[ttz_lep_multi]],
+        #      'Lepton Multiplicity - TTZ'),
+        # Plot([[tth_lep_multi]],
+        #      'Lepton Multiplicity - TTH'),
+        # Plot([[ft_event_obs]],
+        #      'TTTT - Event Observables'),
+        # Plot([[ttw_event_obs]],
+        #      'TTW - Event Observables'),
+        # Plot([[ttz_event_obs]],
+        #      'TTZ - Event Observables'),
+        # Plot([[tth_event_obs]],
+        #      'TTH - Event Observables'),
+        # Plot([[event_obs_stack]],
+        #      'Event Observables'),
         Plot([[tau_purity]],
              'Tau Purity'),
     ]