Commit 679719ad authored by Simon Spannagel's avatar Simon Spannagel
Browse files

PulseTransfer: reduce runtime by a factor 70

parent f1da2abf
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include "core/utils/log.h"
#include "objects/PixelCharge.hpp"

#include <set>
#include <string>
#include <utility>

@@ -96,7 +97,7 @@ void PulseTransferModule::run(Event* event) {

    // Create map for all pixels: pulse and propagated charges
    std::map<Pixel::Index, Pulse> pixel_pulse_map;
    std::map<Pixel::Index, std::vector<const PropagatedCharge*>> pixel_charge_map;
    std::map<Pixel::Index, std::set<const PropagatedCharge*>> pixel_charge_map;

    LOG(DEBUG) << "Received " << propagated_message->getData().size() << " propagated charge objects.";
    for(const auto& propagated_charge : propagated_message->getData()) {
@@ -156,11 +157,8 @@ void PulseTransferModule::run(Event* event) {
            }
            pixel_pulse_map[pixel_index] += pulse;

            auto px = pixel_charge_map[pixel_index];
            // For each pulse, store the corresponding propagated charges to preserve history:
            if(std::find(px.begin(), px.end(), &propagated_charge) == px.end()) {
                pixel_charge_map[pixel_index].emplace_back(&propagated_charge);
            }
            pixel_charge_map[pixel_index].emplace(&propagated_charge);
        } else {
            LOG(TRACE) << "Found pulse information";
            LOG_ONCE(INFO) << "Pulses available - settings \"timestep\", \"max_depth_distance\" and "
@@ -170,11 +168,8 @@ void PulseTransferModule::run(Event* event) {
                // Accumulate all pulses from input message data:
                pixel_pulse_map[pixel_index] += pulse;

                auto px = pixel_charge_map[pixel_index];
                // For each pulse, store the corresponding propagated charges to preserve history:
                if(std::find(px.begin(), px.end(), &propagated_charge) == px.end()) {
                    pixel_charge_map[pixel_index].emplace_back(&propagated_charge);
                }
                pixel_charge_map[pixel_index].emplace(&propagated_charge);
            }
        }
    }
@@ -212,7 +207,9 @@ void PulseTransferModule::run(Event* event) {
        LOG(DEBUG) << "Charge on pixel " << index << " has " << pixel_charge_map[index].size() << " ancestors";

        // Store the pulse:
        pixel_charges.emplace_back(detector_->getPixel(index), std::move(pulse), pixel_charge_map[index]);
        std::vector<const PropagatedCharge*> pixel_charge_vec(pixel_charge_map[index].begin(),
                                                              pixel_charge_map[index].end());
        pixel_charges.emplace_back(detector_->getPixel(index), std::move(pulse), std::move(pixel_charge_vec));
    }

    if(output_pulsegraphs_) {