Commit a95ff829 authored by Paul Schütze's avatar Paul Schütze
Browse files

Merge branch 'nearest_pixel' into 'master'

DetectorHistogrammer: move to using getPixelIndex instead of hard-coded pitch division

See merge request allpix-squared/allpix-squared!538
parents 904ae5e1 86d38fdc
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -349,11 +349,10 @@ void DetectorHistogrammerModule::run(Event* event) {
                inPixel_um_x, inPixel_um_y, static_cast<double>(Units::convert(clus.getCharge(), "ke")));

            // Find the nearest pixel
            auto xpixel = static_cast<unsigned int>(std::round(particlePos.x() / pitch.x()));
            auto ypixel = static_cast<unsigned int>(std::round(particlePos.y() / pitch.y()));
            auto [xpixel, ypixel] = detector_->getModel()->getPixelIndex(particlePos);

            // Retrieve the pixel to which this MCParticle points:
            const auto* pixel = clus.getPixelHit(xpixel, ypixel);
            const auto* pixel = clus.getPixelHit(static_cast<unsigned int>(xpixel), static_cast<unsigned int>(ypixel));
            if(pixel != nullptr) {
                seed_charge_map->Fill(
                    inPixel_um_x, inPixel_um_y, static_cast<double>(Units::convert(pixel->getSignal(), "ke")));
@@ -394,8 +393,7 @@ void DetectorHistogrammerModule::run(Event* event) {
        auto inPixel_um_y = static_cast<double>(Units::convert(inPixelPos.y(), "um"));

        // Find the nearest pixel
        auto xpixel = static_cast<unsigned int>(std::round(particlePos.x() / pitch.x()));
        auto ypixel = static_cast<unsigned int>(std::round(particlePos.y() / pitch.y()));
        auto [xpixel, ypixel] = detector_->getModel()->getPixelIndex(particlePos);

        auto matched_cluster =
            std::find_if(clusters.begin(), clusters.end(), [this, &particlePos, &pitch](const Cluster& clus) {