Commit 06f4a373 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DetectorModel: also add getNeighbors for single pixel

parent 892d9315
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -226,6 +226,21 @@ std::pair<int, int> DetectorModel::getPixelIndex(const ROOT::Math::XYZPoint& pos
    return {pixel_x, pixel_y};
}

std::set<Pixel::Index> DetectorModel::getNeighbors(const Pixel::Index& idx, const size_t distance) const {
    std::set<Pixel::Index> neighbors;

    for(int x = static_cast<int>(idx.x() - distance); x <= static_cast<int>(idx.x() + distance); x++) {
        for(int y = static_cast<int>(idx.y() - distance); y <= static_cast<int>(idx.y() + distance); y++) {
            if(!isWithinPixelGrid(x, y)) {
                continue;
            }
            neighbors.insert({static_cast<unsigned int>(x), static_cast<unsigned int>(y)});
        }
    }

    return neighbors;
}

std::set<Pixel::Index>
DetectorModel::getNeighbors(const Pixel::Index& idx, const Pixel::Index& last_idx, const size_t distance) const {
    std::set<Pixel::Index> neighbors;
+11 −3
Original line number Diff line number Diff line
@@ -411,9 +411,17 @@ namespace allpix {
        virtual std::pair<int, int> getPixelIndex(const ROOT::Math::XYZPoint& position) const;

        /**
         * @brief Return a set containing all the neighboring pixels
         * @param idx       Index of the current pixel in question
         * @param last_idx  Index of the last pixel in question
         * @brief Return a set containing all channels neigboring the given one with a configurable maximum distance
         * @param idx       Index of the channel in question
         * @param distance  Distance for pixels to be considered neighbors
         * @return Set of neighboring pixel indices
         */
        virtual std::set<Pixel::Index> getNeighbors(const Pixel::Index& idx, const size_t distance) const;

        /**
         * @brief Return a set containing all channels neigboring the two given channels with a configurable maximum distance
         * @param idx       Index of the first channel in question
         * @param last_idx  Index of the second channel in question
         * @param distance  Distance for pixels to be considered neighbors
         * @return Set of neighboring pixel indices
         */