Commit 897b627d authored by Stephan Lachnit's avatar Stephan Lachnit
Browse files

Merge branch 'p-perf_transient' into 'master'

Some Performance Improvements for Transient Analyses

See merge request allpix-squared/allpix-squared!902
parents 9b746a8a 8327fd32
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ ADD_LIBRARY(
    config/ConfigManager.cpp
    config/OptionParser.cpp
    geometry/Detector.cpp
    geometry/DetectorField.cpp
    geometry/DetectorModel.cpp
    geometry/PixelDetectorModel.cpp
    geometry/GeometryManager.cpp
+0 −33
Original line number Diff line number Diff line
/**
 * @file
 * @brief Implementation of detector fields
 *
 * @copyright Copyright (c) 2018-2022 CERN and the Allpix Squared authors.
 * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md".
 * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an
 * Intergovernmental Organization or submit itself to any jurisdiction.
 * SPDX-License-Identifier: MIT
 */

#include "DetectorField.hpp"

namespace allpix {

    /*
     * Vector field template specialization of helper function for field flipping
     */
    template <> void flip_vector_components<ROOT::Math::XYZVector>(ROOT::Math::XYZVector& vec, bool x, bool y) {
        if(x) {
            vec.SetX(-vec.x());
        }
        if(y) {
            vec.SetY(-vec.y());
        }
    }

    /*
     * Scalar field template specialization of helper function for field flipping
     * Here, no inversion of the field components is required
     */
    template <> void flip_vector_components<double>(double&, bool, bool) {}
} // namespace allpix
+13 −0
Original line number Diff line number Diff line
@@ -74,6 +74,19 @@ namespace allpix {
     */
    template <typename T> void flip_vector_components(T& field, bool x, bool y);

    /*
     * Vector field template specialization of helper function for field flipping
     */
    template <> inline void flip_vector_components<ROOT::Math::XYZVector>(ROOT::Math::XYZVector& vec, bool x, bool y) {
        vec.SetXYZ((x ? -vec.x() : vec.x()), (y ? -vec.y() : vec.y()), vec.z());
    }

    /*
     * Scalar field template specialization of helper function for field flipping
     * Here, no inversion of the field components is required
     */
    template <> inline void flip_vector_components<double>(double&, bool, bool) {}

    /**
     * @brief Field instance of a detector
     *
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ namespace allpix {

        // Return empty field if outside the matrix or no field is set
        auto [px, py] = model_->getPixelIndex(pos);
        if(!model_->isWithinMatrix(px, py) || type_ == FieldType::NONE) {
        if(type_ == FieldType::NONE || !model_->isWithinMatrix(px, py)) {
            return {};
        }

+3 −3
Original line number Diff line number Diff line
@@ -127,9 +127,9 @@ bool HexagonalPixelDetectorModel::areNeighbors(const Pixel::Index& seed,
// Rounding is more easy in cubic coordinates, so we need to reconstruct the third coordinate from the other two as z = - x -
// y:
std::pair<int, int> HexagonalPixelDetectorModel::round_to_nearest_hex(double x, double y) const {
    auto q = static_cast<int>(std::round(x));
    auto r = static_cast<int>(std::round(y));
    auto s = static_cast<int>(std::round(-x - y));
    auto q = static_cast<int>(std::lround(x));
    auto r = static_cast<int>(std::lround(y));
    auto s = static_cast<int>(std::lround(-x - y));
    double q_diff = std::abs(q - x);
    double r_diff = std::abs(r - y);
    double s_diff = std::abs(s - (-x - y));
Loading