Commit 88ff94e9 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Apply 3 suggestion(s) to 1 file(s)

parent adb90b7a
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -23,15 +23,16 @@ StaggeredPixelDetectorModel::StaggeredPixelDetectorModel(std::string type,
    // Read tile offset - for now only possible along x, applied to odd rows
    offset_ = config.get<double>("pixel_offset");
    if(std::fabs(offset_) >= 1.0) {
        throw InvalidValueError(config,
        throw InvalidValueError(
            config,
            "pixel_offset",
                                "pixel offset should be provided in fractions of the pitch and cannot be larger than +-1.0");
            "pixel offset should be provided in fractions of the pitch and cannot be larger than or equal to +-1.0");
    }
}

ROOT::Math::XYZPoint StaggeredPixelDetectorModel::getMatrixCenter() const {
    // Matrix center is shifted by the pixel offset along x - if the offset is negative, because then the origin of the
    // local coordinate system not the leftmost pixel anymore, the matrix center is calculated relative to the local origin
    // The matrix center is calculated relative to the local origin. It is shifted by the pixel offset along x only if the
    // offset is negative, because then the origin of the local coordinate system is not the leftmost pixel anymore.
    return {getMatrixSize().x() / 2.0 - getPixelSize().x() / 2.0 + (offset_ < 0 ? offset_ : 0.) * getPixelSize().x(),
            getMatrixSize().y() / 2.0 - getPixelSize().y() / 2.0,
            0};
@@ -42,10 +43,6 @@ ROOT::Math::XYZVector StaggeredPixelDetectorModel::getMatrixSize() const {
    return {(getNPixels().x() + std::fabs(offset_)) * getPixelSize().x(), getNPixels().y() * getPixelSize().y(), 0};
}

/**
 * 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 StaggeredPixelDetectorModel::isWithinMatrix(const ROOT::Math::XYZPoint& position) const {
    // Get indices of this pixel:
    const auto indices = getPixelIndex(position);