← Back to research
Detector simulationGeant4Particle identificationCoursework

Telling particles apart

I built a small CMS-style detector in Geant4 and asked it which particle was which. It can tell an electron from a muon. It cannot tell a pion from a kaon, five different ways, and the reason is in the physics.

Paolo Minhas · Project 3 of the DAML course, School of Physics and Astronomy, University of Edinburgh

6
layers: two trackers, RICH, two calorimeters, muon chamber
94%
of muons identified with the muon chamber
63%
of electrons identified, against a 70% target
≈50%
pion-versus-kaon accuracy, whichever method

01The task and the detector

The starting point was the two-layer tracker from the Week 6 Geant4 workshop. Each layer is a thin cylinder that records where a charged particle crosses it. I wrapped it in a 50 cm electromagnetic calorimeter of lead tungstate and a 1.9 m hadronic calorimeter, both Geant4 cylinders with their own sensitive detector that sums the energy deposited per event. A 2 T magnetic field runs along the beam so that tracks bend.

Two more layers came later: a thin ring of air outside everything as a muon chamber, and, for the last part, a cylinder of water between the trackers and the calorimeters to make Cherenkov light. The aim was to identify particles from the pattern of layers that fire, with a 70% efficiency as the target.

Interactive

Fire a particle through the detector

Schematic, not to scale

Fire at the same momentum

An electron showers in the ECAL and stops there: nearly all its energy shows up in that one layer.

ECAL. The electromagnetic calorimeter, a 50 cm lead-tungstate cylinder. It sums the energy deposited per event.

What the simulation measured

Identified correctly 63% of the time (flat 0.2 to 20 GeV), and never below about 2 GeV.

What each layer does for each particle is textbook behaviour, not simulation output. The percentages come from the project notebook.

In plain English

A detector never sees a particle. It sees where thin layers were crossed and how much energy thick layers soaked up. Naming the particle means reading that pattern the way you would name an animal from its footprints and how deep it sank in the mud.

02Reading momentum off a bent track

A charged particle in a magnetic field travels on a circle, and a bigger momentum means a flatter circle. With two tracker hits at 4 m and 8 m, the notebook turns the small difference in their azimuth angle, Δϕ\Delta\phi, into a momentum:

s=sin⁡(Δϕ) r1,R=r228s,pT=0.3 B R,p=pTsin⁡θs = \sin(\Delta\phi)\,r_1,\qquad R = \frac{r_2^{2}}{8s},\qquad p_T = 0.3\,B\,R,\qquad p = \frac{p_T}{\sin\theta}

The lab below runs those lines. Its two presets are the real track pairs from event 6 of the first run, and it prints the notebook’s recorded angle beside the one the formula predicts.

Interactive

Bend a track, read the momentum

tracker 1: 4 mtracker 2: 8 m

Plan view, drawn to scale. The dashed line is where the track would go with no field.

Start from

The simulation used 2 T.

Transverse momentum
45.39 GeV
Bending radius
75.7 m
Sagitta at 8 m
10.6 cm
Hit-to-hit angle Δφ
26.44 mrad

Against the notebook

The notebook recorded φ₁ = 2.61381, φ₂ = 2.58737, θ = 1.62829, so Δφ = 0.02644 rad; the formula above gives 0.02644 rad from the reconstructed 45.466 GeV. The reconstructed momentum is 45.466 GeV against a true 45.4997 GeV, a difference of -0.07%.

A track of transverse momentum pTp_T bends on a circle of radius R=pT/(0.3 B)R = p_T / (0.3\,B) metres, so it can only get 2R2R away from the centre. Reaching the outer tracker at 8 m therefore needs pT≥0.3 B r2/2p_T \ge 0.3\,B\,r_2/2: 2.4 GeV in a 2.0 T field. This track gets there.

In the first run, a file of lepton pairs with each lepton near 45.5 GeV, I paired hits in the two trackers by their polar angle and ran the formulas. Track pairs were found in 511 of the 2,000 events, and for most of them the rebuilt momentum is within about half a percent of the truth.

Momentum rebuilt from track curvature against the true momentum, first run: most events sit within about half a percent of zero, with a thin tail of under-estimates out to about −10%. Project 3 notebook.

03A beam that was too tidy

My first attempt at identification used that same file. A hand-written rule on the calorimeter share and the track momentum labelled 447 track pairs electrons, 397 muons and 58 photons, and left 378 unknown, against truth labels of 818, 443 and 19. That is not usable, and I put it down to the data rather than the rule: every lepton was near 45.5 GeV, so there was no energy dependence to study.

So I swapped the HepMC file reader for Geant4’s general particle source. A short macro fires one particle type from the centre, isotropically, with energies spread flat between 200 MeV and 20 GeV. That made the rest of the project possible: efficiency could now be measured as a function of energy.

04Electrons and muons

The first run of the new setup had electrons, muons and antimuons, 2,000 events in all. The rule was a single line: more than 1 GeV in the ECAL means electron, otherwise muon. An electron showers in the ECAL and leaves almost all its energy there; a muon passes through and leaves very little.

Real results

Electron or muon?

Which detectors the decision may use

Electrons identified63.4%

The rule: over 1 GeV in the ECAL means electron.

Muons identified84.9%

Everything below 1 GeV is called a muon, which is why muons look good.

Overall74.2%

The white tick is the 70% target set for the project. 2000 simulated events, energies flat between 0.2 and 20 GeV.

Muons look good because they are the default answer: anything that deposits under 1 GeV is called one. Electrons are the honest test, and at 63% they miss the 70% target. By energy the picture is stark: no electron below about 2 GeV is identified at all, and the efficiency only crosses 70% near 10 GeV.

Efficiency by energy with the ECAL alone. No electron below about 2 GeV is identified, so every low-energy particle is called a muon (which is why the muon curve sits at 1). Electrons pass the 70% target only above about 10 GeV. Project 3 notebook.
Energy deposited in the ECAL, electrons (blue) and muons (red), with the 1 GeV threshold. Muons pile up below it; electrons spread out to 20 GeV, but there is also a spike of electrons that deposited almost nothing. Project 3 notebook.

The muon chamber is the obvious fix for the muon side. A hit in the outer air layer, together with a track, means the particle got through everything, so any hit overrides the ECAL and calls it a muon. Muon identification rises from 85% to 94%, overall from 74% to 79%, and electrons do not change, because the chamber has nothing to say about them. Most of the gain is above about 5 GeV.

Efficiency with and without the muon chamber. The chamber lifts muons above about 5 GeV (green band) and leaves electrons untouched. Project 3 notebook.

05Pions and kaons

An electron and a muon look nothing alike to a calorimeter. A pion and a kaon do. Both are hadrons, both shower in the HCAL, and at the same momentum they carry similar energy. The project’s later question was whether the calorimeters alone could separate them.

The first rule used the share of the energy in the HCAL: above 0.5 means kaon. The 0.5 was a placeholder. It gave 84% for pions and 17% for kaons, 0.507 overall. The pion figure looks respectable. It is not:

HCAL energy as a share of ECAL plus HCAL, for pions and kaons. Both pile up near 0 (stopped early) and near 1 (punched through), and the two histograms sit on top of each other: the 0.5 cut has nothing to cut on. Project 3 notebook.

Here is why. Pions and kaons both split into two groups, those that stop early (HCAL share near 0) and those that punch through (near 1), and the two histograms lie on top of each other. A cut can only separate what differs, and nothing in this plot does.

The next step, as the course suggested, was machine learning. I trained a gradient-boosted classifier on four inputs (ECAL deposit, HCAL deposit, the HCAL share of the total, and the total). Its test accuracy was 0.487, a little worse than the cut’s 0.507. A classifier cannot find structure that is not in its inputs.

The gradient-boosted classifier. Left, which inputs it leaned on (total deposit and HCAL fraction most). Middle, efficiency by energy for the cut (faint) and the trees (solid). Right, its kaon score for pions and kaons: the two overlap almost completely around the 0.5 decision line. Project 3 notebook.

06The Cherenkov idea

The standard answer in real experiments, ALICE and LHCb among them, is a ring-imaging Cherenkov detector. A charged particle moving faster than light does in a medium emits a cone of light, and the cone’s opening angle depends on speed. Momentum comes from the track curvature, speed from the ring, and a pion and a kaon of the same momentum have different masses, so different speeds.

I modelled it with water as the radiator (refractive index 1.33, a 10 m absorption length across four photon energies from 2 to 3.5 eV) and an air layer outside it where photons are counted. The water is not sensitive; the particles interact with it as they would in real life, and the photons are recorded afterwards. A first version of this detector wrote an empty output file, and the data used below come from the version that works.

The notebook's formulas, live

Why a water RICH can't separate high-momentum kaons

cos⁡θC=1n β,β=pp2+m2,pthreshold=mn2−1\cos\theta_C = \frac{1}{n\,\beta},\qquad \beta = \frac{p}{\sqrt{p^2+m^2}},\qquad p_{\text{threshold}} = \frac{m}{\sqrt{n^2-1}}

With n=1.33n = 1.33 the pion starts to radiate at 0.16 GeV and the kaon at 0.56 GeV. Both angles then climb towards the same limit, arccos⁡(1/n)≈41.2∘\arccos(1/n) \approx 41.2^\circ, because at high momentum a pion and a kaon are both travelling at almost the speed of light.

Show

010203040500.10.20.51251020Momentum (GeV/c)Cherenkov angle (degrees)π onK on
Pion (°)Kaon (°)
Pion
41.1°
Kaon
38.9°
Difference
2.16°

Kaons and pions can be told apart by angle from 0.56 GeV up to about 2.7 GeV. If the beam is flat in momentum from 0.2 to 20 GeV, as the macros set it up, that window holds about 11% of the particles. Between 0.16 and 0.56 GeV pions glow and kaons stay dark, another 1.8%. The rest sits where the two rings are the same ring.

The lab says something uncomfortable. A water RICH separates kaons from pions in a window from the kaon’s threshold of 0.56 GeV up to a few GeV, and the beam I used runs flat to 20 GeV. Most of the kaons were never in the window.

07What the RICH returned

The rules I tried were simple: more than 5 photons in the RICH means pion, otherwise kaon, with the HCAL share as the fallback for the combined version. The summary below is from 500 pions and 500 kaons.

Efficiency by rule, RICH run (flat 0.2 to 20 GeV)
RulePionsKaonsOverall
HCAL share only0.8520.1460.499
RICH photons only0.6400.3240.482
RICH, then HCAL0.9620.0400.501

Every overall figure is about one half, and in every row the pion and kaon columns add up to about 1. Put side by side, the seven classifiers of this project look like this:

Arithmetic on the notebook's numbers

How much does each classifier actually know?

Add a classifier’s efficiency for one species to its efficiency for the other and subtract 1. A classifier that ignores the particle and just says “pion” 84% of the time scores 0; a perfect one scores 1.

Electron vs muon: ECAL energy over 1 GeV

Electron vs muon: plus a muon chamber

Pion vs kaon: HCAL fraction over 0.5

Pion vs kaon: gradient-boosted trees

Pion vs kaon: HCAL fraction (RICH run)

Pion vs kaon: RICH photon count over 5

Pion vs kaon: RICH, falling back to HCAL

Orange: electron against muon. Blue: pion against kaon. The gradient-boosting row is worked out from its accuracy of 0.487 on a roughly balanced test sample, so it is approximate. With about 500 events of each species, an efficiency near 0.5 carries a statistical uncertainty of about ±2%, so every blue bar is consistent with zero.

The efficiency curves by energy show the same thing in another way. The RICH-only rule does not separate the two species; it calls everything a kaon at low momentum and everything a pion at high momentum, switching over where the photon count rises.

HCAL only, RICH only and combined, by energy. At each energy the pion and kaon efficiencies of the RICH rule add to about 1: it calls nearly everything the same thing, switching from kaon to pion as the photon count grows. Project 3 notebook.
Photons per event against momentum. Below about 2 to 3 GeV the count is close to zero for both species; above it, there are thousands for both. Project 3 notebook.
Left and middle, the angles of the simulated hits: they spread from 45° to 135° and do not sit on the theory curves. Right, the theoretical pion−kaon angle difference, large just above the kaon threshold and nearly zero at high momentum. Project 3 notebook.

Two things in these plots are not what the theory says. First, pions should be glowing from 0.16 GeV, but both species record almost no photons until 2 or 3 GeV, and above that the pion and kaon counts overlap. Second, the simulated hit angles span 45° to 135° instead of clustering near 41°. The notebook takes a hit’s polar angle as the Cherenkov angle, which would be right only if the particle were travelling along the polar axis; the hits are almost certainly measured from the beam axis instead, so each one would first have to be rotated into its own particle’s frame. I did not find what was holding back the photon counts, nor make that rotation.

In plain English

I measured a ring in the wrong coordinates, so I could not see whether it was the right size. It’s like trying to judge how wide a hula hoop is while only knowing the angle each point on it makes with the ceiling, and not with the hoop’s own centre.

08How far to trust it

These are the checks I made on the notebook while building this page, in a neutral tone, and what they could not settle.

  • Every number is the notebook’s. The efficiencies, resolutions and accuracies on this page are printed outputs. The informedness bars and the “share of the beam” figures are arithmetic on them (the beam share assumes a flat 0.2 to 20 GeV spectrum, as in the macros). Nothing was re-simulated, and the Geant4 code and sample files were not part of what I had to hand.
  • The tracker radii are the code’s defaults. The 4 m and 8 m in the curvature lab are the values the reconstruction function takes as defaults (with the field at 2 T). I did not check them against the Geant4 geometry file, which is not part of what I had to hand.
  • There are no error bars on the efficiencies. From the binomial formula, an efficiency near 0.5 measured on about 500 events has an uncertainty of roughly ±2%. That makes the pion-and-kaon results consistent with chance, and it means the bin-by-bin curves, with a handful of events in each low-energy bin, are noisy.
  • The thresholds were first guesses. The 1 GeV electron cut, the 0.5 HCAL share and the 5-photon cut were each tried once and not scanned. A scan, and an ROC curve for each rule, would show whether any threshold does better than chance; I would expect not for pions and kaons, but the notebook does not show it.
  • The calorimeter calibration was a placeholder. An early cell sets calibration constants of 3.3 and 10 with a note to change them; the identification then uses raw deposits, so the energy-resolution plots are of uncalibrated sums.
  • The RICH angle is unconfirmed. As above, the hit angles are in detector coordinates, so the notebook cannot yet test the theory curves, and both the photon-count and the angle readings in section 7 are open questions.
  • Two readings are mine. The curl-up explanation of the electron efficiency (section 4) and the coordinate explanation of the RICH angles (section 7) are readings of the plots, not tests, and are labelled as such.

09More plots from the notebook

The rest of the figures I used, with the same captions as in the notebook’s own output. Click one to enlarge it.

Spread of (reconstructed − true)/true energy in bins of true energy. It is erratic at low energy, where the bins hold few events. Project 3 notebook.
Hits in the outer muon chamber per event. Most events have none; a hit, together with a track, is called a muon. Project 3 notebook.
ECAL against HCAL deposit, one dot per event. The two species fill the same region. Project 3 notebook.
Efficiency by energy for the HCAL-fraction cut. The pion curve looks good because nearly everything is called a pion. Project 3 notebook.
Photons recorded in the RICH per event. Pions and kaons share the same distribution, a few thousand photons with a tail past 70,000, so a cut at 5 photons only separates the events that recorded none. Project 3 notebook.
One event, drawn in the particle frame, with the expected pion (41.1°) and kaon (38.9°) rings at 1.85 GeV. This event recorded no photons, so there is no ring to compare against. Project 3 notebook.
Theory, water (n = 1.33): the pion turns on at 0.16 GeV and the kaon at 0.56 GeV, and the two angles converge on about 41° as momentum grows. Project 3 notebook.

Source: the Project 3 notebook for the DAML course. Cherenkov formulas: see any detector-physics text, for example the PDG review on particle detectors. Back to all research.