HOWTO merge events from different sources

From GlueXWiki
Jump to: navigation, search

In HOWTO merge real noise into simulated events I explained how to merge arbitrary noise hits into a simulated event stream to get a realistic simulation of random hits associated with detector backgrounds. However, maybe all you want to do is to merge hits from multiple events into a single stream. In that case, it will annoy you that the two functions of smearing Monte Carlo hits and events merging are bundled together in a single step, using mcsmear. To cover this use case, I provide a null event generator called nullgen that you can use to inject empty events in the place of simfile.hddm in the sample shown in HOWTO merge real noise into simulated events. The following example shows how this works.

$ nullgen -r 30592 -n 1000 -o null1000.hddm
$ mcsmear null1000.hddm bgfile1.hddm:1 bgfile2.hddm:1

The first command generates a set of 1000 null events and writes them into null1000.hddm, which can be named anything. These events are empty containers; there are no MC particles in them and no detector hits. The second command takes these null events and merges into them a superposition of one event from bgfile1.hddm and one from bgfile2.hddm. The suffixes :1 and :1 can be changed to be any real number. Their meaning is the same as described in HOWTO merge real noise into simulated events. The only role of the null1000.hddm input file is to set the number of output events that will be written. The length of the files bgfile1.hddm and bgfile2.hddm are irrelevant, provided that they contain at least one event. Each time one of them hits the end-of-file, it is rewound and started again from the beginning. This mechanism allows mcsmear to be used as a general event merging tool, with the smearing action effectively disabled due to the fact that there are no hits in the input file to smear.