Commit 1d60e64f authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Cluster: change getPosition to return position on local coords, getIndex for indices

parent d3e44302
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -58,11 +58,19 @@ bool Cluster::addPixelHit(const PixelHit* pixel_hit) {
    return false;
}

ROOT::Math::XYVectorD Cluster::getPosition() const {
    ROOT::Math::XYVectorD meanPos = ROOT::Math::XYVectorD(0., 0.);
std::pair<double, double> Cluster::getIndex() const {
    double x = 0, y = 0;
    for(const auto& pixel : this->getPixelHits()) {
        meanPos += ROOT::Math::XYVectorD(pixel->getPixel().getIndex().x() * pixel->getSignal(),
                                         pixel->getPixel().getIndex().y() * pixel->getSignal());
        x += pixel->getPixel().getIndex().x() * pixel->getSignal();
        y += pixel->getPixel().getIndex().y() * pixel->getSignal();
    }
    return {x / getCharge(), y / getCharge()};
}

ROOT::Math::XYZVector Cluster::getPosition() const {
    ROOT::Math::XYZVector meanPos;
    for(const auto& pixel : this->getPixelHits()) {
        meanPos = pixel->getPixel().getLocalCenter() * pixel->getSignal() + meanPos;
    }
    meanPos /= getCharge();
    return meanPos;
+9 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
#ifndef ALLPIX_DETECTOR_HISTOGRAMMER_CLUSTER_H
#define ALLPIX_DETECTOR_HISTOGRAMMER_CLUSTER_H

#include <Math/DisplacementVector2D.h>
#include <Math/Vector3D.h>

#include <set>

@@ -52,10 +52,16 @@ namespace allpix {
        std::pair<unsigned int, unsigned int> getSizeXY() const;

        /**
         * @brief Get the charge-weighted mean cluster position
         * @brief Get the charge-weighted mean cluster position in index coordinates
         * @return Indices of weighted mean cluster position
         */
        std::pair<double, double> getIndex() const;

        /**
         * @brief Get the charge-weighted mean cluster position in local coordinates
         * @return weighted mean cluster position
         */
        ROOT::Math::XYVectorD getPosition() const;
        ROOT::Math::XYZVector getPosition() const;

        /**
         * @brief Get the seed PixelHit, i.e. the PixelHit with the largest charge