Issue with dropping messages during the event processing
Together with @sbugiel I stumpled upon an issue with dipatching messages. If a certain message type does not have a receiver, it is dropped immediately. However, through the history of the other messages, pointers might still be there - which then get invalidated.
Demonstration:
- Write a module listening fir PixelHit messages and executing the following code:
for(auto& pixel_charge : pixel_message_->getData()) {
// Get MCparticle position
std::vector<const PropagatedCharge*> propagated_charge = pixel_charge.getPropagatedCharges();
const DepositedCharge* deposited_charge = propagated_charge.at(0) -> getDepositedCharge();
const MCParticle* mc_particle = deposited_charge -> getMCParticle();
ROOT::Math::XYZPoint mc_particle_entry = mc_particle -> getLocalEntryPoint();
- If your configuration does contain a module explicitely listening for MCParticles (such as the ROOTObjectWriter), everything works fine.
- If your configuration does not contain such a module, you will see the following output:
|14:31:46.299| (WARNING) [R:DepositionGeant4] Dispatched message Message<allpix::MCParticle> from DepositionGeant4 has no receivers!
|14:31:53.594| (FATAL) [R:DefaultDigitizer:dut] Error during execution of run:
Object PixelCharge is missing reference to PropagatedCharge
Please check your configuration and modules! Cannot continue...
because the object has already been dropped.
We should prevent this from happening and only drop messages at the end of the event processing I guess. In the same go we could also remove/rework the above WARNING
messages which are not very helpful as they are currently.