Commit 689aa9ec authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'MatrixFlipping' into 'master'

Option to mirror coupling matrix every second row (or column)

See merge request allpix-squared/allpix-squared!1148
parents bf803bfa 914f2fea
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ CapacitiveTransferModule::CapacitiveTransferModule(Configuration& config,
    model_ = detector_->getModel();
    config_.setDefault("output_plots", 0);
    config_.setDefault("cross_coupling", true);
    config_.setDefault("flip_odd_rows", false);
    config_.setDefault("flip_odd_cols", false);
    config_.setDefault("nominal_gap", 0.0);
    config_.setDefault("max_depth_distance", Units::get<double>(5, "um"));
    // By default, collect from the full sensor surface, not the implant region
@@ -46,6 +48,8 @@ CapacitiveTransferModule::CapacitiveTransferModule(Configuration& config,
    config_.setDefault("minimum_gap", config_.get<double>("nominal_gap"));

    cross_coupling_ = config_.get<bool>("cross_coupling");
    flip_odd_rows_ = config_.get<bool>("flip_odd_rows");
    flip_odd_cols_ = config_.get<bool>("flip_odd_cols");
    max_depth_distance_ = config_.get<double>("max_depth_distance");
    collect_from_implant_ = config_.get<bool>("collect_from_implant");

@@ -328,8 +332,17 @@ void CapacitiveTransferModule::run(Event* event) {
                    row = static_cast<size_t>(std::floor(matrix_rows_ / 2));
                }

                auto xcoord = xpixel + static_cast<int>(col - static_cast<size_t>(std::floor(matrix_cols_ / 2)));
                auto ycoord = ypixel + static_cast<int>(row - static_cast<size_t>(std::floor(matrix_rows_ / 2)));
                // Some designs have a mirrored crosstalk matrix which is flipped in every other row or column:
                auto row_to_use = row;
                if(flip_odd_rows_ == true && (ypixel % 2 == 1)) {
                    row_to_use = max_row_ - row - 1;
                }
                auto col_to_use = col;
                if(flip_odd_cols_ == true && (xpixel % 2 == 1)) {
                    col_to_use = max_col_ - col - 1;
                }
                auto xcoord = xpixel + static_cast<int>(col_to_use - static_cast<size_t>(std::floor(matrix_cols_ / 2)));
                auto ycoord = ypixel + static_cast<int>(row_to_use - static_cast<size_t>(std::floor(matrix_rows_ / 2)));

                // Ignore if out of pixel grid
                if(!detector_->getModel()->isWithinMatrix(xcoord, ycoord)) {
+2 −0
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ namespace allpix {
        double max_depth_distance_{};
        bool collect_from_implant_{};
        bool cross_coupling_{};
        bool flip_odd_rows_{};
        bool flip_odd_cols_{};

        void getCapacitanceScan(TFile* root_file);
        std::array<TGraph*, 9> capacitances_{};
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ This module requires an installation of Eigen3.
* `coupling_matrix`: Cross-coupling matrix with relative capacitances.
* `max_depth_distance`: Maximum distance in depth, i.e. normal to the sensor surface at the implant side, for a propagated charge to be taken into account in case the detector has no implants defined or `collect_from_implant` is set to `false`. Defaults to `5um`.
* `collect_from_implant`: Only consider charge carriers within the implant region of the respective detector instead of the full surface of the sensor. Should only be used with non-linear electric fields and defaults to `false`.
* `flip_odd_rows`: For use with designs in which every other row has a mirrored coupling matrix. Enables flipping the matrix rows for every odd pixel row. Defaults to `false` (disabled).
* `flip_odd_cols`: As above, just for the columns. Enables flipping the coupling matrix columns for every odd pixel column. Defaults to `false` (disabled).
* `output_plots`: Saves the output plots for this module. Defaults to 1 (enabled).

The cross-coupling matrix, to be parsed via the matrix file or via the configuration file, must be organized in Row vs Col, such as: