Split simulation stage to search for gamma-conversion
Use-case: Eventtypes with selections on the outcome of the detector simulation (e.g. Gamma converted to e+e- within a certain volume and with kinematic requirements).
To check whether a gamma produced in the signal event was converted currently requires running the simulation for all particles in the event (+ in all spill-over events in Run 2) which is very CPU intensive and highly inefficient.
This MR contains a prototype that splits the HepMC event and removes all photons which are descendants of the signal particle which are placed in a second dummy HepMC event that is then converted to our/G4's event model and simulated. The check for successful conversion is then applied and only if the gamma is accepted is the simulation for the remaining event run. If it does not pass, the remaining event loop is skipped and the next event is generated.
Using the event-type 27162212 which requires gamma-conversion, the time required to run the gamma simulation + check is significantly shorter than the time required to generate the full event in the first place.
Implementation:
- Quickly hacked together using the existing ReDecay infrastructure which provides almost all required pieces of cpp (but with its services might be a slight overkill).
- The decision which particles to extract and simulate first is hard-coded to photons from the signal particle (which have no end-vertex though this should be true for all of them by construction). More flexibility is probably desirable?
Question:
As the simulation of one photon is significantly faster than the event generation, repeating it multiple times and check for gamma conversion would be even better. However, this current prototype is build around existing algorithms and passes data via the TES. Repeating the simulation would require looping over the sequencer multiple times. While I can write a modified sequencer that does this, I believe the algorithms won't execute a second time and I don't know if it is possible to reset them or make them re-entrant?