Skip to content
All projects

ML on Edge Hardware

Electron Identification BDT on FPGA

University of Zurich · CMS / CERN · 2019 – 2024

During my PhD I designed the first fully demonstrated machine-learning algorithm to run in the CMS Phase-2 hardware trigger: a boosted decision tree for electron identification implemented in FPGA firmware at 100 ns latency, using under 3.1% of chip logic, and raising selection efficiency by up to 10%. It was recognised with a CMS Award (2023).

XGBoostconiferBDTXilinx VU13P

The future of the LHC

The Large Hadron Collider (LHC) at CERN (Geneva, CH) has successfully concluded Phase-1 of operations in June 2026. In the coming years, it will be upgraded to the High Luminosity LHC (HL-LHC), designed to deliver proton-proton collisions at 5 to 7.5 times the nominal LHC luminosity, starting around 2030. Over the course of its lifetime, the HL-LHC is expected to deliver a grand total of 4000 fb⁻¹ of collision data — a factor 10 increase with respect to everything collected before — which is crucial for many statistically limited measurements of Standard Model properties and searches for new physics.

However, the running conditions of the HL-LHC pose serious challenges for the experiments. For example, the average number of simultaneous proton collisions per bunch crossing (pileup) will increase from roughly 40 to 200, causing many more particles to traverse the detector volumes. Consequently, one of the main challenges for the LHC experiments is the real-time selection of collision events. The CMS detector is, in essence, a 40 MHz camera, and it is physically impossible to store every frame. The hardware-based Level-1 Trigger therefore reduces the event rate from 40 MHz to a manageable bandwidth, using only coarse event information and a few microseconds of decision time. Studies have shown that running today's trigger algorithms in HL-LHC conditions would produce a rate roughly 40 times above what the data acquisition system allows.

The CMS Collaboration has therefore planned some major upgrades to the detector: the end-cap calorimeters will be replaced by the new High Granularity Calorimeter (HGCAL) to provide richer descriptions of particle showers; the Tracker will for the first time reconstruct charged particle tracks at the 40 MHz collision rate, and the Level-1 Trigger is fully redesigned with new dataflow architecture based on state-of-the-art FPGAs and increased latency budget of 12.5 µs. More time, more information, and more processing power means the trigger can - for the first time — host machine learning algorithms to select the interesting data.

Electron triggers in CMS

A large fraction of the CMS physics program relies on electron triggers: algorithms that select in real-time the collision events with one or more final-state electrons. Those triggers always impose thresholds on the electron momentum (pT): if an event contains an electron that passes the threshold, then the event data will be recorded, otherwise it is lost forever. Choosing the threshold means navigating a delicate trade-off between physics acceptance and trigger rates; For example, a lower threshold would accept more events for offline analysis, but also implies higher rates. And since the CMS Level-1 trigger has only limited bandwidth (100 kHz in Phase-1, 750 kHz in Phase-2), the thresholds of all algorithms in the trigger menu should be carefully tuned. In other words, the key challenge is to maintain low thresholds at acceptable trigger rates, even in the harsh HL-LHC environment.

Baseline algorithm

In order to decide whether to accept or reject the event, the Level-1 trigger must first reconstruct all particles in the event, using partial (coarse) detector data. In the HL-LHC era, there will be only 12.5 µs to collect the detector data, reconstruct low-level particle representations, send those off-detector to the Level-1 trigger, where high-level representations are built and finally the accept/reject decision is made. Therefore, to maximize physics acceptance, not only the trigger thresholds are important, but even more so are the reconstruction and identification algorithms themselves. If electrons are identified with very low purity, then the rates would essentially consist of background. Conversely a very accurate identification would reduce backgrounds, which in turn frees up rate-budget to eg. lower the thresholds or introduce other triggers.

The baseline electron identification algorithm for the Phase-2 trigger (until recently) is called the "Tk-matched electron". It first identifies an electromagnetic shower in the HGCAL through multivariate analysis, and then requires a geometrically compatible track, matched with a tight elliptical window at the calorimeter surface.

Schematic of an electron in the CMS detector: an L1 track in the tracker and an HGCAL cluster in the calorimeter, matched to the generated electron.
Track–cluster matching: an L1 track and an HGCAL cluster are associated to reconstruct the electron.

The problem

The track-matching is the only way to reconstruct electrons with trigger thresholds similar to those of Phase-1 and sustainable rates. But the track does not always actually come from an electron traversing the Tracker volume; most often a low-energy hadronic particle creates the track, which can then be "accidentally" matched to the HGCAL cluster and form a "fake" electron. Since the trigger has no direct handle on the track quality (the usual handle to suppress fake/background tracks), the baseline identification instead relies on a hard track requirement of pT > 10 GeV to suppress backgrounds from pileup and combinatorics. But in doing so, the capability to reconstruct electrons with pT<10 GeV is explicitly impaired.

An additional complexity in this story is bremsstrahlung. As an electron propagates through the tracker material, it may radiate a photon; the photon, unaffected by the magnetic field, continues in a straight line to the calorimeter, while the electron trajectory is kinked by the photon emission. The track reconstruction does not accommodate such kinks, so the track parameters of radiating electrons tend to be poorly estimated — and the reconstructed track drifts out of the tight matching window, or falls below the pT requirement altogether.

The consequences: electrons with pT below roughly 10 GeV have essentially zero efficiency in the baseline identification, and even at high pT up to 10% of genuine electrons are lost.

Trigger efficiency versus electron pT for standalone e/γ, track-matched, and isolated track-matched electrons.
Efficiency vs. electron pT (at 30 kHz) — standalone e/γ, track-matched, and isolated track-matched electrons.
Trigger rate versus threshold for standalone e/γ, track-matched, and isolated track-matched electrons.
Rate vs. threshold — standalone e/γ, track-matched, and isolated track-matched electrons.

New approach to electron ID

During my PhD, I developed a new algorithm, referred to as the "Composite ID", to recover selection efficiency with respect to the baseline approach. The Composite ID differs from the baseline identification in three aspects.

First, the explicit track pT requirement is dropped entirely. So instead of considering only tracks with pT>10 GeV, the HGCAL cluster may be matched to any track that is reconstructed, including fake ones. Second, the tight geometrical track-cluster matching is relaxed to a loose ΔR < 0.2 window, which is almost fully efficient even for the softest, most heavily radiating electrons. Both these changes therefore recover efficiency, but also yield many more background objects. The algorithm therefore has to introduce a way to reject those backgrounds (while maintaining high efficiency), but in a smarter way than imposing a tight pT cut or matching window.

The third difference is the crucial one. Rather than identifying the calorimeter cluster first and matching a track afterwards, the Composite ID constructs candidate objects from cluster-track pairs and feeds cluster features, track features, and matching features simultaneously into a single boosted decision tree (BDT) model. In providing these three classes of features, the model learns to control the individual object qualities and the tightness of the matching at the same time; a clean high-pT electron and a messy bremsstrahlung case simply occupy different regions of the same feature space, and the model handles both. So instead of rejecting track-cluster candidates with a cut-based approach, the BDT model decides from learned representations which candidates are genuine electrons or background.

Model training

The Composite ID is trained as a binary BDT classifier, labeling composite candidates with a probability to be a genuine electron or background. A BDT was chosen over a neural network deliberately: for compact models with tabular input features, BDTs offer comparable discrimination power at substantially lower FPGA resource cost. The training samples are constructed from Monte-Carlo simulated collision events at 200 pileup, the design scenario of the HL-LHC. Signal candidates come from events with final-state electrons generated with a flat pT spectrum between 1 and 100 GeV, while background candidates come from "minimum bias" events containing only particles from low-energy proton collisions (the overwhelming majority of true background events). In both cases, candidates are built from any pre-selected track that falls within the loose ΔR < 0.2 window of any pre-selected HGCAL cluster, with the track propagated to the calorimeter surface to account for the bending in the magnetic field. Signal candidates are additionally required to match a generator-level electron, so the model learns from genuinely correct track-cluster pairs.

Each candidate is described by 27 features in three classes. The 4 track features (eg. the track pT, the quality of the track fit and the number of tracker hits used) control the quality of the track; the 20 cluster features give a detailed description of the particle shower in HGCAL — the number of layers with energy deposits, the energy-weighted shower center, the ratio of hadronic to electromagnetic energy, the penetration depth; and the 3 matching features (the differences in pT, η and φ between cluster and track) control the tightness of the association. The figure below shows a selection of these distributions for signal and background: no single feature separates the two, but together they carve out the electron region of the feature space. Many of the cluster features are also highly correlated with each other — a redundancy that becomes useful later, when the feature set has to be trimmed for the firmware.

One further subtlety: the discrimination power of the features depends strongly on the candidate pT, since soft candidates live in a region densely populated by pileup while hard candidates do not. The model is therefore trained independently in two pT bins (a low-pT training for 5–25 GeV and a high-pT training above 15 GeV, with an overlapping margin), which yields notably better background rejection than a single inclusive model. The training itself is performed with XGBoost.

Distributions of the Composite ID input features (cluster, track, and matching variables) for signal electrons and background.
Composite ID input features for signal electrons and background. From left to right: matching, HGCAL cluster, and L1 track variables.

Emulated performance

The physics performance is characterized with the two metrics that matter for an electron trigger: the rate as function of the pT threshold, and the identification efficiency as function of the generator-level electron pT at a fixed rate — here 9 kHz, a typical budget for a single-electron trigger in the end-caps. Since the BDT produces a continuous score, a whole family of working points can be defined along its ROC curve; rather than being limited to one operating point, the trigger menu can tune the efficiency-rate trade-off per use case, from very pure high-threshold triggers to loose selections for cross-object triggers.

The curves below are computed with the bit-precise C++ emulator of the trigger, which includes quantizing the features and reducing the model to the firmware implementation described in the next section. This is done to measure the performance as it is expected from the actual model running in the FPGA hardware, not the floating-point model evaluated in Python. The comparison with the baseline identification is unambiguous: at the same 9 kHz rate budget, the Composite ID reaches a slightly lower threshold (27 instead of 28 GeV) while the efficiency is substantially higher across the full spectrum. The most dramatic gains are for low-energy electrons (pT<20 GeV), where the baseline efficiency was essentially zero, but also at high energies the efficiency is recovered by up to 10%. Notably, the impact of all the quantization is small: the emulated inference was found to agree excellently with the floating-point model, so almost none of the physics performance is lost in translation to hardware.

Trigger efficiency versus electron pT for the Composite ID compared with the elliptic-ID baseline.
Selection efficiency vs. electron pT — Composite ID vs. elliptic-ID baseline.
Trigger rate versus threshold for the Composite ID compared with the elliptic-ID baseline.
Trigger rate vs. threshold — Composite ID vs. elliptic-ID baseline.

FPGA implementation

A model that performs well in simulation is only half the work; the other half is making it run on the Level-1 Trigger, specifically the Correlator boards, where FPGA resources are shared with the entire particle-flow reconstruction, and where multiple candidates per event must be evaluated in parallel within the latency budget. This turned the project into an exercise in co-design, with three deliberate reductions.

First, the number of input features was reduced from 27 to 11. The selection was guided by SHAP values, which quantify the impact of each feature on the individual model predictions, and constrained by a harder requirement: several features were simply too expensive to compute on the backend electronics that generate the trigger inputs, and were excluded regardless of their importance. The final set consists of 3 cluster features, 5 track features, and 3 matching features, distributions of which are shown above.

Second, the maximum tree depth was reduced from 6 to 4. The look-up tables (LUTs) required to evaluate a BDT on an FPGA grow exponentially with tree depth, and a depth of 4 was found to be the optimal trade-off between identification performance and resource cost.

Third, the input features were quantized to the fixed-point bit representations that are actually used on the FPGA, and the model was retrained on inputs emulated with exactly these precisions, so that the training conditions match the hardware reality.

The retrained model was translated to FPGA firmware with the Conifer package and implemented on the Xilinx Virtex UltraScale+ VU13P of the Correlator boards, with 10 parallel copies of the model to cover up to 30 candidates per event per region. The full inference takes 18 clock cycles at 180 MHz — 100 nanoseconds — and the complete e/γ core occupies just 3.1% of the LUTs of the FPGA. Crucially, the firmware achieved 100% bit-wise agreement with the C++ emulator used to quantify the physics performance: every single trigger decision made in hardware is exactly reproduced in software.

FPGA floorplan of the Correlator Layer-1 board, with the e/γ algorithm, isolation, and sorter placed among the particle-flow, PUPPI, regionizer, and infrastructure logic.
Correlator Layer-1 FPGA floorplan, with the e/γ core (including the Composite ID algorithm in light-blue) sharing the device resources with the rest of the particle-flow reconstruction.

Conclusion

The result is a major improvement in electron trigger performance. At equal background rates, the Composite ID recovers a minimum of 5–10% efficiency for electrons above 30 GeV with respect to the baseline identification, and dramatically extends the reach towards soft electrons, where the baseline efficiency was negligible. Beyond the single-electron triggers, this opens the door to cross-object triggers with much lower thresholds — such as di-electron plus missing-energy triggers, which were unsustainable in the previous system and would be of great value for exactly the compressed new-physics scenarios I searched for in the rest of my thesis.

CMS Award

The Composite ID hereby became the first machine learning algorithm within the CMS Phase-2 Level-1 Trigger project to be fully demonstrated in both the emulator and the firmware, paving the way for the many ML-based trigger strategies that have followed since. My work was recognized with the CMS Award 2023, for outstanding contribution to the Phase-2 Level-1 e/γ trigger algorithm and its implementation in firmware.

CMS Award 2023 Ceremony
Receipt of the CMS Award 2023, with CMS spokesperson Patricia McBride.