Skip to content

PixelCharge: fix bug where times were *always* set to zero

Simon Spannagel requested to merge f-pulse-times into master

Discovered thanks to this forum thread:

In the PulseTransfer we then convert the generated and propagated charge carriers into a pulse and add that (including its references the MCParticles) to the PixelCharge object - and here things go wrong. Look at the following code:

// Store the MC particle references
for(const auto& mc_particle : unique_particles) {
    // Local and global time are set as the earliest time found among the MCParticles:
    if(mc_particle != nullptr) {
        const auto* primary = mc_particle->getPrimary();
        local_time_ = std::min(local_time_, primary->getLocalTime());
        global_time_ = std::min(global_time_, primary->getGlobalTime());
    }
    mc_particles_.emplace_back(mc_particle);
}

...it looks innocent enough - but if both local_time_ and global_time_ were initialized to zero, they will always and forever remain zero. :/

New approach: initialize to infinity and only set to zero if no value could be found.

Merge request reports