Commit cea4ac03 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DetectorModel: Move getSensorIntercept to PixelDetector class

parent 5c3aa33c
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -15,9 +15,6 @@
#include "core/geometry/HybridPixelDetectorModel.hpp"
#include "core/geometry/MonolithicPixelDetectorModel.hpp"
#include "core/geometry/RadialStripDetectorModel.hpp"
#include "tools/liang_barsky.h"

#include <Math/Translation3D.h>

using namespace allpix;

@@ -191,18 +188,3 @@ std::vector<DetectorModel::SupportLayer> DetectorModel::getSupportLayers() const

    return ret_layers;
}

ROOT::Math::XYZPoint DetectorModel::getSensorIntercept(const ROOT::Math::XYZPoint& inside,
                                                       const ROOT::Math::XYZPoint& outside) const {
    // Get direction vector of motion *out of* sensor
    auto direction = (outside - inside).Unit();
    // 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 {
        // 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&) {
        return inside;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -398,9 +398,11 @@ namespace allpix {
         * @param  inside Position before the step, inside the sensor volume
         * @param  outside  Position after the step, outside the sensor volume
         * @return Exit point of the sensor in local coordinates
         *
         * @note This method is purely virtual and must be implemented by the respective concrete detector model classes
         */
        ROOT::Math::XYZPoint getSensorIntercept(const ROOT::Math::XYZPoint& inside,
                                                const ROOT::Math::XYZPoint& outside) const;
        virtual ROOT::Math::XYZPoint getSensorIntercept(const ROOT::Math::XYZPoint& inside,
                                                        const ROOT::Math::XYZPoint& outside) const = 0;

        /**
         * @brief Returns if a local position is within the pixel implant region of the sensitive device
+18 −0
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@

#include "PixelDetectorModel.hpp"
#include "core/module/exceptions.h"
#include "tools/liang_barsky.h"

#include <Math/Translation3D.h>

using namespace allpix;

@@ -103,3 +106,18 @@ bool PixelDetectorModel::areNeighbors(const Pixel::Index& seed, const Pixel::Ind
    return (static_cast<size_t>(std::abs(seed.x() - entrant.x())) <= distance &&
            static_cast<size_t>(std::abs(seed.y() - entrant.y())) <= distance);
}

ROOT::Math::XYZPoint PixelDetectorModel::getSensorIntercept(const ROOT::Math::XYZPoint& inside,
                                                            const ROOT::Math::XYZPoint& outside) const {
    // Get direction vector of motion *out of* sensor
    auto direction = (outside - inside).Unit();
    // 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 {
        // 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&) {
        return inside;
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -49,6 +49,19 @@ namespace allpix {
         */
        bool isWithinSensor(const ROOT::Math::XYZPoint& local_pos) const override;

        /**
         * @brief Calculate exit point of step outside sensor volume from one point inside the sensor (before step) and one
         * point outside (after step).
         * @throws std::invalid_argument if no intersection of track segment with sensor volume can be found
         * @param  inside Position before the step, inside the sensor volume
         * @param  outside  Position after the step, outside the sensor volume
         * @return Exit point of the sensor in local coordinates
         *
         * @note This method uses the Liang-Barsky clipping of a line segment with a box
         */
        ROOT::Math::XYZPoint getSensorIntercept(const ROOT::Math::XYZPoint& inside,
                                                const ROOT::Math::XYZPoint& outside) const override;

        /**
         * @brief Returns if a local position is within the pixel implant region of the sensitive device
         * @param local_pos Position in local coordinates of the detector model