/cms:trigger-efficiencyfrom cms
Measures HLT trigger efficiency in CMS NanoAOD analyses using the reference-trigger method. Computes turn-on curves vs offline variables (m_jj, HT, pT) with Clopper-Pearson uncertainties and determines plateau thresholds.
Ships in cms. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
An analysis trigger (or an OR of paths) is efficient only above some offline
threshold. Measure the efficiency in data with a reference trigger that
is independent of the signal paths, plot it against the offline variable the
analysis cuts on, and cut where it has plateaued. On NanoAOD each HLT path is
a boolean branch HLT_<name>. Offline kinematics are in GeV.
scripts/list_hlt_paths.py shows which paths a file has and how often they fire. scripts/turnon.py holds the efficiency, threshold and plotting helpers, plus a demo that measures the 2016 dijet turn-on from JetHT Open Data.
summary.json or a notemuon-tag-and-probe skill (and the POG correctionlib JSON)| Term | Meaning |
|---|---|
| Signal trigger(s) | Paths the analysis selects events with; usually an OR of the lowest unprescaled jet/HT paths |
| Reference trigger | Lower-threshold path (often prescaled) or an orthogonal-dataset path, fully efficient where the signal turns on |
| Denominator | Events passing the full offline selection and the reference trigger |
| Numerator | Denominator events that also fire the signal OR |
| Clopper-Pearson (CP) | Exact binomial interval; correct at ε → 1 where the Gaussian error goes to 0 |
| Plateau / threshold | Lowest bin edge above which every populated bin has CP upper bound ≥ target, the pooled ε ≥ target, and ≥ min_events reference events |
Prescales cancel in the ratio because numerator and denominator come from the same events. Never take the numerator from one dataset and the denominator from another.
source /cvmfs/sft.cern.ch/lcg/views/LCG_109/x86_64-el9-gcc15-opt/setup.sh
<skill>/scripts/list_hlt_paths.py <one file per run era> --match '^(PFJet|PFHT|AK8PFJet|CaloJet)[0-9]'
# # files=2 events=200000 match=...
# 0.21907 21907 HLT_PFHT800 (absent in 1/2 files) fraction over the files that have the path
# 0.11594 23188 HLT_PFHT900
Save the output (> hlt_paths_2016G.txt) as evidence of which menu you saw.
Run it on one file from every era you use. The output is the menu as
stored, which is the ground truth. Twikis list what was planned. In 2016,
HLT_PFHT800 is a branch in Run2016G files but is absent from Run2016H
files (tested).
import sys; sys.path.insert(0, "<skill>/scripts")
from turnon import efficiency, find_threshold, plateau, plot_turnon
# per chunk: offline selection first, then the trigger bits of the SAME events
ref = offline_sel & events["HLT_PFJet260"]
sigs = [t for t in SIGNAL if t in events.fields] # some eras lack some paths
fired = np.logical_or.reduce([events[t] for t in sigs])
den += np.histogram(mjj[ref], edges)[0]
num += np.histogram(mjj[ref & fired], edges)[0]
e = efficiency(num, den) # eff, lo, hi (68% CP); NaN where den == 0
thr, i = find_threshold(e, edges, target=0.995, min_events=100) # state target and min_events with the result
eff, lo, hi, n = plateau(e, i) # pooled efficiency above thr
plot_turnon(ax, e, edges, "ref. HLT_PFJet260", color="k")
plot_turnon(ax, e2, edges, "ref. HLT_PFHT475", dx=6, xerr=False, fmt="s") # offset cross-check overlay
DIJET_EDGES in turnon.py is the full CMS dijet bin table (1–14000 GeV).
Slice it for the turn-on range, and use the same table for the fit so the
threshold is a bin edge. For HEPData or JSON, keep only bins with den > 0;
the efficiency is NaN elsewhere.
Accumulate counts, not efficiencies, over chunks, files and condor jobs. Add
num and den and form the ratio once at the end.
HLT_PFHT475,
HLT_PFJet400). The plateau and threshold should agree.validation/dijet-2016/summary.json (all 142 files):
threshold 1058 GeV, plateau 0.99928 (+0.00012 −0.00015), 45776 ref. events.F=$(for era in Run2016G Run2016H; do
xrdfs root://eospublic.cern.ch ls -R /eos/opendata/cms/$era/JetHT/NANOAOD/UL2016_MiniAODv2_NanoAODv9-v1 \
| grep '\.root$' | sort | head -3 | sed "s|^|root://eospublic.cern.ch/|"; done)
<skill>/scripts/turnon.py --demo $F --out turnon.png # target 0.99
# THRESHOLD_GEV=1058 PLATEAU=0.99873 PLATEAU_LO=0.99705 PLATEAU_HI=0.99955 N_REF_ABOVE=1572
Tested on cmslpc (LCG_109): 6 files, 75 s, 2 GB RSS. It reproduces the threshold of the full 142-file validation. The demo skips the golden JSON and event filters, so use it as a check, not as a result.
KeyError: 'HLT_PFHT800' (or any path) when reading several eras: the
branch exists only in some files. Build the path list per file from
tree.keys() and OR only the present ones.sqrt(ε(1−ε)/n).
Use Clopper-Pearson (scipy.stats.beta.ppf, as in turnon.py).errorbar draws nothing or warns when a bin has den == 0: ε is NaN.
Mask empty bins before plotting (plot_turnon does). Never write NaN to
HEPData or JSON.efficiency() raises on this.min_events) and quote the pooled plateau.no plateau found (exit 1 from the demo) on one file: the prescaled
reference has only a few hundred events per file above 1 TeV. Use more
files.tree.iterate(cols, step_size=...)). The demo peaks at 2 GB for 6 JetHT files.--match, --json; exit 1 if none match).clopper_pearson, efficiency,
find_threshold, plateau, plot_turnon, the CMS dijet bin edges, and
the --demo.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cms, nanoaod, trigger-efficiency, turn-on-curve, clopper-pearson, hlt
npx claudepluginhub cms-ml/marketplace --plugin cms10 skills in this plugin
/analysis-spec-builderUse when a user wants to plan, scope or write down a CMS physics analysis or plotting task before coding it: creating or updating an analysis specification, turning a quick request ("plot the dimuon mass in 2016 data vs DY", "find the best trijet in ttbar") into a structured document, listing datasets, triggers, selections, histograms, corrections and statistical treatment, or producing a specification.md for later implementation./awkward-arrayUse when working with jagged or variable-length arrays in Python with Awkward Array 2 (import awkward as ak): reading CMS NanoAOD or other ROOT ntuples into arrays with uproot, building per-object records with ak.zip, selecting objects or events with masks, counting with ak.num or ak.count, pairing objects with ak.combinations or ak.cartesian (dilepton masses, deltaR, jet cleaning), taking the leading object or argmax per event, following NanoAOD index branches such as Jet_muonIdx1, flattening for histograms, writing Parquet or JSON, or debugging awkward errors such as "cannot slice", "index out of range" or None values appearing in results./cmsswUse when setting up or working inside a CMSSW release area (cmsrel, cmsenv, scram), choosing a CMSSW release or SCRAM_ARCH for a dataset, running an old release inside a cmssw-el7/el8 container, checking out or patching CMSSW packages with git cms-addpkg or git cms-merge-topic, writing or building an EDAnalyzer, EDProducer or EDFilter, writing or debugging a cmsRun Python configuration (_cfg.py, _cfi.py, _cff.py), inspecting EDM ROOT files (MiniAOD, AOD, RECO) with edm* tools, or installing extra Python packages on top of a CMSSW release./combineUse when working with CMS Combine (HiggsAnalysis-CombinedLimit): writing or debugging a datacard or physics model, choosing or running a Combine method (AsymptoticLimits, FitDiagnostics, MultiDimFit, HybridNew, Significance, GoodnessOfFit, ChannelCompatibilityCheck, Impacts), interpreting Combine output, explaining a Combine error message or warning, asking how or why Combine does something, or running a Combine command (combine, text2workspace.py, combineCards.py, combineTool.py) to reproduce, diagnose or confirm a result./hepdataUse when preparing, writing, validating or reviewing a HEPData record for a CMS paper, PAS, or an Open Data study: converting spectra, efficiencies, cutflows, fit results, limits or hist/ROOT histograms into HEPData YAML with hepdata_lib, filling keywords, qualifiers and asymmetric uncertainties, running hepdata-validate, uploading to the HEPData sandbox, following the CMS (EXO, B2G) HEPData and reinterpretation requirements, or debugging errors such as "Got unexpected extra argument", "takes 2 positional arguments", "The tar ball is not valid", "Inconsistent length of 'values' list" or .nan values in the YAML./histUse when creating, filling, slicing, rebinning, normalising or plotting histograms in Python with scikit-hep hist / boost-histogram and mplhep, especially from CMS NanoAOD arrays: choosing axes and binning for GeV quantities, weighted fills with genWeight (including negative weights), normalising MC to cross section times luminosity, categorical axes for regions, processes or systematics, UHI indexing, CMS-style plots with hep.cms.label, ratio panels, or errors such as "has no attribute 'Weight'", "Select 'histtype' from" or "cannot convert to RegularArray" when filling.Other plugins' skills for the same job