Loading src/core/geometry/PixelDetectorModel.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,20 @@ bool PixelDetectorModel::isWithinMatrix(const int x, const int y) const { return !(x < 0 || x >= static_cast<int>(number_of_pixels_.x()) || y < 0 || y >= static_cast<int>(number_of_pixels_.y())); } /** * Faster implementation of matrix lookup for local coordinate positions than going through the pixel index * This is quite easy for rectangular pixels and matrices. */ bool PixelDetectorModel::isWithinMatrix(const ROOT::Math::XYZPoint& position) const { if(position.x() < 0.5 * pixel_size_.x() || position.x() > (number_of_pixels_.x() - 0.5) * pixel_size_.x()) { return false; } if(position.y() < 0.5 * pixel_size_.y() || position.y() > (number_of_pixels_.y() - 0.5) * pixel_size_.y()) { return false; } return true; } ROOT::Math::XYZPoint PixelDetectorModel::getPixelCenter(const int x, const int y) const { auto size = getPixelSize(); auto local_x = size.x() * x; Loading src/core/geometry/PixelDetectorModel.hpp +7 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,13 @@ namespace allpix { */ bool isWithinMatrix(const int x, const int y) const override; /** * @brief Returns if a position is within the grid of pixels defined for the device * @param position Position in local coordinates of the detector model * @return True if position within the pixel grid, false otherwise */ bool isWithinMatrix(const ROOT::Math::XYZPoint& position) const override; /** * @brief Returns a pixel center in local coordinates * @param x X- (or column-) coordinate of the pixel Loading Loading
src/core/geometry/PixelDetectorModel.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,20 @@ bool PixelDetectorModel::isWithinMatrix(const int x, const int y) const { return !(x < 0 || x >= static_cast<int>(number_of_pixels_.x()) || y < 0 || y >= static_cast<int>(number_of_pixels_.y())); } /** * Faster implementation of matrix lookup for local coordinate positions than going through the pixel index * This is quite easy for rectangular pixels and matrices. */ bool PixelDetectorModel::isWithinMatrix(const ROOT::Math::XYZPoint& position) const { if(position.x() < 0.5 * pixel_size_.x() || position.x() > (number_of_pixels_.x() - 0.5) * pixel_size_.x()) { return false; } if(position.y() < 0.5 * pixel_size_.y() || position.y() > (number_of_pixels_.y() - 0.5) * pixel_size_.y()) { return false; } return true; } ROOT::Math::XYZPoint PixelDetectorModel::getPixelCenter(const int x, const int y) const { auto size = getPixelSize(); auto local_x = size.x() * x; Loading
src/core/geometry/PixelDetectorModel.hpp +7 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,13 @@ namespace allpix { */ bool isWithinMatrix(const int x, const int y) const override; /** * @brief Returns if a position is within the grid of pixels defined for the device * @param position Position in local coordinates of the detector model * @return True if position within the pixel grid, false otherwise */ bool isWithinMatrix(const ROOT::Math::XYZPoint& position) const override; /** * @brief Returns a pixel center in local coordinates * @param x X- (or column-) coordinate of the pixel Loading