Key Points
The Big Picture
- We’re teaching a computer to classify pairs of jets into Hbb / Hcc / QCD.
- We use simulated CMS data because it comes with a built-in answer key.
- MiniParT is a scaled-down version of a real particle physics AI architecture - small enough to fully understand, built the same way the real ones are.
Working in Google Colab
- Colab does not preinstall
uproot,fsspec-xrootd,awkward, orvector; install them with!pip installbefore running anything else in this lesson. -
uproot.open()on aroot://URL streams a CMS file directly from CERN’s servers, without downloading it. - This lesson uses three specific files, one each from the ttHTobb, ttHTocc, and QCD_bcToE CERN Open Data records.
- Always check
tree.num_entriesafter opening a file - a much smaller count than expected means it’s the wrong file.
The Complete Code
- This episode previews the complete pipeline, from reading raw CMS files to plotting results, with minimal explanation beyond notes on typical output.
- The episodes that follow build the same pipeline piece by piece, covering the physics and the code behind each part.
What Is a Jet?
- A jet is a spray of particles created when a quark flies out of a collision.
- We describe each jet with 10 numbers: 4 about its size/direction
(
pt,eta,phi,mass), 4 about what it’s made of (the energy fractions), and 2 about its structure (nConstituents,puId). - These numbers are read from public CMS NanoAOD files using
uproot. - DeepJet/DeepCSV tagger scores are deliberately excluded as features, so the model learns to separate Hbb/Hcc/QCD from basic information instead of copying an existing tagger’s answer.
Finding the Truth Labels
- Truth-level (
GenPart_*) columns exist only in simulation, and only get used to build labels, never fed to the model. - We find the Higgs boson’s daughter quarks by PDG ID (5 = bottom, 4 = charm) and mother ID (25 = Higgs).
- We match those truth quarks to real jets using ΔR, a “distance on
the sky” built from
etaandphi, using a 0.4 threshold that matches the jet clustering cone size. - QCD background just uses the two leading jets, since there’s no Higgs decay to match to.
Preparing the Data
- Combine all three datasets, then split 80/20 into train/test,
keeping the class proportions equal on both sides with
stratify. - Scale every feature to the same average-0, spread-1 footing, fitting the scaler only on training data.
- Convert to PyTorch tensors and feed the model small shuffled batches at a time, not the whole dataset at once.
- QCD examples slightly outnumber Hbb and Hcc examples after selection, because truth-matching discards more signal events than the QCD selection discards background events.
Building MiniParT
- The embedding layer translates each jet’s 10 raw numbers into a richer 64-number internal description.
- Self-attention lets the two jets exchange information about each other, using 4 parallel attention heads, repeated over 2 stacked layers.
- Mean pooling merges the two jets’ descriptions into one summary per event, and keeps the model’s answer independent of which jet was listed first.
- A small MLP turns that summary into 3 final class scores.
Training the Model
-
CrossEntropyLossgrades how wrong the model’s guesses are;AdamWdecides how to adjust the model’s weights in response. - Each batch follows the same six steps: clear old gradients, forward pass, compute loss, backpropagate, update weights.
- One full pass through all batches is an epoch; we repeat for several epochs so the model keeps improving.
- Training accuracy is a useful sanity check, but not a fair test, since it is measured on data the model has already seen.
Evaluating the Model
-
model.eval()+torch.no_grad()on the held-out test set gives an honest accuracy score, unlike training accuracy: typically around 71%. - A confusion matrix shows which classes get confused, not just overall accuracy: Hcc is predicted as Hbb more often than correctly identified, while Hbb/Hcc-to-QCD confusion stays small.
- ROC curves and AUC summarize the signal-vs-background tradeoff: QCD vs Rest (AUC ≈ 0.98) clearly beats Hbb vs Rest and Hcc vs Rest (both ≈ 0.83).
- The model’s internal 64-number “fingerprint,” averaged per class, can be checked with cosine similarity for genuine class separation; single-event comparisons are unreliable and can look backwards.