Commit a852f3b9 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DetectorModel: get rid of off double-getNeighbors method

parent 6efbaa5b
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -241,27 +241,6 @@ std::set<Pixel::Index> DetectorModel::getNeighbors(const Pixel::Index& idx, cons
    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;

    auto x_lower = static_cast<int>(std::min(idx.x(), last_idx.x()) - distance);
    auto x_higher = static_cast<int>(std::max(idx.x(), last_idx.x()) + distance);
    auto y_lower = static_cast<int>(std::min(idx.y(), last_idx.y()) - distance);
    auto y_higher = static_cast<int>(std::max(idx.y(), last_idx.y()) + distance);

    for(int x = x_lower; x <= x_higher; x++) {
        for(int y = y_lower; y <= y_higher; y++) {
            if(!isWithinPixelGrid(x, y)) {
                continue;
            }
            neighbors.insert({static_cast<unsigned int>(x), static_cast<unsigned int>(y)});
        }
    }

    return neighbors;
}

bool DetectorModel::areNeighbors(const Pixel::Index& seed, const Pixel::Index& entrant, const size_t distance) const {
    auto pixel_distance = [](unsigned int lhs, unsigned int rhs) { return (lhs > rhs ? lhs - rhs : rhs - lhs); };
    return (pixel_distance(seed.x(), entrant.x()) <= distance && pixel_distance(seed.y(), entrant.y()) <= distance);
+0 −12
Original line number Diff line number Diff line
@@ -420,18 +420,6 @@ namespace allpix {
         */
        virtual std::set<Pixel::Index> getNeighbors(const Pixel::Index& idx, const size_t distance) const;

        /**
         * @brief Return a set containing all pixels neighboring the two given pixels with a configurable maximum distance
         * @param idx       Index of the first pixel in question
         * @param last_idx  Index of the second pixel in question
         * @param distance  Distance for pixels to be considered neighbors
         * @return Set of neighboring pixel indices, including the two initial pixels
         *
         * @note The returned set should always also include the initial pixel indices the neighbors are calculated for
         */
        virtual std::set<Pixel::Index>
        getNeighbors(const Pixel::Index& idx, const Pixel::Index& last_idx, const size_t distance) const;

        /**
         * @brief Check if two pixel indices are neighbors to each other
         * @param  seed    Initial pixel index
+3 −1
Original line number Diff line number Diff line
@@ -390,7 +390,9 @@ TransientPropagationModule::propagate(Event* event,
        auto idx = Pixel::Index(static_cast<unsigned int>(xpixel), static_cast<unsigned int>(ypixel));
        auto last_idx = Pixel::Index(static_cast<unsigned int>(last_xpixel), static_cast<unsigned int>(last_ypixel));

        for(const auto& pixel_index : model_->getNeighbors(idx, last_idx, distance_)) {
        auto neighbors = model_->getNeighbors(idx, distance_);
        neighbors.merge(model_->getNeighbors(last_idx, distance_));
        for(const auto& pixel_index : neighbors) {
            auto ramo = detector_->getWeightingPotential(static_cast<ROOT::Math::XYZPoint>(position), pixel_index);
            auto last_ramo = detector_->getWeightingPotential(static_cast<ROOT::Math::XYZPoint>(last_position), pixel_index);