Commit 0fb35e32 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DetectorHistogrammer: change caluclation of in-pixel position: use...

DetectorHistogrammer: change caluclation of in-pixel position: use getPixelCenter of nearest pixel instead of fmod
parent 12ce99db
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -371,10 +371,10 @@ void DetectorHistogrammerModule::run(Event* event) {
            auto particlePos = particle->getLocalReferencePoint() + track_smearing(track_resolution_);
            LOG(DEBUG) << "MCParticle at " << Units::display(particlePos, {"mm", "um"});

            auto inPixelPos = XYVector(std::fmod(particlePos.x() + pitch.x() / 2, pitch.x()),
                                       std::fmod(particlePos.y() + pitch.y() / 2, pitch.y()));
            LOG(TRACE) << "MCParticle in pixel at " << Units::display(inPixelPos, {"mm", "um"});
            // Find the nearest pixel
            auto [xpixel, ypixel] = detector_->getModel()->getPixelIndex(particlePos);

            auto inPixelPos = particlePos - detector_->getModel()->getPixelCenter(xpixel, ypixel);
            auto inPixel_um_x = static_cast<double>(Units::convert(inPixelPos.x(), "um"));
            auto inPixel_um_y = static_cast<double>(Units::convert(inPixelPos.y(), "um"));

@@ -386,9 +386,6 @@ void DetectorHistogrammerModule::run(Event* event) {
            cluster_charge_map->Fill(
                inPixel_um_x, inPixel_um_y, static_cast<double>(Units::convert(clus.getCharge(), "ke")));

            // Find the nearest pixel
            auto [xpixel, ypixel] = detector_->getModel()->getPixelIndex(particlePos);

            // Retrieve the pixel to which this MCParticle points:
            const auto* pixel = clus.getPixelHit(static_cast<unsigned int>(xpixel), static_cast<unsigned int>(ypixel));
            if(pixel != nullptr) {
@@ -425,14 +422,14 @@ void DetectorHistogrammerModule::run(Event* event) {

        // Calculate 2D local position of particle:
        auto particlePos = particle->getLocalReferencePoint() + track_smearing(track_resolution_);
        auto inPixelPos = XYVector(std::fmod(particlePos.x() + pitch.x() / 2, pitch.x()),
                                   std::fmod(particlePos.y() + pitch.y() / 2, pitch.y()));
        auto inPixel_um_x = static_cast<double>(Units::convert(inPixelPos.x(), "um"));
        auto inPixel_um_y = static_cast<double>(Units::convert(inPixelPos.y(), "um"));

        // Find the nearest pixel
        auto [xpixel, ypixel] = detector_->getModel()->getPixelIndex(particlePos);

        auto inPixelPos = particlePos - detector_->getModel()->getPixelCenter(xpixel, ypixel);
        auto inPixel_um_x = static_cast<double>(Units::convert(inPixelPos.x(), "um"));
        auto inPixel_um_y = static_cast<double>(Units::convert(inPixelPos.y(), "um"));

        auto matched_cluster =
            std::find_if(clusters.begin(), clusters.end(), [this, &particlePos, &pitch](const Cluster& clus) {
                return (std::fabs(clus.getPosition().x() * pitch.x() - particlePos.x()) < matching_cut_.x()) &&