We now consider a fairly complicated example. We wish to construct a simulated event by combining the digits from a generated MC (Monte Carlo) event with those from multiple events in a background run. For definiteness assume the background run is real data (RD) (not MC).
We must open two independent input streams and one output stream. We loop over output events and select one event from the MC stream and multiple events from the RD stream. We construct one digit container from the MC input and multiple containers from the RD stream. We also construct a writeable output container.
We loop over detector channel indices and read the corresponding digit (if existing) from each input container. These are combined to create a new digit and the combined digit is added to the output container.
After the event is complete, the new container is written out either in the format of the present persistency mechanism (objectivity or root) or in the raw data format.
The user may also want to apply a threshold cut (or cuts) to simulate the sparse detector readout. This could be applied when the digits are stored in the container or as part of the conversion to raw data format.