My most recent project, aDetector, is coming along nicely. After a few more days of development it’s reached the stage where a detector can be assembled from a series of tracking systems and calorimeters, and simulate the decay of $$J/\psi$$ mesons to pairs of leptons. The leptons propagate through the detector, following helical paths in the presence of a uniform magnetic field, and lose energy as they interact with the various components in ways characteristic to each particle and component.

The project provides three views of the detector, to allow the user to have a complete view of each event. The event displays are generated using a completely home made graphics library, where the user is able to change the position and angle of the “camera” viewing the detector. To save CPU time the complete display is only regenerated whenever the user change the position of the view, freeing up the CPU for event generation.

# New project in development: aDetector

One of the projects I’ve wanted to put together for a long time is a very simple particle detector simulation that gives the user an idea what it is like to perform a physics analysis at and LHC experiment (or other experiment). The requirements are quite challenging:

• The software must work on any system without the need for an installation process. (ie It should be web based and work within the browser, preferably without special plugins.)
• The results must be relatively realistic, calling on help from experts if necessary. Fortunately I know many experts who can help with this, and my own knowledge and resources will get me most of the way.
• The software must be extendable and in particular, capable of simulating many different detectors of arbitrary geometry and complexity.
• While some steps can involve special software (such as the pythia particle event generator) the files used for the running of the program must be easily readable, with a preference for the xml format.
• The software must be intuitive and attractive to the user.
• The software must be “light” so that it can be used on almost any system.

There are probably many additional requirements which will arise later, but this is plenty to be getting on with.

### Overall design concept

The software will be written in Javascript, with artwork in the canvas. The user will have several views of the detector, which will “collect” (generate) data and accumulate results. The user can then choose how to combine the detected particles to search for a signal, generate a mass peak, and then make a discovery.

The particles will be generated randomly, with background and signal processes similar to those in the relevant experiment. The detector will be a series of modules that can be taken in and out. The particles will traverse the detector components and “interact” in a very simple manner, giving a list of particle candidates.

### First trials

The first component I made was a cylindrically symmetric tracking system, capable of detecting charged particles. Then I simulated $$J/\psi\to ee$$ events to see what the results would look like before and after passing the particles through the tracker. The tracker should not provide perfect measurements of the particle momenta, so the reconstructed momenta must give peaks with equal areas, but larger widths than the true momenta. You can see some screenshots below:

### Random numbers

One of the first problems I had to solve was how to generate a random number for a given distribution. It turns out this is relatively simple; for a function $$y=f(x)$$ simple invert the function to get $$x=f^{-1}(y)$$ then take a random uniform number for $$y$$. For example, for a Cauchy distribution we have:

$y = \frac{1}{\pi}\frac{\gamma}{\left(x-x_0\right)^2+\gamma^2} \\ x = x_0 \pm \sqrt{ \frac{\gamma}{\pi y} – \gamma^2 }$

It feels good to have finally gotten around to solving this problem. If I’d have known it was this simple I’d have done this long ago instead of using the accept-reject method!