HOWTO merge real noise into simulated events

From GlueXWiki
Jump to: navigation, search

This procedure assumes that you have already downloaded and installed the sim-recon package, and configured your shell environment for running sim-recon commands. To begin, first generate a Monte Carlo dataset using the MC generator of your choice, eg. bggen. Then run the generated events through a physics simulation, either hdgeant or hdgeant4, to produce detector hits for each event. Now you want to add a realistic set of noise hits to the simulated hit pattern, so that the simulated event looks like it came from a detector running under realistic background conditions at a given beam intensity.

This procedure does not generate the noise hits themselves; those must come from another source. The best way to generate the noise sample is to collect data using a random trigger (eg. 60 Hz clock) when running at the desired beam intensity and target configuration. These data need to then be decoded from raw data format (EVIO) and converted to hddm output. Let us assume a hddm file containing these noise events has been created by this means, or perhaps some other, and copied into the current working directory. In this example, I call this file random_input_events.hddm, but it can be named anything. Also sitting in the same directory is the MC simulated dataset, named simfile.hddm in this example. Now we are ready to do the merge.

$ mcsmear [all of the standard mcsmear options] simfile.hddm random_input_events.hddm:1

The suffix ":1" after the random_input_events.hddm filename tells mcsmear not to treat this as a normal MC simulation output file from hdgeant/hdgeant4, but as a source of noise hit patterns to be merged into the output record, after the smearing is complete. The simulation events come from simfile.hddm, which get smeared by the mcsmear algorithm as usual. But the presence of the random_input_events.hddm:1 on the command line tells mcsmear to take 1 event from random_input_events.hddm for each output event it writes, and overlay the hits from the noise source onto the smeared hit pattern from the simfile.hddm event, before writing the output events. The suffix 1 tells the system that the noise pattern from exactly 1 event in random_input_events.hddm should be superimposed onto each output event. If the suffix were 25, there would be 25 events from random_input_events.hddm overlayed onto each other and then superimposed on the simfile.hddm output event before the event is written to the output file. The suffix can also be a real number, with a decimal point, like 1.8 or 10.778, which tells mcsmear to overlay a random number of noise events onto each output event, with the random number following a Poisson distribution with the given mean. The mean can be any positive real number, less or greater than 1.

An additional optional integer argument can be specified after a '+', for example, random_input_events.hddm:1+100. This additional argument specifies the number of event that should be skipped from the beginning of the file before the first event is read in. In the example of random_input_events.hddm:1+100, 100 events are skipped before processing begins. Events are read sequentially from random_input_events.hddm by mcsmear as needed, and if it hits the end of the file before it has exhausted all of the events in simfile.hddm, it simply rewinds random_input_events.hddm to the beginning and starts reading noise events again from the start. In this way, a single noise file can serve as an unlimited source of noise hits, albeit with some loss of statistical independence if the rewind frequency is too high.

If you have trouble getting this to work, or there is something related to this that you would like to do, that you are not sure this facility provides, I invite you to contact me at richard.t.jones at uconn.edu.