|
@@ -4,47 +4,108 @@ import matplotlib.pyplot as plt
|
|
|
|
|
|
from filval.result_set import ResultSet
|
|
|
from filval.histogram_utils import hist, hist_add, hist_normalize, hist_scale
|
|
|
-from filval.plotter import (decl_plot, render_plots, hist_plot, hist_plot_stack, Plot, generate_dashboard)
|
|
|
+from filval.plotter import (decl_plot, render_plots, hist_plot, hist_plot_stack,
|
|
|
+ Plot, generate_dashboard, hists_to_table)
|
|
|
|
|
|
+an_tttt = ([0.47, 0.33, 0.18, 0.78, 0.49, 0.52, 0.33, 0.49],
|
|
|
+ [0, 0, 0, 0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
+an_ttw = ([2.29663, 0.508494, 0.161166, 1.03811, 0.256401, 0.127582, 0.181522, 0.141659],
|
|
|
+ [0, 0, 0, 0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
+an_ttz = ([0.974751, 0.269195, 1e-06, 0.395831, 0.0264703, 0.06816, 0.8804, 0.274265],
|
|
|
+ [0, 0, 0, 0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
+an_tth = ([1.13826, 0.361824, 0.162123, 0.683917, 0.137608, 0.0632719, 0.554491, 0.197864],
|
|
|
+ [0, 0, 0, 0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
|
|
|
@decl_plot
|
|
|
-def plot_yield_grid(rss):
|
|
|
+def plot_yield_grid(rss, tau_category=-1):
|
|
|
r"""## Event Yield
|
|
|
|
|
|
The event yield for the eight signal regions defined in AN-17-115. Data is normalized
|
|
|
- to the Moriond 2018 integrated luminosity ($35.9\textrm{fb}^{-1}$). Code for the histogram generation is
|
|
|
- here: <https://github.com/cfangmeier/FTAnalysis/blob/master/studies/tau/Yield.C>
|
|
|
+ to the integrated luminosity of $35.9\textrm{fb}^{-1}$.
|
|
|
+
|
|
|
+ Ignoring taus means both that there is no requirement on number of good taus *and*
|
|
|
+ the taus, if present, are not considered for the SS pair.
|
|
|
+
|
|
|
+ If taus are not ignored, any good tau with $p_T$>20Gev is considered in constructing the SS lepton pair. The yields
|
|
|
+ are then further broken down by the number of good taus in the event.
|
|
|
+
|
|
|
+ A "good" tau in the above means any tau candidate passing the `byTightIsolationMVArun2v1DBoldDMwLT` ID w/ pt>20GeV.
|
|
|
+ It is also required to pass tau-lepton cross cleaning where it must not match any electron or muon within
|
|
|
+ $\delta R < 0.4$.
|
|
|
+
|
|
|
+ Truth-matched taus are those that match within $\delta R < 0.3$ with gen-level taus that pass the flag `fromHardProcessDecayed`.
|
|
|
"""
|
|
|
+
|
|
|
+ def get_sr(rs, tm=False):
|
|
|
+ if tm:
|
|
|
+ if tau_category == 0:
|
|
|
+ return hist(rs.SRs_0tmtau)
|
|
|
+ if tau_category == 1:
|
|
|
+ return hist(rs.SRs_1tmtau)
|
|
|
+ elif tau_category == 2:
|
|
|
+ return hist(rs.SRs_2tmtau)
|
|
|
+ else:
|
|
|
+ if tau_category == -1:
|
|
|
+ return hist(rs.ignore_tau_SRs)
|
|
|
+ elif tau_category == 0:
|
|
|
+ return hist(rs.SRs_0tau)
|
|
|
+ elif tau_category == 1:
|
|
|
+ return hist(rs.SRs_1tau)
|
|
|
+ elif tau_category == 2:
|
|
|
+ return hist(rs.SRs_2tau)
|
|
|
+
|
|
|
_, ((ax_tttt, ax_ttw), (ax_ttz, ax_tth)) = plt.subplots(2, 2)
|
|
|
- ft, ttw, ttz, tth = map(lambda rs: hist(rs.SRs), rss)
|
|
|
-
|
|
|
+ tttt, ttw, ttz, tth = [get_sr(rs) for rs in rss]
|
|
|
+ tm_tttt, tm_ttw, tm_ttz, tm_tth = [get_sr(rs, True) for rs in rss]
|
|
|
+
|
|
|
plt.sca(ax_tttt)
|
|
|
- an = ((0.47, 0.33, 0.18, 0.78, 0.49, 0.52, 0.33, 0.49),
|
|
|
- (0, 0, 0, 0, 0, 0, 0, 0), [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
- hist_plot(ft, title='TTTT', stats=False, label='Mock')
|
|
|
- hist_plot(an, title='TTTT', stats=False, label='AN')
|
|
|
+ hist_plot(tttt, title='TTTT', stats=False, label='Mock', include_errors=True)
|
|
|
+ if tau_category == -1:
|
|
|
+ hist_plot(an_tttt, title='TTTT', stats=False, label='AN')
|
|
|
+ elif tau_category >= 0:
|
|
|
+ hist_plot(tm_tttt, title='TTTT', stats=False, label='Truth-Matched Taus', include_errors=True)
|
|
|
+ plt.ylim((0, None))
|
|
|
|
|
|
plt.sca(ax_ttw)
|
|
|
- an = ([2.29663, 0.508494, 0.161166, 1.03811, 0.256401, 0.127582, 0.181522, 0.141659],
|
|
|
- [0, 0, 0, 0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
- hist_plot(ttw, title='TTW', stats=False, label='Mock')
|
|
|
- hist_plot(an, title='TTW', stats=False, label='AN')
|
|
|
+ hist_plot(ttw, title='TTW', stats=False, label='Mock', include_errors=True)
|
|
|
+ if tau_category == -1:
|
|
|
+ hist_plot(an_ttw, title='TTW', stats=False, label='AN')
|
|
|
+ elif tau_category >= 0:
|
|
|
+ hist_plot(tm_ttw, title='TTW', stats=False, label='Truth-Matched Taus', include_errors=True)
|
|
|
+ plt.ylim((0, None))
|
|
|
plt.legend()
|
|
|
|
|
|
plt.sca(ax_ttz)
|
|
|
- an = ([0.974751, 0.269195, 1e-06, 0.395831, 0.0264703, 0.06816, 0.8804, 0.274265],
|
|
|
- [0, 0, 0, 0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
- hist_plot(ttz, title='TTZ', stats=False, label='Mock')
|
|
|
- hist_plot(an, title='TTZ', stats=False, label='AN')
|
|
|
+ hist_plot(ttz, title='TTZ', stats=False, label='Mock', include_errors=True)
|
|
|
+ if tau_category == -1:
|
|
|
+ hist_plot(an_ttz, title='TTZ', stats=False, label='AN')
|
|
|
+ elif tau_category >= 0:
|
|
|
+ hist_plot(tm_ttz, title='TTZ', stats=False, label='Truth-Matched Taus', include_errors=True)
|
|
|
+ plt.ylim((0, None))
|
|
|
plt.xlabel('Signal Region')
|
|
|
|
|
|
plt.sca(ax_tth)
|
|
|
- an = ([1.13826, 0.361824, 0.162123, 0.683917, 0.137608, 0.0632719, 0.554491, 0.197864],
|
|
|
- [0, 0, 0, 0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
|
|
|
- hist_plot(tth, title='TTH', stats=False, label='Mock')
|
|
|
- hist_plot(an, title='TTH', stats=False, label='AN')
|
|
|
+ hist_plot(tth, title='TTH', stats=False, label='Mock', include_errors=True)
|
|
|
+ if tau_category == -1:
|
|
|
+ hist_plot(an_tth, title='TTH', stats=False, label='AN')
|
|
|
+ elif tau_category >= 0:
|
|
|
+ hist_plot(tm_tth, title='TTH', stats=False, label='Truth-Matched Taus', include_errors=True)
|
|
|
+ plt.ylim((0, None))
|
|
|
plt.xlabel('Signal Region')
|
|
|
|
|
|
+ def to_table(hists):
|
|
|
+ return hists_to_table(hists, row_labels=['TTTT', 'TTW', 'TTZ', 'TTH'],
|
|
|
+ column_labels=[f'SR{n}' for n in range(1, 9)])
|
|
|
+
|
|
|
+ tables = '<h2>Mock</h2>'
|
|
|
+ tables += to_table([tttt, ttw, ttz, tth])
|
|
|
+ if tau_category == -1:
|
|
|
+ tables += '<h2>AN</h2>'
|
|
|
+ tables += to_table([an_tttt, an_ttw, an_ttz, an_tth])
|
|
|
+ elif tau_category >= 0:
|
|
|
+ tables += '<h2>TM Taus</h2>'
|
|
|
+ tables += to_table([tm_tttt, tm_ttw, tm_ttz, tm_tth])
|
|
|
+ return tables
|
|
|
|
|
|
|
|
|
@decl_plot
|
|
@@ -89,6 +150,7 @@ def plot_lep_multi(rss, dataset):
|
|
|
_plot(ax_taus, taus)
|
|
|
plt.xlabel('\\# Good Taus')
|
|
|
|
|
|
+
|
|
|
@decl_plot
|
|
|
def plot_sig_strength(rss):
|
|
|
r""" The signal strength of the TTTT signal defined as
|
|
@@ -101,9 +163,11 @@ def plot_sig_strength(rss):
|
|
|
strength = ft[0] / np.sqrt(ft[0] + bg[0])
|
|
|
hist_plot((strength, ft[1], ft[2]), stats=False)
|
|
|
|
|
|
+
|
|
|
@decl_plot
|
|
|
-def plot_event_obs(rss, dataset):
|
|
|
- r"""
|
|
|
+def plot_event_obs(rss, dataset, in_signal_region=True):
|
|
|
+ r"""The distribution of $N_{jet}$, $N_{Bjet}$, MET, and $H_T$ in either all events
|
|
|
+ or only signal region (igoring taus) events.
|
|
|
|
|
|
"""
|
|
|
_, ((ax_njet, ax_nbjet), (ax_ht, ax_met)) = plt.subplots(2, 2)
|
|
@@ -116,10 +180,16 @@ def plot_event_obs(rss, dataset):
|
|
|
|
|
|
def _plot(ax, obs):
|
|
|
plt.sca(ax)
|
|
|
- h = {'MET': rs.met_in_SR,
|
|
|
- 'HT': rs.ht_in_SR,
|
|
|
- 'NJET': rs.njet_in_SR,
|
|
|
- 'NBJET': rs.nbjet_in_SR}[obs]
|
|
|
+ if in_signal_region:
|
|
|
+ h = {'MET': rs.met_in_SR,
|
|
|
+ 'HT': rs.ht_in_SR,
|
|
|
+ 'NJET': rs.njet_in_SR,
|
|
|
+ 'NBJET': rs.nbjet_in_SR}[obs]
|
|
|
+ else:
|
|
|
+ h = {'MET': rs.met,
|
|
|
+ 'HT': rs.ht,
|
|
|
+ 'NJET': rs.njet,
|
|
|
+ 'NBJET': rs.nbjet}[obs]
|
|
|
hist_plot(hist(h), stats=False, label=dataset, xlabel=obs)
|
|
|
|
|
|
_plot(ax_njet, 'NJET')
|
|
@@ -127,8 +197,9 @@ def plot_event_obs(rss, dataset):
|
|
|
_plot(ax_ht, 'HT')
|
|
|
_plot(ax_met, 'MET')
|
|
|
|
|
|
+
|
|
|
@decl_plot
|
|
|
-def plot_event_obs_stack(rss):
|
|
|
+def plot_event_obs_stack(rss, in_signal_region=True):
|
|
|
r"""
|
|
|
|
|
|
"""
|
|
@@ -136,10 +207,16 @@ def plot_event_obs_stack(rss):
|
|
|
|
|
|
def _plot(ax, obs):
|
|
|
plt.sca(ax)
|
|
|
- attr = {'MET': 'met_in_SR',
|
|
|
- 'HT': 'ht_in_SR',
|
|
|
- 'NJET': 'njet_in_SR',
|
|
|
- 'NBJET': 'nbjet_in_SR'}[obs]
|
|
|
+ if in_signal_region:
|
|
|
+ attr = {'MET': 'met_in_SR',
|
|
|
+ 'HT': 'ht_in_SR',
|
|
|
+ 'NJET': 'njet_in_SR',
|
|
|
+ 'NBJET': 'nbjet_in_SR'}[obs]
|
|
|
+ else:
|
|
|
+ attr = {'MET': 'met',
|
|
|
+ 'HT': 'ht',
|
|
|
+ 'NJET': 'njet',
|
|
|
+ 'NBJET': 'nbjet'}[obs]
|
|
|
ft, ttw, ttz, tth = map(lambda rs: hist(getattr(rs, attr)), rss)
|
|
|
hist_plot_stack([ttw, ttz, tth], labels=["TTW", "TTZ", "TTH"])
|
|
|
hist_plot(hist_scale(ft, 5), label="TTTT (x5)", color='k')
|
|
@@ -151,6 +228,7 @@ def plot_event_obs_stack(rss):
|
|
|
_plot(ax_ht, 'HT')
|
|
|
_plot(ax_met, 'MET')
|
|
|
|
|
|
+
|
|
|
@decl_plot
|
|
|
def plot_tau_purity(rss):
|
|
|
_, ((ax_ft, ax_ttw), (ax_ttz, ax_tth)) = plt.subplots(2, 2)
|
|
@@ -173,46 +251,73 @@ def plot_tau_purity(rss):
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
-
|
|
|
+
|
|
|
|
|
|
rss = (ResultSet("ft", 'data/yield_ft.root'),
|
|
|
ResultSet("ttw", 'data/yield_ttw.root'),
|
|
|
ResultSet("ttz", 'data/yield_ttz.root'),
|
|
|
ResultSet("tth", 'data/yield_tth.root'))
|
|
|
- rss_notau = (ResultSet("ft_notau", 'data/yield_ft_notau.root'),
|
|
|
- ResultSet("ttw_notau", 'data/yield_ttw_notau.root'),
|
|
|
- ResultSet("ttz_notau", 'data/yield_ttz_notau.root'),
|
|
|
- ResultSet("tth_notau", 'data/yield_tth_notau.root'))
|
|
|
|
|
|
|
|
|
|
|
|
- yield_tau = (plot_yield_grid, (rss,), {})
|
|
|
- yield_notau = (plot_yield_grid, (rss_notau,), {})
|
|
|
+ yield_tau_ignore_tau = plot_yield_grid, (rss, -1)
|
|
|
+ yield_tau_0tau = plot_yield_grid, (rss, 0)
|
|
|
+ yield_tau_1tau = plot_yield_grid, (rss, 1)
|
|
|
+ yield_tau_2tau = plot_yield_grid, (rss, 2)
|
|
|
|
|
|
- yield_tau_stack = (plot_yield_stack, (rss,), {})
|
|
|
- yield_notau_stack = (plot_yield_stack, (rss_notau,), {})
|
|
|
+ ft_event_obs_in_sr = plot_event_obs, (rss, 'TTTT'), {'in_signal_region': True}
|
|
|
+ ttw_event_obs_in_sr = plot_event_obs, (rss, 'TTW'), {'in_signal_region': True}
|
|
|
+ ttz_event_obs_in_sr = plot_event_obs, (rss, 'TTZ'), {'in_signal_region': True}
|
|
|
+ tth_event_obs_in_sr = plot_event_obs, (rss, 'TTH'), {'in_signal_region': True}
|
|
|
|
|
|
- sig_strength_tau = (plot_sig_strength, (rss,), {})
|
|
|
- sig_strength_notau = (plot_sig_strength, (rss_notau,), {})
|
|
|
+ ft_event_obs = plot_event_obs, (rss, 'TTTT'), {'in_signal_region': False}
|
|
|
+ ttw_event_obs = plot_event_obs, (rss, 'TTW'), {'in_signal_region': False}
|
|
|
+ ttz_event_obs = plot_event_obs, (rss, 'TTZ'), {'in_signal_region': False}
|
|
|
+ tth_event_obs = plot_event_obs, (rss, 'TTH'), {'in_signal_region': False}
|
|
|
|
|
|
- ft_lep_multi = (plot_lep_multi, (rss, 'TTTT'), {})
|
|
|
- ttw_lep_multi = (plot_lep_multi, (rss, 'TTW'), {})
|
|
|
- ttz_lep_multi = (plot_lep_multi, (rss, 'TTZ'), {})
|
|
|
- tth_lep_multi = (plot_lep_multi, (rss, 'TTH'), {})
|
|
|
+ ft_lep_multi = plot_lep_multi, (rss, 'TTTT')
|
|
|
+ ttw_lep_multi = plot_lep_multi, (rss, 'TTW')
|
|
|
+ ttz_lep_multi = plot_lep_multi, (rss, 'TTZ')
|
|
|
+ tth_lep_multi = plot_lep_multi, (rss, 'TTH')
|
|
|
|
|
|
- ft_event_obs = (plot_event_obs, (rss_notau, 'TTTT'), {})
|
|
|
- ttw_event_obs = (plot_event_obs, (rss_notau, 'TTW'), {})
|
|
|
- ttz_event_obs = (plot_event_obs, (rss_notau, 'TTZ'), {})
|
|
|
- tth_event_obs = (plot_event_obs, (rss_notau, 'TTH'), {})
|
|
|
-
|
|
|
- event_obs_stack = (plot_event_obs_stack, (rss_notau,), {})
|
|
|
-
|
|
|
- tau_purity = (plot_tau_purity, (rss,), {})
|
|
|
+
|
|
|
|
|
|
|
|
|
plots = [
|
|
|
-
|
|
|
-
|
|
|
+ Plot([[yield_tau_ignore_tau]],
|
|
|
+ 'Yield Ignoring Taus'),
|
|
|
+ Plot([[yield_tau_0tau]],
|
|
|
+ 'Yield For events with 0 Tau'),
|
|
|
+ Plot([[yield_tau_1tau]],
|
|
|
+ 'Yield For events with 1 Tau'),
|
|
|
+ Plot([[yield_tau_2tau]],
|
|
|
+ 'Yield For events with 2 or more Tau'),
|
|
|
+
|
|
|
+ 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_in_sr]],
|
|
|
+ 'TTTT - Event Observables (In SR)'),
|
|
|
+ Plot([[ttw_event_obs_in_sr]],
|
|
|
+ 'TTW - Event Observables (In SR)'),
|
|
|
+ Plot([[ttz_event_obs_in_sr]],
|
|
|
+ 'TTZ - Event Observables (In SR)'),
|
|
|
+ Plot([[tth_event_obs_in_sr]],
|
|
|
+ 'TTH - Event Observables (In SR)'),
|
|
|
+ Plot([[ft_event_obs]],
|
|
|
+ 'TTTT - Event Observables (All Events)'),
|
|
|
+ Plot([[ttw_event_obs]],
|
|
|
+ 'TTW - Event Observables (All Events)'),
|
|
|
+ Plot([[ttz_event_obs]],
|
|
|
+ 'TTZ - Event Observables (All Events)'),
|
|
|
+ Plot([[tth_event_obs]],
|
|
|
+ 'TTH - Event Observables (All Events)'),
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -225,29 +330,14 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
- Plot([[tau_purity]],
|
|
|
- 'Tau Purity'),
|
|
|
+
|
|
|
+
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
render_plots(plots, to_disk=False)
|
|
|
- generate_dashboard(plots, 'TTTT Yields', output='yield2.html', source_file=__file__)
|
|
|
+ generate_dashboard(plots, 'TTTT Yields', output='yield_breakout_4.html', source_file=__file__,
|
|
|
+ ana_source="https://github.com/cfangmeier/FTAnalysis/commit/46fc1afab42f6b04c9e21ba519e6a30524983550")
|