Skip to content

Commit

Permalink
Updating ATLAS-FTAG-Tools package (#190)
Browse files Browse the repository at this point in the history
* Updating ATLAS-FTAG-Tools package

* Remove old flavour categories

* Add docstring and changelog

* Fixing changelog
  • Loading branch information
afroch authored Jun 30, 2023
1 parent 467f9b8 commit 35ad70d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 112 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### [Latest]

- Updating ATLAS-FTAG-Tools package [!190](https://github.com/umami-hep/puma/pull/190)
- Adding Data/MC Plots capabilities to the histogram classes [!187](https://github.com/umami-hep/puma/pull/187)

### [v0.2.6] (2023/06/01)
Expand Down
21 changes: 11 additions & 10 deletions puma/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ftag import Flavour, Flavours

from puma.plot_base import PlotBase, PlotLineObject
from puma.utils import get_good_colours, global_config, logger
from puma.utils import get_good_colours, get_hist_error_style_dict, logger
from puma.utils.histogram import hist_ratio, hist_w_unc


Expand Down Expand Up @@ -522,7 +522,7 @@ def plot(self, **kwargs):
bins=bins,
bottom=elem.band,
weights=elem.unc * 2,
**global_config["hist_err_style"],
**get_hist_error_style_dict(),
)

# Add standard "Line" to legend
Expand Down Expand Up @@ -562,13 +562,14 @@ def plot(self, **kwargs):
bins=bins,
bottom=self.stacked_dict["band"],
weights=self.stacked_dict["unc"] * 2,
**global_config["hist_err_style"],
**get_hist_error_style_dict(),
)

# Add label handle for the uncertainty
plt_handles.append(
mpl.patches.Patch(
label="stat. uncertainty", **global_config["hist_err_style"]
label="stat. uncertainty",
**get_hist_error_style_dict(),
)
)

Expand Down Expand Up @@ -753,9 +754,9 @@ def plot_ratios(self):
y2=np.nan_to_num(ratio + ratio_unc, nan=0, posinf=0),
step="pre",
facecolor="none",
edgecolor=global_config["hist_err_style"]["edgecolor"],
linewidth=global_config["hist_err_style"]["linewidth"],
hatch=global_config["hist_err_style"]["hatch"],
edgecolor=get_hist_error_style_dict()["edgecolor"],
linewidth=get_hist_error_style_dict()["linewidth"],
hatch=get_hist_error_style_dict()["hatch"],
)

if self.stacked and self.draw_errors:
Expand All @@ -765,9 +766,9 @@ def plot_ratios(self):
y2=np.nan_to_num((ratio + ratio_unc) / ratio, nan=0, posinf=0),
step="pre",
facecolor="none",
edgecolor=global_config["hist_err_style"]["edgecolor"],
linewidth=global_config["hist_err_style"]["linewidth"],
hatch=global_config["hist_err_style"]["hatch"],
edgecolor=get_hist_error_style_dict()["edgecolor"],
linewidth=get_hist_error_style_dict()["linewidth"],
hatch=get_hist_error_style_dict()["hatch"],
)

def add_bin_width_to_ylabel(self):
Expand Down
120 changes: 19 additions & 101 deletions puma/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
from puma.utils.logging import logger, set_log_level


def get_hist_error_style_dict():
"""
Return the histogram error style dict. This is needed
to define the style of the error bars around in the
histograms
Returns
-------
dict
Histogram error style dict
"""
return {
"fill": False,
"linewidth": 0,
"hatch": "/////",
"edgecolor": "#666666",
}


def set_xaxis_ticklabels_invisible(ax):
"""Helper function to set the ticklabels of the xaxis invisible
Expand Down Expand Up @@ -222,104 +241,3 @@ def get_good_linestyles(names=None):
"Invalid type of `names`, has to be a list of strings or a sting."
)
return [linestyle_tuples[name] for name in names]


# TODO: remove flavour_categories once not used in ummai
global_config = {
"flavour_categories": {
"bjets": {
"colour": "#1f77b4", # blue
"legend_label": "$b$-jets",
},
"cjets": {
"colour": "#ff7f0e", # orange
"legend_label": "$c$-jets",
},
"ujets": {
"colour": "#2ca02c", # green
"legend_label": "Light-jets",
},
"taujets": {
"colour": "#7c5295", # purple
"legend_label": "$\\tau$-jets",
},
"singlebjets": {
"colour": "#1f77b4", # blue (like b-jets)
"legend_label": "single-$b$ jets",
},
"bbjets": {
"colour": "#8E0024", # dark red
"legend_label": "$bb$-jets",
},
"singlecjets": {
"colour": "#ff7f0e", # orange (like c-jets)
"legend_label": "single-$c$ jets",
},
"ccjets": {
"colour": "#ad4305",
"legend_label": "$cc$-jets",
},
"upjets": {
"colour": "#9ed670",
"legend_label": "$u$-jets",
},
"djets": {
"colour": "#274e13",
"legend_label": "$d$-jets",
},
"sjets": {
"colour": "#00bfaf",
"legend_label": "$s$-jets",
},
"gluonjets": {
"colour": "#7b4e24",
"legend_label": "gluon-jets",
},
"lquarkjets": {
"colour": "#A05252",
"legend_label": "light-fl. jets w/o gluons",
},
"hadrcbjets": {
"colour": "#264653",
"legend_label": "hadronic $b$-hadron decay",
},
"lepcbjets": {
"colour": "#190099",
"legend_label": "leptonic $b$-hadron decay",
},
"singleebdecay": {
"colour": "#e9c46a",
"legend_label": "$e$'s in $b$- or $c$-hadron decay",
},
"singlemubdecay": {
"colour": "#f4a261",
"legend_label": "$\\mu$'s in $b$- or $c$-hadron decay",
},
"singletaubdecay": {
"colour": "#e76f51",
"legend_label": "$\\tau$'s in $b$- or $c$-hadron decay",
},
"Hbb": {
"colour": "#1f77b4", # blue
"legend_label": "$Hbb$-jets",
},
"Hcc": {
"colour": "#B45F06", # Tenne (dark orange)
"legend_label": "$Hcc$-jets",
},
"top": {
"colour": "#A300A3", # dark magenta
"legend_label": "$Top$-jets",
},
"QCD": {
"colour": "#38761D", # Bilbao (dark green)
"legend_label": "QCD-jets",
},
},
"hist_err_style": {
"fill": False,
"linewidth": 0,
"hatch": "/////",
"edgecolor": "#666666",
},
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ scipy==1.10.1
tables==3.7.0
testfixtures==7.0.0
palettable==3.3.0
atlas-ftag-tools==0.1.3
atlas-ftag-tools==0.1.5

0 comments on commit 35ad70d

Please sign in to comment.