Commit 8ad4d43c authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DetectorHistogrammer: use DetectorModel to calculate Cluster index

parent 02d6bdbd
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -58,22 +58,13 @@ bool Cluster::addPixelHit(const PixelHit* pixel_hit) {
    return false;
}

std::pair<double, double> Cluster::getIndex() const {
    double x = 0, y = 0;
    for(const auto& pixel : this->getPixelHits()) {
        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::XYZPoint Cluster::getPosition() const {
    ROOT::Math::XYZVector meanPos;
    for(const auto& pixel : this->getPixelHits()) {
        meanPos = pixel->getPixel().getLocalCenter() * pixel->getSignal() + meanPos;
    }
    meanPos /= getCharge();
    return meanPos;
    return static_cast<ROOT::Math::XYZPoint>(meanPos);
}

std::pair<unsigned int, unsigned int> Cluster::getSizeXY() const {
+1 −7
Original line number Diff line number Diff line
@@ -51,17 +51,11 @@ namespace allpix {
         */
        std::pair<unsigned int, unsigned int> getSizeXY() const;

        /**
         * @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::XYZVector getPosition() const;
        ROOT::Math::XYZPoint getPosition() const;

        /**
         * @brief Get the seed PixelHit, i.e. the PixelHit with the largest charge
+1 −2
Original line number Diff line number Diff line
@@ -351,8 +351,8 @@ void DetectorHistogrammerModule::run(Event* event) {
        cluster_size_x->Fill(clusSizesXY.first);
        cluster_size_y->Fill(clusSizesXY.second);

        auto [cluster_x, cluster_y] = clus.getIndex();
        auto clusterPos = clus.getPosition();
        auto [cluster_x, cluster_y] = detector_->getModel()->getPixelIndex(clusterPos);
        LOG(DEBUG) << "Cluster at indices " << cluster_x << ", " << cluster_y << "(" << clusterPos
                   << " local coordinates) with charge " << Units::display(clus.getCharge(), "ke");
        cluster_map->Fill(cluster_x, cluster_y);
@@ -399,7 +399,6 @@ void DetectorHistogrammerModule::run(Event* event) {
                inPixel_um_x, inPixel_um_y, static_cast<double>(Units::convert(seed_pixel->getSignal(), "ke")));
            cluster_seed_charge->Fill(static_cast<double>(Units::convert(seed_pixel->getSignal(), "ke")));


            // Calculate residual with cluster position:
            auto residual_um_x = static_cast<double>(Units::convert(particlePos.x() - clusterPos.x(), "um"));
            auto residual_um_y = static_cast<double>(Units::convert(particlePos.y() - clusterPos.y(), "um"));