Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify output hierarchy and update rate plot configs #60

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions configs/V29/rate_plots/all_rate_plots.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions configs/V29/rate_plots/eg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
EGRates:
sample: MinBias
version: V29
test_objects:
- EG:default
- tkElectron:NoIso
- tkElectron:Iso
- tkPhoton:Iso
binning:
min: 10
max: 97
step: 3
11 changes: 11 additions & 0 deletions configs/V29/rate_plots/ht.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HTRates:
sample: MinBias
version: V29
test_objects:
- phase1PuppiHT:default
- seededConePuppiHT:default
- trackerHT:default
binning:
min: 50
max: 975
step: 25
27 changes: 27 additions & 0 deletions configs/V29/rate_plots/jets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
JetDefaultRates:
sample: MinBias
version: V29
test_objects:
- phase1PuppiJet:default
- seededConePuppiJet:default
# - seededConeExtendedPuppiJet:default
- trackerJet:default
# - caloJet:default
binning:
min: 40
max: 420
step: 20

JetsByRegion:
sample: MinBias
version: V29
test_objects:
- phase1PuppiJet:default:barrel
- phase1PuppiJet:default:endcap
- seededConePuppiJet:default:barrel
- seededConePuppiJet:default:endcap
binning:
min: 40
max: 420
step: 20

10 changes: 10 additions & 0 deletions configs/V29/rate_plots/met.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
METRates:
sample: MinBias
version: V29
test_objects:
- puppiMET:default
- trackerMET:default
binning:
min: 50
max: 500
step: 25
22 changes: 22 additions & 0 deletions configs/V29/rate_plots/muons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
gmtMuonByRegion:
sample: MinBias
version: V29
test_objects:
- gmtMuon:default:barrel
- gmtMuon:default:overlap
- gmtMuon:default:endcap
binning:
min: 0
max: 75
step: 3

MuonRates:
sample: MinBias
version: V29
test_objects:
- gmtMuon:default
- gmtTkMuon:default
binning:
min: 0
max: 75
step: 3
23 changes: 23 additions & 0 deletions configs/V29/rate_plots/taus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
TauRates:
sample: MinBias
version: V29
test_objects:
- nnTau:default
- caloTau:default
binning:
min: 10
max: 155
step: 5

TauRatesByRegion:
sample: MinBias
version: V29
test_objects:
- caloTau:default:barrel
- caloTau:default:endcap
- nnTau:default:barrel
- nnTau:default:endcap
binning:
min: 10
max: 155
step: 5
23 changes: 12 additions & 11 deletions menu_tools/object_performance/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@


class Plotter:
outdir_base = "outputs/object_performance/"

def _make_output_dirs(self, version: str) -> None:
os.makedirs(f"{self.outdir_base}/{version}/turnons", exist_ok=True)
os.makedirs(f"{self.outdir_base}/{version}/distributions", exist_ok=True)
os.makedirs(f"{self.outdir_base}/{version}/scalings", exist_ok=True)
os.makedirs(f"outputs/{version}/object_performance/turnons", exist_ok=True)
os.makedirs(
f"outputs/{version}/object_performance/distributions", exist_ok=True
)
os.makedirs(f"outputs/{version}/object_performance/scalings", exist_ok=True)

def _create_new_plot(self) -> tuple[plt.Figure, plt.Axes]:
fig, ax = plt.subplots(figsize=(10, 10))
Expand All @@ -44,11 +44,13 @@ def __init__(self, name, cfg, turnon_collection):

@property
def _outdir_turnons(self) -> str:
return os.path.join(self.outdir_base, self.version, "turnons")
return os.path.join("outputs", self.version, "object_performance", "turnons")

@property
def _outdir_distributions(self) -> str:
return os.path.join(self.outdir_base, self.version, "distributions")
return os.path.join(
"outputs", self.version, "object_performance", "distributions"
)

def _style_plot(self, fig, ax, legend_loc="lower right"):
ax.axvline(self.threshold, ls=":", c="k")
Expand Down Expand Up @@ -393,8 +395,9 @@ def plot(self):
ax.set_ylim(0, np.max(y_points))

plot_fname = os.path.join(
self.outdir_base,
"outputs",
self.version,
"object_performance",
"scalings",
f"{self.plot_name}_{self.version}",
)
Expand All @@ -412,8 +415,6 @@ def plot(self):


class ScalingCentral:
outdir = "outputs/object_performance/"

def __init__(self, cfg_plots_path: str) -> None:
with open(cfg_plots_path, "r") as f:
self.cfg_plots = yaml.safe_load(f)
Expand Down Expand Up @@ -453,8 +454,8 @@ def _write_scalings_to_file(self, obj: Object, params: np.ndarray) -> None:
"""
fpath = os.path.join(
"outputs",
"object_performance",
obj.version,
"object_performance",
"scalings",
)
os.makedirs(fpath, exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion menu_tools/object_performance/tests/test_turnons_v29.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_matching_plots_reproduced(test_name):

# Load result and assert correct outcome
with open(
f"outputs/object_performance/V29/turnons/{test_name}.json",
f"outputs/V29/object_performance/turnons/{test_name}.json",
"r",
) as f:
test_result = json.load(f)
Expand Down
2 changes: 1 addition & 1 deletion menu_tools/utils/scalings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def load_scaling_params(obj: Object, eta_range: str) -> tuple[float, float]:
"""
fname = str(obj).replace("inclusive", eta_range)
fpath = os.path.join(
"outputs", "object_performance", obj.version, "scalings", fname + ".yaml"
"outputs", obj.version, "object_performance", "scalings", fname + ".yaml"
)
try:
with open(fpath, "r") as f:
Expand Down
Loading