Commit 7225074b authored by Håkan Wennlöf's avatar Håkan Wennlöf
Browse files

Added a function to check whether a given position is within the pixel grid....

Added a function to check whether a given position is within the pixel grid. Updated efficiency in [DetectorHistogrammer] using this.
parent 5fa6b26f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -370,6 +370,16 @@ namespace allpix {
         */
        virtual bool isWithinMatrix(const int x, const int y) const = 0;

        /**
         * @brief Returns if a position is within the grid of pixels defined for the device
         * @param position Position in local coordinates of the detector model
         * @return True if position within the pixel grid, false otherwise
         */
        bool isWithinMatrix(const ROOT::Math::XYZPoint& position) const {
            std::pair<int, int> pixelIndex = getPixelIndex(position);
            return isWithinMatrix(pixelIndex.first, pixelIndex.second);
        }

        /**
         * @brief Returns a pixel center in local coordinates
         * @param x X- (or column-) coordinate of the pixel
+8 −0
Original line number Diff line number Diff line
@@ -551,6 +551,14 @@ void DetectorHistogrammerModule::run(Event* event) {
        // Calculate 2D local position of particle:
        auto particlePos = particle->getLocalReferencePoint() + track_smearing(track_resolution_);

        // Check whether the particle position is in the sensor excess, and exclude it from the efficiency calculation if so
        if(!detector_->getModel()->isWithinMatrix(particlePos)) {
            LOG(DEBUG) << "Particle at local coordinates x = " << particlePos.x() << " mm"
                       << ", y = " << particlePos.y() << " mm"
                       << " hit in the sensor excess; removing from efficiency calculation.";
            continue;
        }

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