src/core/geometry/HexagonalPixelDetectorModel.hpp

Detector model with hexagonal pixel shape. More…

Namespaces

Name
allpix
Helper class to hold support layers for a detector model.

Classes

Name
class allpix::HexagonalPixelDetectorModel
Detector model with hexagonal pixel grid.

Detailed Description

Detector model with hexagonal pixel shape.

Copyright: Copyright (c) 2021-2024 CERN and the Allpix Squared authors. This software is distributed under the terms of the MIT License, copied verbatim in the file “LICENSE.md”. In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction. SPDX-License-Identifier: MIT

Source code


#ifndef ALLPIX_HEXAGONAL_PIXEL_DETECTOR_H
#define ALLPIX_HEXAGONAL_PIXEL_DETECTOR_H

#include "PixelDetectorModel.hpp"

namespace allpix {
    class HexagonalPixelDetectorModel : public PixelDetectorModel {
    public:
        explicit HexagonalPixelDetectorModel(std::string type,
                                             const std::shared_ptr<DetectorAssembly>& assembly,
                                             const ConfigReader& reader,
                                             const Configuration& config);

        ~HexagonalPixelDetectorModel() override = default;

        ROOT::Math::XYZPoint getMatrixCenter() const override;

        ROOT::Math::XYZPoint getPixelCenter(const int x, const int y) const override;

        std::pair<int, int> getPixelIndex(const ROOT::Math::XYZPoint& position) const override;

        bool isWithinMatrix(const int x, const int y) const override;

        bool isWithinMatrix(const Pixel::Index& pixel_index) const override;

        ROOT::Math::XYZVector getMatrixSize() const override;

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

        bool areNeighbors(const Pixel::Index& seed, const Pixel::Index& entrant, const size_t distance) const override;

    private:
        // Transformations from axial coordinates to cartesian coordinates
        const std::array<double, 4> transform_pointy_{std::sqrt(3.0), std::sqrt(3.0) / 2.0, 0.0, 3.0 / 2.0};
        const std::array<double, 4> transform_flat_{3.0 / 2.0, 0.0, std::sqrt(3.0) / 2.0, std::sqrt(3.0)};

        // Inverse transformations, going from cartesian coordinates to axial coordinates
        const std::array<double, 4> inv_transform_pointy_{std::sqrt(3.0) / 3.0, -1.0 / 3.0, 0.0, 2.0 / 3.0};
        const std::array<double, 4> inv_transform_flat_{2.0 / 3.0, 0.0, -1.0 / 3.0, std::sqrt(3.0) / 3.0};

        double get_pixel_center_x(const int x, const int y) const;

        double get_pixel_center_y(const int x, const int y) const;

        double start_angle() const { return (pixel_type_ == Pixel::Type::HEXAGON_POINTY ? 0.5 : 0.0); }

        std::pair<int, int> round_to_nearest_hex(double x, double y) const;

        size_t hex_distance(double x1, double y1, double x2, double y2) const;
    };
} // namespace allpix

#endif /* ALLPIX_HEXAGONAL_PIXEL_DETECTOR_H */

Updated on 2024-12-13 at 08:31:37 +0000