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
McEventCollectionas previously. Copy BeamTruthEvent to shadowTruthMcEventCollection(not saved toStoreGate). - For each
GenEventin shadowTruth:
a) ApplyZeroLifetimePositionerto deal with the issue of oscillating neutral mesons.
b) ApplyTruthPreselectionTool. This makes a copy of theGenEvent, identifies all particles (including quasi-stable particles) in theGenEventheld in the BeamTruthEventMcEventCollectionwhich will be passed to the Simulators and add a ShadowParticleIdAttributeholding theidof theGenParticlein theshadowTruthversion of theGenEventto them. It then loops over theGenParticleandGenVertexobjects in theGenEventcopy 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 theGenEventis stored in the TruthEventMcEventCollection(saved toStoreGate). - As previously pass the
GenEventobject(s) in TruthEvent toInputConverter::convert. As the selection ofGenParticleobjects has already been done though, this now just createsISFParticleobjects fromGenParticleobjects with the ShadowParticleIdAttribute. - During the building of the
G4Event, when converting a quasi-stable particle (identified as aGenParticlewith status==2 and no endGenVertex) to aG4PrimaryParticle, the predefined decay chain is taken from the _shadowTruthGenEventinstead of theGenEventfrom the TruthEventMcEventCollection. We also avoid linkingG4PrimaryParticleobjects in the predefined decay chain to anyHepMCtruth. - Simulation then proceeds as before, the only difference is in the barcodes assigned to particles produced in predefined decays and in the ordering of
GenParticleandGenVertexobjects in the outputGenEvent.
Notes:
- The implementation of
TruthPreselectionToolcould be improved. Consider integrating with theInputConverterdirectly? - After this is validated and switched on by default it should be possible to simplify the TruthSvc implementation considerably.
Edited by John Derek Chapman