Cutflow tables#

Part 4 of 4 in Summarise Data

✓ 01. Histograms
✓ 02. Render Histograms
✓ 03. Two-Dimensional Histograms
▶ 04. Cutflow Tables

This tutorial turns the dimuon event selection into a cutflow product and a rendered table.

It uses the same selection ideas introduced in tutorials/02-transform-data/02-object-selections, now with EventWeight so the cutflow tracks weighted data/MC yields.

1. Inspect the selection#

The selection keeps candidate dimuon events:

selection:
  dimuon_candidates:
    - "NIsolatedMuon >= 2"
    - "triggerIsoMu24 == 1"
    - "HasMuonAbove25"

Each requirement is evaluated in sequence. FAST-HEP records how many events pass each step, producing a cutflow artifact.

Unlike the earlier object-selection tutorial, this workflow applies EventWeight, so the cutflow tracks weighted data and Monte Carlo yields as well as simple event counts.

2. Inspect the style file#

styles.yaml keeps visual presentation separate from analysis logic. For this tutorial the style is tiny because the renderer writes a CSV-style cutflow table:

styles:
  event_selection_cutflow:
    op: hep.render.cutflow_csv

Just as histogram renderers convert histogram products into plots, the cutflow renderer converts a machine-readable cutflow artifact into a table that can be inspected directly or imported into other tools.

3. Run the workflow#

pixi run fasthep run tutorials/03-summarise-data/04-cutflow-tables/author.yaml --outdir build/tutorials/03-summarise-data/04-cutflow-tables

4. Inspect the outputs#

Look at:

  • build/tutorials/03-summarise-data/04-cutflow-tables/artifacts/cutflows/

  • build/tutorials/03-summarise-data/04-cutflow-tables/artifacts/tables/

  • build/tutorials/03-summarise-data/04-cutflow-tables/render/

  • build/tutorials/03-summarise-data/04-cutflow-tables/run_summary.yaml

The cutflow artifact records the full machine-readable selection history, including the order of cuts and the event yields after each step.

The rendered table is a human-readable view of the same information.

As with histogram rendering, the cutflow and its presentation are kept separate. This allows the same cutflow artifact to be rendered in different formats without rerunning the analysis.

Expected outputs#

The compact cutflow snippet shows the selection logic and weighted yields recorded in the machine-readable artifact.

{
  "label": "NIsolatedMuon >= 2",
  "selection": "dimuon_candidates",
  "stats": [
    {
      "dataset": "data",
      "n_in": 469384.0,
      "n_out": 16208.0,
      "n_unweighted_in": 469384,
      "n_unweighted_out": 16208,
      "sumw2_in": 469384.0,
      "sumw2_out": 16208.0,
      "sumw_in": 469384.0,
      "sumw_out": 16208.0
    }
  ]
}

The CSV table is rendered from the same cutflow artifact:

selection,cut,dataset,n_in,n_out,n_unweighted_in,n_unweighted_out,sumw_in,sumw_out,sumw2_in,sumw2_out,efficiency
dimuon_candidates,NIsolatedMuon >= 2,data,469384.0,16208.0,469384,16208,469384.0,16208.0,469384.0,16208.0,0.03453036319942734
dimuon_candidates,NIsolatedMuon >= 2,dy,34115.5078125,16829.44921875,77729,37559,34115.5078125,16829.44921875,21186.4375,9284.119140625,0.48320446680132256
dimuon_candidates,NIsolatedMuon >= 2,qcd,79160.5078125,0.0,142,0,79160.5078125,0.0,3075498752.0,0.0,0.0
dimuon_candidates,NIsolatedMuon >= 2,single_top,311.62298583984375,5.748311996459961,5684,111,311.62298583984375,5.748311996459961,19.59632110595703,0.3327018618583679,0.01952850105559465
dimuon_candidates,NIsolatedMuon >= 2,ttbar,7929.47607421875,51.6297492980957,36941,226,7929.47607421875,51.6297492980957,2067.39208984375,13.769474029541016,0.0061178636203676135
dimuon_candidates,NIsolatedMuon >= 2,wjets,209603.5625,0.3119172751903534,109737,1,209603.5625,0.3119172751903534,474947.4375,0.09729238599538803,9.11269672034045e-06
dimuon_candidates,NIsolatedMuon >= 2,ww,229.94956970214844,12.639495849609375,4580,244,229.94956970214844,12.639495849609375,13.77381706237793,0.7602576017379761,0.05327510917030567
dimuon_candidates,NIsolatedMuon >= 2,wz,69.92791748046875,13.157758712768555,3367,623,69.92791748046875,13.157758712768555,1.7318625450134277,0.3263869881629944,0.18503118503118504
dimuon_candidates,NIsolatedMuon >= 2,zz,16.922521591186523,8.998815536499023,2421,1235,16.922521591186523,8.998815536499023,0.14007407426834106,0.07490068674087524,0.510119785212722
dimuon_candidates,triggerIsoMu24 == 1,data,16208.0,16208.0,16208,16208,16208.0,16208.0,16208.0,16208.0,1.0
dimuon_candidates,triggerIsoMu24 == 1,dy,16829.44921875,16829.44921875,37559,37559,16829.44921875,16829.44921875,9284.119140625,9284.119140625,1.0
dimuon_candidates,triggerIsoMu24 == 1,qcd,0.0,0.0,0,0,0.0,0.0,0.0,0.0,
dimuon_candidates,triggerIsoMu24 == 1,single_top,5.748311996459961,5.748311996459961,111,111,5.748311996459961,5.748311996459961,0.3327018618583679,0.3327018618583679,1.0
dimuon_candidates,triggerIsoMu24 == 1,ttbar,51.6297492980957,47.29368591308594,226,206,51.6297492980957,47.29368591308594,13.769474029541016,12.597925186157227,0.911504424778761
dimuon_candidates,triggerIsoMu24 == 1,wjets,0.3119172751903534,0.3119172751903534,1,1,0.3119172751903534,0.3119172751903534,0.09729238599538803,0.09729238599538803,1.0
dimuon_candidates,triggerIsoMu24 == 1,ww,12.639495849609375,12.639495849609375,244,244,12.639495849609375,12.639495849609375,0.7602576017379761,0.7602576017379761,1.0
dimuon_candidates,triggerIsoMu24 == 1,wz,13.157758712768555,13.157758712768555,623,623,13.157758712768555,13.157758712768555,0.3263869881629944,0.3263869881629944,1.0
dimuon_candidates,triggerIsoMu24 == 1,zz,8.998815536499023,8.998815536499023,1235,1235,8.998815536499023,8.998815536499023,0.07490068674087524,0.07490068674087524,1.0
dimuon_candidates,HasMuonAbove25,data,16208.0,15995.0,16208,15995,16208.0,15995.0,16208.0,15995.0,0.9868583415597236
dimuon_candidates,HasMuonAbove25,dy,16829.44921875,16628.84375,37559,37263,16829.44921875,16628.84375,9284.119140625,9023.5546875,0.9921190660028222
dimuon_candidates,HasMuonAbove25,qcd,0.0,0.0,0,0,0.0,0.0,0.0,0.0,
dimuon_candidates,HasMuonAbove25,single_top,5.748311996459961,5.676234722137451,111,110,5.748311996459961,5.676234722137451,0.3327018618583679,0.3275066316127777,0.990990990990991
dimuon_candidates,HasMuonAbove25,ttbar,47.29368591308594,47.29368591308594,206,206,47.29368591308594,47.29368591308594,12.597925186157227,12.597925186157227,1.0
dimuon_candidates,HasMuonAbove25,wjets,0.3119172751903534,0.3119172751903534,1,1,0.3119172751903534,0.3119172751903534,0.09729238599538803,0.09729238599538803,1.0
dimuon_candidates,HasMuonAbove25,ww,12.639495849609375,12.577849388122559,244,243,12.639495849609375,12.577849388122559,0.7602576017379761,0.7564573287963867,0.9959016393442623
dimuon_candidates,HasMuonAbove25,wz,13.157758712768555,13.157758712768555,623,623,13.157758712768555,13.157758712768555,0.3263869881629944,0.3263869881629944,1.0
dimuon_candidates,HasMuonAbove25,zz,8.998815536499023,8.985803604125977,1235,1232,8.998815536499023,8.985803604125977,0.07490068674087524,0.07481058686971664,0.9975708502024292