Improve Particle Source
Description
It might be worth thinking about improving the particle source we currently implement in DepositionGeant4
. Right now it used a G4GeneralParticleSource
which is set up once in the constructor of the generator action and which produces one primary vertex every event (call to BeamOn
). Multiple particles are simulated using multiple BeamOn
calls.
This e.g. limits the source to produce one particle type.
Proposal
We could set up only the bare minimum of the source parameters in the constructor but move the setting of particle type, energy, multiplicity etc to the GeneratePrimaries
function.
Links / references
One example which does it like this is among the Geant4 extended examples for event generators: http://geant4.web.cern.ch/geant4/UserDocumentation/Doxygen/examples_doc/html/ExampleparticleGun.html
The relevant code is this section: https://github.com/Geant4/geant4/blob/master/examples/extended/eventgenerator/particleGun/src/PrimaryGeneratorAction1.cc
While this uses a G4ParticleGun
it should be possible to do the same with the currently used source. I'm not entirely sure what the difference is, anyway.
Use cases
Implementing this would e.g. allow to provide vectors of particle_type
and particle_energy
parameters in the configuration file and thus generating several different particles at once. One very concrete example is a simulation of high-energy Gamma background in which a single positron should be detected. Currently I am performing this simulation by overlaying two separate simulations with background and signal. While this works fine, it is a bit cumbersome.
Feature checklist
-
Define feature wish list -
Implement new behavior -
Documentation -
Covered by test cases