# Saving and merging background¶

## Saving background tracks¶

GEMC can save into a file the tracks that produced hits. They can be merged later on with a generator of choice w/o having to run the luminosity beam again [1].

The option “SAVE_ALL_MOTHERS” can be set to “3” as follows:

-SAVE_ALL_MOTHERS=3


This saves all tracks that entered any sensitive volumes into a LUND file. If a track’s mother also produced hits, only the mother is saved so the hits are not double counted [2].

## Merging background tracks¶

The option MERGE_LUND_BG can be used to merge tracks from background file “filename”:

-MERGE_LUND_BG="filename"


The users can use the internal GEMC generator, cosmic model, or a separate LUND file to generate non-background events.

As an example, three events were run with luminosity background:

• event #1 (Figure 1 left) produced no hits,
• event #2 (Figure 2 left) produced background hits.
• event #3 (Figure 3 left) is a real example of one event with 124,000 beam electrons producing background hits.

The three events, merged to a single track, are shown in Fig 1, 2 and 3 right.

Figure 1. Event 1. Left: no background hits with luminosity. Right: no hits were merged to the generated track.

Figure 2. Event 2. Left: tracks producing hits from luminosity were saved. Right: the tracks were merged to the generated track.

Figure 3. Event 3. Left: tracks producing hits from a realistic luminosity of 124,000 electrons per event were saved. Right: the tracks were merged to the generated track.

## Timing¶

The track saved are merged in the event at the time that they were generated by the luminosity beam interactions, depending for example on which beam bunch produced the interation. This ensures that the background is uncorrelated to the generated events.

Footnotes

 [1] A run with luminosity activated involves typically thousands of beam interations. While one beam particle runs through in < 1 msec, a full event may take minutes, so it may be not feasible to run luminosity with some event generator.
 [2] To include the secondaries set SAVE_ALL_MOTHERS to “2”. Attention: this will likely lead to double counting hits.