Commit 9ca0364c authored by Simon Spannagel's avatar Simon Spannagel
Browse files

HexagonalPixelDetector: adjust to new names of DetectorModule methods

parent 1bb0b034
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@ HexagonalPixelDetectorModel::HexagonalPixelDetectorModel(std::string type, const
    }
}

ROOT::Math::XYZPoint HexagonalPixelDetectorModel::getCenter() const {
    auto grid = getGridSize();
ROOT::Math::XYZPoint HexagonalPixelDetectorModel::getMatrixCenter() const {
    auto grid = getMatrixSize();
    auto corner_offset_left = pixel_size_.x() / 2 * std::cos(M_PI * (start_angle() + 3) / 3);   // corner 3
    auto corner_offset_bottom = pixel_size_.y() / 2 * std::sin(M_PI * (start_angle() + 4) / 3); // corner 4
    return {grid.x() / 2.0 + corner_offset_left, grid.y() / 2.0 + corner_offset_bottom, 0};
@@ -66,7 +66,7 @@ std::pair<int, int> HexagonalPixelDetectorModel::getPixelIndex(const ROOT::Math:
    return round_to_nearest_hex(q, r);
}

bool HexagonalPixelDetectorModel::isWithinPixelGrid(const int x, const int y) const {
bool HexagonalPixelDetectorModel::isWithinMatrix(const int x, const int y) const {
    // Check the valid pixel indices - this depends on the orientation of the axial index coordinate system with respect to
    // the cartesian local coordinate system, so we need to allow different indices depending on the hexagon orientation:
    if(pixel_type_ == Pixel::Type::HEXAGON_POINTY) {
@@ -78,11 +78,11 @@ bool HexagonalPixelDetectorModel::isWithinPixelGrid(const int x, const int y) co
    }
}

bool HexagonalPixelDetectorModel::isWithinPixelGrid(const Pixel::Index& pixel_index) const {
    return isWithinPixelGrid(pixel_index.x(), pixel_index.y());
bool HexagonalPixelDetectorModel::isWithinMatrix(const Pixel::Index& pixel_index) const {
    return isWithinMatrix(pixel_index.x(), pixel_index.y());
}

ROOT::Math::XYZVector HexagonalPixelDetectorModel::getGridSize() const {
ROOT::Math::XYZVector HexagonalPixelDetectorModel::getMatrixSize() const {
    auto corner_offset_right = pixel_size_.x() / 2 * std::cos(M_PI * start_angle() / 3);        // corner 0
    auto corner_offset_top = pixel_size_.y() / 2 * std::sin(M_PI * (start_angle() + 1) / 3);    // corner 1
    auto corner_offset_left = pixel_size_.x() / 2 * std::cos(M_PI * (start_angle() + 3) / 3);   // corner 3
@@ -104,7 +104,7 @@ std::set<Pixel::Index> HexagonalPixelDetectorModel::getNeighbors(const Pixel::In
        for(int y = idx.y() - static_cast<int>(distance); y <= idx.y() + static_cast<int>(distance); y++) {
            // "cut off" the corners of the rectangle around the index in question to make it a hexagon, remove
            // indices outside the pixel grid
            if(std::abs(x - idx.x() + y - idx.y()) <= static_cast<int>(distance) && isWithinPixelGrid(x, y)) {
            if(std::abs(x - idx.x() + y - idx.y()) <= static_cast<int>(distance) && isWithinMatrix(x, y)) {
                neighbors.insert({x, y});
            }
        }
+4 −4
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ namespace allpix {
         *
         * The center coordinate corresponds to the \ref Detector::getPosition "position" in the global frame.
         */
        ROOT::Math::XYZPoint getCenter() const override;
        ROOT::Math::XYZPoint getMatrixCenter() const override;

        /**
         * @brief Returns a pixel center in local coordinates
@@ -74,20 +74,20 @@ namespace allpix {
         * therefore need to check the allowed range along x as a function of the y coordinate. The integer division by two
         * ensures we allow for one more x coordinate every other row in y.
         */
        bool isWithinPixelGrid(const int x, const int y) const override;
        bool isWithinMatrix(const int x, const int y) const override;

        /**
         * @brief Returns if a pixel index is within the grid of pixels defined for the device
         * @param pixel_index Pixel index to be checked
         * @return True if pixel_index is within the pixel grid, false otherwise
         */
        bool isWithinPixelGrid(const Pixel::Index& pixel_index) const override;
        bool isWithinMatrix(const Pixel::Index& pixel_index) const override;

        /**
         * @brief Return gridsize along X,Y of a hexagonal sensor grid.
         * @return X and Y gridlength length in mm
         */
        ROOT::Math::XYZVector getGridSize() const override;
        ROOT::Math::XYZVector getMatrixSize() const override;

        /**
         * @brief Return a set containing all pixels neighboring the given one with a configurable maximum distance