Avoid removing particles from the GenEvent after SimHit creation has started
In order to complete the switch from using GenParticle
barcodes
to GenParticle
id
to link GenParticles
within a GenEvent
to other persistent EDM objects (SimHits), then we cannot remove GenParticles
from the GenEvent
during the actual simulation process as this can alter the ids of other GenParticles
which may have already been linked to SimHits. Any removal has to happen before the first SimHits are created.
Initial approach
- Read in BeamTruthEvent
McEventCollection
as previously. Copy BeamTruthEvent to shadowTruthMcEventCollection
(not saved toStoreGate
). - For each
GenEvent
in shadowTruth:
a) ApplyZeroLifetimePositioner
to deal with the issue of oscillating neutral mesons.
b) ApplyTruthPreselectionTool
. This makes a copy of theGenEvent
, identifies all particles (including quasi-stable particles) in theGenEvent
held in the BeamTruthEventMcEventCollection
which will be passed to the Simulators and add a ShadowParticleIdAttribute
holding theid
of theGenParticle
in theshadowTruth
version of theGenEvent
to them. It then loops over theGenParticle
andGenVertex
objects in theGenEvent
copy and removes all objects with an ancestor which has the ShadowParticleIdAttribute
(effectively this removes the decay trees downstream of quasi-stable particles). This modified copy of theGenEvent
is stored in the TruthEventMcEventCollection
(saved toStoreGate
). - As previously pass the
GenEvent
object(s) in TruthEvent toInputConverter::convert
. As the selection ofGenParticle
objects has already been done though, this now just createsISFParticle
objects fromGenParticle
objects with the ShadowParticleIdAttribute
. - During the building of the
G4Event
, when converting a quasi-stable particle (identified as aGenParticle
with status==2 and no endGenVertex
) to aG4PrimaryParticle
, the predefined decay chain is taken from the _shadowTruthGenEvent
instead of theGenEvent
from the TruthEventMcEventCollection
. We also avoid linkingG4PrimaryParticle
objects in the predefined decay chain to anyHepMC
truth. - Simulation then proceeds as before, the only difference is in the barcodes assigned to particles produced in predefined decays and in the ordering of
GenParticle
andGenVertex
objects in the outputGenEvent
.
Notes:
- The implementation of
TruthPreselectionTool
could be improved. Consider integrating with theInputConverter
directly? - After this is validated and switched on by default it should be possible to simplify the TruthSvc implementation considerably.
Edited by John Derek Chapman