Loading src/core/geometry/PixelDetectorModel.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -117,10 +117,12 @@ ROOT::Math::XYZPoint PixelDetectorModel::getSensorIntercept(const ROOT::Math::XY // We have to be centered around the sensor box. This means we need to shift by the matrix center auto translation_local = ROOT::Math::Translation3D(static_cast<ROOT::Math::XYZVector>(getMatrixCenter())); try { auto intersection_point = LiangBarsky(direction, translation_local.Inverse()(inside), getSensorSize()); // Get intersection from Liang-Barsky line clipping and re-transform to local coordinates: return translation_local(LiangBarsky(direction, translation_local.Inverse()(inside), getSensorSize())); } catch(std::invalid_argument&) { if(intersection_point) { return translation_local(intersection_point.value()); } else { return inside; } } src/tools/liang_barsky.h +9 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ #include <Math/Point3D.h> #include <Math/Vector3D.h> #include <optional> namespace allpix { /** Loading @@ -28,12 +30,12 @@ namespace allpix { * @param direction Direction vector of the motion * @param position Original ("before") position to be considered * @param box Size of the box to calculate the intersections with * @return Closest intersection with box in the direction indicated by input vector * * @throws std::invalid_argument if no intersection of track segment with the box volume can be found in positive * @return Closest intersection with box in the direction indicated by input vector if there is such intersection, * std::nullopt if no intersection of track segment with the box volume can be found in positive * direction from the given position. * */ inline ROOT::Math::XYZPoint LiangBarsky(const ROOT::Math::XYZVector& direction, inline std::optional<ROOT::Math::XYZPoint> LiangBarsky(const ROOT::Math::XYZVector& direction, const ROOT::Math::XYZPoint& position, const ROOT::Math::XYZVector& box) { Loading Loading @@ -80,7 +82,7 @@ namespace allpix { } // Otherwise: The line does not intersect the box. throw std::invalid_argument("no intersection with volume boundaries found"); return std::nullopt; } } // namespace allpix Loading Loading
src/core/geometry/PixelDetectorModel.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -117,10 +117,12 @@ ROOT::Math::XYZPoint PixelDetectorModel::getSensorIntercept(const ROOT::Math::XY // We have to be centered around the sensor box. This means we need to shift by the matrix center auto translation_local = ROOT::Math::Translation3D(static_cast<ROOT::Math::XYZVector>(getMatrixCenter())); try { auto intersection_point = LiangBarsky(direction, translation_local.Inverse()(inside), getSensorSize()); // Get intersection from Liang-Barsky line clipping and re-transform to local coordinates: return translation_local(LiangBarsky(direction, translation_local.Inverse()(inside), getSensorSize())); } catch(std::invalid_argument&) { if(intersection_point) { return translation_local(intersection_point.value()); } else { return inside; } }
src/tools/liang_barsky.h +9 −7 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ #include <Math/Point3D.h> #include <Math/Vector3D.h> #include <optional> namespace allpix { /** Loading @@ -28,12 +30,12 @@ namespace allpix { * @param direction Direction vector of the motion * @param position Original ("before") position to be considered * @param box Size of the box to calculate the intersections with * @return Closest intersection with box in the direction indicated by input vector * * @throws std::invalid_argument if no intersection of track segment with the box volume can be found in positive * @return Closest intersection with box in the direction indicated by input vector if there is such intersection, * std::nullopt if no intersection of track segment with the box volume can be found in positive * direction from the given position. * */ inline ROOT::Math::XYZPoint LiangBarsky(const ROOT::Math::XYZVector& direction, inline std::optional<ROOT::Math::XYZPoint> LiangBarsky(const ROOT::Math::XYZVector& direction, const ROOT::Math::XYZPoint& position, const ROOT::Math::XYZVector& box) { Loading Loading @@ -80,7 +82,7 @@ namespace allpix { } // Otherwise: The line does not intersect the box. throw std::invalid_argument("no intersection with volume boundaries found"); return std::nullopt; } } // namespace allpix Loading