From atlas
Use when building an ATLAS statistical analysis with cabinetry: writing a cabinetry config file, building histogram templates from ROOT NTuples, constructing a pyhf workspace, running a profile likelihood fit, visualising pre/post-fit data-MC comparisons, producing pull plots and NP rankings, or computing CLs exclusion limits via cabinetry's high-level API.
How this skill is triggered — by the user, by Claude, or both
Slash command
/atlas:cabinetryThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
cabinetry is a high-level Python library that sits above pyhf and automates the
cabinetry is a high-level Python library that sits above pyhf and automates the workflow from ROOT NTuples → histogram templates → pyhf workspace → fit results → plots. It is driven by a YAML/JSON config file and is the recommended end-to-end framework for new ATLAS analyses using the Python stack.
NTuples (ROOT) → cabinetry templates → pyhf workspace → fit → plots
cabinetry.templates.build(config) — fills histograms from NTuplescabinetry.workspace.build(config) — creates HistFactory JSONcabinetry.fit.fit(model, data) — profile likelihood fitcabinetry.visualize.* — plotsGeneral:
HistogramFolder: "histograms/"
InputPath: "ntuples/{SamplePath}"
Regions:
- Name: "SR"
Filter: "n_bjets >= 2 and met > 200e3"
Variable: "meff"
Binning: [0, 500e3, 700e3, 1000e3, 1500e3, 2000e3]
- Name: "CR_top"
Filter: "n_bjets >= 2 and met < 150e3"
Variable: "meff"
Binning: [0, 500e3, 1000e3, 2000e3]
Samples:
- Name: "Data"
Data: true
SamplePath: "data/*.root"
- Name: "Signal"
SamplePath: "signal/signal.root"
NormFactor: "mu_sig"
- Name: "ttbar"
SamplePath: "ttbar/ttbar.root"
Systematics:
- Name: "JES"
Up:
SamplePath: "ttbar/ttbar_JES_up.root"
Down:
SamplePath: "ttbar/ttbar_JES_dn.root"
Type: NormPlusShape
Samples: "ttbar"
- Name: "Lumi"
Value: 0.015
Type: Normalization
Samples: ["Signal", "ttbar"]
Full workflow:
import cabinetry
config = cabinetry.configuration.load("config.yaml")
cabinetry.configuration.print_overview(config)
# Build histogram templates from NTuples
cabinetry.templates.build(config)
# Construct pyhf workspace
workspace = cabinetry.workspace.build(config)
cabinetry.workspace.save(workspace, "workspace.json")
# Build model and fit
model, data = cabinetry.model_utils.model_and_data(workspace)
fit_results = cabinetry.fit.fit(model, data)
Visualisation:
# Pre-fit data/MC
cabinetry.visualize.data_mc(config, figure_folder="figures/prefit/")
# Post-fit data/MC
cabinetry.visualize.data_mc(config, figure_folder="figures/postfit/", fit_results=fit_results)
# NP pulls
cabinetry.visualize.pulls(fit_results, figure_folder="figures/")
# NP ranking (impact on POI)
ranking_results = cabinetry.fit.ranking(model, data, fit_results=fit_results)
cabinetry.visualize.ranking(ranking_results, figure_folder="figures/")
CLs upper limit:
limit_results = cabinetry.fit.limit(model, data)
print(f"Observed limit: {limit_results.observed_limit:.2f}")
print(f"Expected limit: {limit_results.expected_limit[2]:.2f}") # median
Load a pre-built workspace directly (skip template building):
import json, pyhf
with open("workspace.json") as f:
ws = pyhf.Workspace(json.load(f))
model, data = cabinetry.model_utils.model_and_data(ws)
fit_results = cabinetry.fit.fit(model, data)
NormFactor on a sample inserts a free normfactor modifier — use for signal
μ and CR-driven backgroundsType: NormPlusShape creates separate norm and shape modifiers — correct for
most experimental systematicsType: Normalization (with Value) creates a normsys modifier — for
luminosity and cross-section uncertaintiesAddStatError: true (global option) adds Barlow-Beeston staterror to all binsVariable and Filtermet > 200e3, not
> 200)SamplePath glob patternsHistogramFolder has old files, build()
will use them. Delete the folder to force a rebuild.Up is specified, cabinetry mirrors it for
Down automaticallyHist objects instead of
NTuples via custom template providersnpx claudepluginhub usatlas/marketplace --plugin atlasGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.