Scientific Computing – Jefferson Lab

Predicting particle trajectories with neural networks

Physicists fire electrons at hydrogen and record the particles that fly out. Two small neural networks built with Deep Netts tell the lab's Java software which recorded traces belong to real particles – so it reconstructs more of them, and faster.

+15.6%

reconstructed tracks on real CLAS12 data

35%

faster track reconstruction

+15–35%

events in two- and three-particle reactions

How it works – the animation

0
Segments
0
Candidates
0
Rejected
0
Tracks found
Step 1 / 6
Collision

A 10.6 GeV electron beam hits a 5 cm liquid-hydrogen target. This event has an electron and two pions – one of the reactions the paper analysed.

+10–15%
tracking efficiency
35%
faster tracking
+15–35%
events in two- and three-particle reactions

Source: G. Gavalian et al., CLAS12 Track Reconstruction with Artificial Intelligence (arXiv:2202.06869) – detector layout, network, two-pass workflow, Table 1, run conditions. The event drawn is illustrative.

1.In short

  • Who: Dr. Gagik Gavalian and colleagues, Jefferson Lab with Old Dominion University (Norfolk, VA).
  • What: the software that turns raw detector signals into particle tracks – the most expensive step of processing the data, 80–90% of the time.
  • Problem: at high beam intensity the detector is full of background signals; the possible combinations explode and good tracks get lost.
  • Deep Netts: two small feed-forward networks, built with the open source Deep Netts community edition in Java – one picks the real tracks from the candidates, one repairs tracks with a missing piece.
  • Result: 15.6% more tracks, 35% faster tracking, 15–35% more events for physics – from the same data.

2.Jefferson Lab and CLAS12

The Thomas Jefferson National Accelerator Facility – Jefferson Lab – is a US Department of Energy laboratory in Newport News, Virginia. Its accelerator, CEBAF, produces a continuous beam of electrons. In the lab's experimental Hall B stands CLAS12, a large detector used to study the structure of protons and neutrons (nucleons) and to search for new particle states.

Why electrons? An electron is tiny and well understood. Shooting it into a proton is like probing an unknown object with a very fine needle: from what comes out – which particles, in which directions, with what speed – physicists work out what the proton looks like inside.

The data in this case come from the standard running conditions: a 10.6 GeV electron beam at 45 nA (nanoamperes – the beam current, i.e. how many electrons per second) hitting a 5 cm long cell of liquid hydrogen.

3.One event, step by step

One collision with everything that comes out of it is called an event. The detector records millions of them. In each:

  1. 1 · Collision

    An electron hits a proton in the hydrogen target.

  2. 2 · Particles fly out

    E.g. the scattered electron and one or two pions.

  3. 3 · Magnet bends them

    A six-coil torus magnet bends charged particles; + and − bend opposite ways.

  4. 4 · Drift chambers

    Each particle crosses three regions of wire chambers inside its sector.

  5. 5 · Wires fire

    Wires next to the particle's path give a signal – the raw data.

Six sectors

The six coils of the magnet split the forward detector into six wedge-shaped sectors, like slices of a cake seen from the beam. A particle stays inside one sector, so each sector is reconstructed on its own.

S1S2S3S4S5S6orange dot = beam (into the page) · dark spokes = magnet coils
Looking along the beam. Each sector has its own set of drift chambers. Drawing simplified.

Three regions, six superlayers

In each sector the particle passes three regions of drift chambers – before, inside and after the magnet. Each region has two chambers called superlayers, so a particle crosses six superlayers in a row. Every superlayer is 6 layers of 112 wires; one sector is therefore a matrix of 36 layers × 112 wires.

4.From wires to segments

A drift chamber is filled with gas and strung with thin wires. A charged particle passing through knocks electrons out of the gas; they drift to the nearest wire and produce a small electrical pulse. So inside one superlayer, the particle lights up about one wire per layer, in a slanted row:

L1L2L3L4L5L6wire 30wire 69segment · mean wire 44.0
One superlayer, 40 of its 112 wires. Blue: wires the particle lit; grey: background hits. Wire numbers illustrative.

The software groups adjacent fired wires into a cluster – a segment: a short piece of the track inside one superlayer. For the networks, each segment is summarised in one number: its average wire position. A track crossing all six superlayers is therefore six numbers.

Chambers are not perfect. Sometimes a superlayer records no segment for a real particle, and the track has only five. In conventional processing these 5-segment tracks were about 10% of all reconstructed tracks.

5.The tracking problem

Each event leaves many segments in a sector: some from real tracks, some from background, some from partial paths of slow particles. To build tracks, the software forms candidates – one segment from every superlayer – and has to decide which candidates are real. The number of combinations grows very fast:

SL1SL2SL3SL4SL5SL6target side
Segments: 21Possible tracks: 1,728Real: 2

Each superlayer reports short pieces of track – segments. Two of these particles are real; the rest is background from the intense beam. The software does not know which is which.

Drawing simplified: one sector, positions illustrative.

How it was done before

  1. Clustering

    Fired wires → segments, per superlayer.

  2. Seeding

    All 6-segment combinations; then 5-segment ones from what is left.

  3. Hit-based fit

    Fit candidates using wire positions; keep good ones.

  4. Time-based fit

    Kalman filter refines each track with the drift times.

The conventional code picked good candidates iteratively, considering all possible combinations and fitting them. Tracking takes 80–90% of the total CLAS12 event processing time. Many marginal candidates went all the way to the Kalman filter only to be dropped there because the fit did not converge.

It gets worse exactly when physicists want more data: a higher beam current gives more collisions per second, but also more background segments – more combinations, and more good tracks lost among them. The 5-segment tracks are hit hardest, because leaving one superlayer out multiplies the combinations again.

6.Where Deep Netts comes in

The team replaced one step – choosing which candidates are real tracks – with two neural networks. Everything before and after stays the same, including the precise fits that compute the final momentum and direction:

  1. Clustering

    Wires → segments. Unchanged.

  2. Candidates

    One segment per superlayer. Unchanged.

  3. Deep Netts

    Classifier

    Scores each 6-segment candidate: positive, negative or false track.

  4. Deep Netts

    Auto-encoder

    Adds the missing segment to 5-segment candidates.

  5. Hit-based + Kalman fit

    Only the chosen tracks are fitted. Unchanged.

The networks don't replace physics. They only answer one question fast – is this combination of segments a real particle? – so the expensive, exact physics code runs on the right candidates.

7.Network 1: the classifier

Choosing the model

The team compared three kinds of models on CLAS12 drift chamber data: a convolutional neural network (CNN), extremely randomized trees (ERT) and a multi-layer perceptron (MLP). The MLP – a plain feed-forward network – was best suited, based on inference speed and accuracy.

What goes in, what comes out

  • Input: 6 numbers – the average wire position of the candidate's segment in each superlayer.
  • Inside: three hidden layers of 12 neurons each.
  • Output: 3 scores – positive track, negative track, false track.
SL1 mean wireSL2 mean wireSL3 mean wireSL4 mean wireSL5 mean wireSL6 mean wirepositive tracknegative trackfalse
The classifier from the paper: 6 inputs → 3 hidden layers of 12 neurons → 3 outputs. Built with Deep Netts, in Java.

Why this works: a real charged particle in a magnetic field makes a smooth curve, so its six wire positions follow a smooth pattern – bending one way for positive charge, the other way for negative. A random mix of segments breaks the pattern. The network learns these patterns from examples.

How it was trained

On real experimental data, already processed by the conventional tracking. Tracks with a good fit quality (χ² cuts) that also lead back to the target were the “positive” and “negative” examples; combinations of six segments that the conventional algorithm did not identify as a track were the “false” examples. The authors note that the performance keeps improving with constant training on new data.

Sketch – the classifier's shape in the Deep Netts API

FeedForwardNetwork classifier = FeedForwardNetwork.builder()
        .addInputLayer(6)                                   // mean wire, SL1..SL6
        .addFullyConnectedLayer(12, ActivationType.TANH)
        .addFullyConnectedLayer(12, ActivationType.TANH)
        .addFullyConnectedLayer(12, ActivationType.TANH)
        .addOutputLayer(3, ActivationType.SOFTMAX)          // positive, negative, false
        .lossFunction(LossType.CROSS_ENTROPY)
        .build();

classifier.train(trainingSet);                              // tracks from conventional reconstruction
float[] scores = classifier.predict(meanWires);             // e.g. [0.93, 0.01, 0.06]
Layer sizes from the paper; activation functions and variable names are illustrative (the paper does not list them).

8.Network 2: the auto-encoder

The second network solves the missing-segment problem. An auto-encoder is a network trained to output the same numbers it gets as input. That sounds useless – until you damage the input on purpose.

The training trick

The team took the same good tracks used for the classifier. For each, they set one of the six inputs – chosen at random – to zero, and asked the network to output the full, correct six values. After enough examples the network learns to fill the zero with a value that fits the other five. The authors call it a corruption auto-encoder: it repairs a corrupted input.

Mean wire position in SL1 … SL6 (wires 1–112)

41.243.0?47.950.653.1

↓ auto-encoder (6 in, 6 out) ↓

41.243.045.447.950.653.1
The network learned from complete tracks what a real track looks like, so it can fill in a gap. In the paper it lands 0.36 wires from the true position on average. Numbers here are illustrative.

Tested on tracks it had not seen, the predicted segment position was on average 0.36 wires from the true one, and equally good whichever superlayer was missing. That is less than half the distance between two neighbouring wires.

9.The two-pass workflow

Pass 1 – complete tracks

  1. Build 6-segment candidates

    Every combination of one segment per superlayer, per sector.

  2. Deep Netts

    Score them

    The classifier gives each the probability of being a positive or negative track.

  3. Sort by probability

    Best candidate first.

  4. Take the best, drop its rivals

    Move #1 to the found tracks; remove candidates sharing any of its segments. Repeat.

Pass 2 – tracks with a missing segment

  1. Build 5-segment candidates

    From segments not used in pass 1.

  2. Deep Netts

    Fill the gap

    The auto-encoder adds a pseudo-segment in the missing superlayer.

  3. Deep Netts

    Score again

    Now 6 numbers – the same classifier picks the good ones.

  4. Fit everything

    Tracks from both passes go to hit-based fitting and the Kalman filter.

To measure the gain fairly, the reconstruction code ran two parallel branches on the same data: one choosing tracks the conventional way, one with the networks. Both fed the same fitting code, so every difference in the output comes from the track choice alone.

10.Results

More tracks from the same data

Track typeConventionalAI-assistedGain
6 superlayers242,145256,175+5.8%
5 superlayers (one missing)24,15552,839×2.19
All tracks267,339309,058+15.6%
Table 1 of the paper: data at 45 nA. Typically the gain is 3–6% for 6-superlayer tracks and 70–120% for 5-superlayer tracks; the single-particle tracking efficiency rises by 10–12%.

The biggest win is in the hardest case – tracks with a missing segment – where the combinations are the most numerous. That matches the idea: the more candidates there are, the better the network does compared with trying them one by one.

Better as the beam gets stronger

The team analysed runs from 5 to 70 nA. With conventional tracking the efficiency dropped by about 0.40% per nA of beam current; with AI-assisted tracking by only 0.22% per nA.

100%90%80%70%010203040506070beam current (nA) – more current = more collisions and more background45 nA (production)AI-assisted (Deep Netts): −0.22% per nAconventional: −0.40% per nA
Fitted efficiency lines as reported in the paper (assuming 100% at zero current). The summary of the paper gives the conventional slope as 0.37% per nA.

35% faster

Because the networks pick the candidates, far fewer marginal tracks are sent to the Kalman filter only to fail there. The tracking code ran 35% faster.

11.What it means for physics

Physicists measure reactions by counting events. The team checked two reactions where the detected particles leave a “missing” nucleon, visible as a peak in the missing-mass distribution:

e + π⁺ + missing neutronH(e,e′π⁺X)
+15%
e + π⁺ + π⁻ + missing protonH(e,e′π⁺π⁻X)
+30–35%

Grey = events found with conventional tracking, blue = extra events with AI-assisted tracking (same data).

Increase in events in the nucleon peak with AI-assisted tracking (paper, Figure 10). The increase is uniform across the distribution – no distortion of the physics.
  • Faster experiments: the required statistical precision can be reached in a shorter time, or by running at a higher beam current.
  • Old data gain value: data already collected can be re-processed with AI-assisted tracking for up to 35% more statistics.
  • Simpler code: the authors note the AI approach leads to a very small and simple codebase – compose candidates, feed them to the networks.
  • Next: extending the approach to other CLAS12 tracking detectors and other Jefferson Lab setups.

12.Why Java and Deep Netts

CLAS12 reconstruction runs on CLARA, a service-oriented framework written in Java: a set of microservices, each processing data from one detector. Their own analysis and plotting tools (GROOT, part of the Jas4pp library) are Java too.

The first prototypes were made in Python with Keras/TensorFlow. For production the networks had to live inside the Java reconstruction, so the final implementation of both networks was done with the Deep Netts community edition. In the paper's words, Deep Netts is lightweight with minimal dependencies – portable code without installing a large number of platform-dependent packages. The fast inference inside the reconstruction services was implemented with the EJML matrix library, also pure Java and thread-safe.

In his article for Deep Netts, Dr. Gavalian adds that the most popular alternative they looked at needed native libraries for every platform – over 1 GB to link to their code – while other libraries were incomplete or poorly documented. Deep Netts' documented API let them develop and test prototype networks quickly.

Where Deep Netts runs, exactly: the networks were designed, trained and implemented with Deep Netts in Java; the reconstruction services evaluate them with EJML matrix code. No Python and no native libraries in the production chain.

13.Glossary

CEBAF
Continuous Electron Beam Accelerator Facility – Jefferson Lab's electron accelerator.
GeV
Giga-electronvolt, a unit of energy. At 10.6 GeV the electrons move at almost the speed of light.
nA, beam current
Nanoamperes – how many electrons per second hit the target. More current: more collisions, more background.
Luminosity
How many collisions per second the setup can produce; grows with beam current.
Nucleon
A proton or a neutron.
Pion (π⁺, π⁻)
A light particle often produced in these collisions; + or − is its charge.
Event
One recorded collision with everything that came out of it.
Sector
One of six wedge-shaped parts of the forward detector, between the magnet's coils.
Drift chamber
A gas-filled box with thin wires; wires near a charged particle's path give a signal.
Superlayer
A chamber of 6 layers × 112 wires. A particle crosses six of them.
Segment (cluster)
Adjacent fired wires in one superlayer – a short piece of track.
Track candidate
One segment from each superlayer joined into a possible path.
χ² (chi-squared)
A measure of how well a fitted curve matches the hits; used to pick high-quality training tracks.
Kalman filter
A precise step-by-step fit that refines a track with the drift times of its hits.
Missing mass
The mass of the undetected particle, computed from everything detected; real reactions show a peak.
MLP / feed-forward network
The classic neural network: numbers in, layers of neurons, scores out.
Auto-encoder
A network trained to reproduce its input; trained on damaged inputs, it learns to repair them.
Inference
Using a trained network to get an answer, as opposed to training it.

14.Sources