Commit 0fad1f82 authored by Håkan Wennlöf's avatar Håkan Wennlöf
Browse files

Merge branch 'p-noise-all-channels' into 'master'

Allow Adding Noise on All Channels

See merge request allpix-squared/allpix-squared!1130
parents 8d8cdcc3 5993e591
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -448,6 +448,14 @@ namespace allpix {
         */
        virtual std::pair<int, int> getPixelIndex(const ROOT::Math::XYZPoint& local_pos) const = 0;

        /**
         * @brief Return a set containing all pixels of the matrix
         * @return Set of all pixel indices of the matrix
         *
         * @note This method is purely virtual and must be implemented by the respective concrete detector model classes
         */
        virtual std::set<Pixel::Index> getPixels() const = 0;

        /**
         * @brief Return a set containing all pixels neighboring the given one with a configurable maximum distance
         * @param idx       Index of the pixel in question
+13 −0
Original line number Diff line number Diff line
@@ -105,6 +105,19 @@ ROOT::Math::XYZVector HexagonalPixelDetectorModel::getMatrixSize() const {
    return {limit_right - corner_offset_left, limit_top - corner_offset_bottom, 0};
}

std::set<Pixel::Index> HexagonalPixelDetectorModel::getPixels() const {
    std::set<Pixel::Index> pixels;

    for(int x = -static_cast<int>(number_of_pixels_.y() / 2); x < static_cast<int>(number_of_pixels_.x()); x++) {
        for(int y = -static_cast<int>(number_of_pixels_.x() / 2); y < static_cast<int>(number_of_pixels_.y()); y++) {
            if(isWithinMatrix(x, y)) {
                pixels.insert({x, y});
            }
        }
    }
    return pixels;
}

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

+6 −0
Original line number Diff line number Diff line
@@ -90,6 +90,12 @@ namespace allpix {
         */
        ROOT::Math::XYZVector getMatrixSize() const override;

        /**
         * @brief Return a set containing all pixels of the matrix
         * @return Set of all pixel indices of the matrix
         */
        std::set<Pixel::Index> getPixels() const override;

        /**
         * @brief Return a set containing all pixels neighboring the given one with a configurable maximum distance
         * @param idx       Index of the pixel in question
+13 −0
Original line number Diff line number Diff line
@@ -123,9 +123,21 @@ std::pair<int, int> PixelDetectorModel::getPixelIndex(const ROOT::Math::XYZPoint
    return {pixel_x, pixel_y};
}

std::set<Pixel::Index> PixelDetectorModel::getPixels() const {
    std::set<Pixel::Index> pixels;
    for(int x = 0; x < static_cast<int>(number_of_pixels_.x()); x++) {
        for(int y = 0; y < static_cast<int>(number_of_pixels_.y()); y++) {
            pixels.insert({x, y});
        }
    }
    return pixels;
}

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

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-overflow"
    for(int x = idx.x() - static_cast<int>(distance); x <= idx.x() + static_cast<int>(distance); x++) {
        for(int y = idx.y() - static_cast<int>(distance); y <= idx.y() + static_cast<int>(distance); y++) {
            if(!isWithinMatrix(x, y)) {
@@ -134,6 +146,7 @@ std::set<Pixel::Index> PixelDetectorModel::getNeighbors(const Pixel::Index& idx,
            neighbors.insert({x, y});
        }
    }
#pragma GCC diagnostic pop

    return neighbors;
}
+6 −0
Original line number Diff line number Diff line
@@ -113,6 +113,12 @@ namespace allpix {
         */
        std::pair<int, int> getPixelIndex(const ROOT::Math::XYZPoint& local_pos) const override;

        /**
         * @brief Return a set containing all pixels of the matrix
         * @return Set of all pixel indices of the matrix
         */
        std::set<Pixel::Index> getPixels() const override;

        /**
         * @brief Return a set containing all pixels neighboring the given one with a configurable maximum distance
         * @param idx       Index of the pixel in question
Loading