Commit a6efbc23 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DetectorField: re-introduce offset

parent 0b517bdc
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -158,9 +158,10 @@ void Detector::setElectricFieldGrid(const std::shared_ptr<std::vector<double>>&
                                    std::array<double, 3> size,
                                    FieldMapping mapping,
                                    std::array<double, 2> scales,
                                    std::array<double, 2> offset,
                                    std::pair<double, double> thickness_domain) {
    check_field_match(size, mapping, scales, thickness_domain);
    electric_field_.setGrid(field, bins, size, mapping, scales, thickness_domain);
    electric_field_.setGrid(field, bins, size, mapping, scales, offset, thickness_domain);
}

void Detector::setElectricFieldFunction(FieldFunction<ROOT::Math::XYZVector> function,
@@ -201,9 +202,10 @@ void Detector::setWeightingPotentialGrid(const std::shared_ptr<std::vector<doubl
                                         std::array<double, 3> size,
                                         FieldMapping mapping,
                                         std::array<double, 2> scales,
                                         std::array<double, 2> offset,
                                         std::pair<double, double> thickness_domain) {
    check_field_match(size, mapping, scales, thickness_domain);
    weighting_potential_.setGrid(potential, bins, size, mapping, scales, thickness_domain);
    weighting_potential_.setGrid(potential, bins, size, mapping, scales, offset, thickness_domain);
}

void Detector::setWeightingPotentialFunction(FieldFunction<double> function,
@@ -265,9 +267,10 @@ void Detector::setDopingProfileGrid(std::shared_ptr<std::vector<double>> field,
                                    std::array<double, 3> size,
                                    FieldMapping mapping,
                                    std::array<double, 2> scales,
                                    std::array<double, 2> offset,
                                    std::pair<double, double> thickness_domain) {
    check_field_match(size, mapping, scales, thickness_domain);
    doping_profile_.setGrid(std::move(field), bins, size, mapping, scales, thickness_domain);
    doping_profile_.setGrid(std::move(field), bins, size, mapping, scales, offset, thickness_domain);
}

void Detector::setDopingProfileFunction(FieldFunction<double> function, FieldType type) {
+7 −1
Original line number Diff line number Diff line
@@ -125,7 +125,8 @@ namespace allpix {
         * @param bins The dimensions of the flat electric field array
         * @param size Size of the electric field along the three dimensions of the field map
         * @param mapping Specification of the mapping of the field onto the pixel plane
         * @param scales Scaling factors for the field size, given in fractions of a pixel unit cell in x and y
         * @param scales Scaling factors for the field size, given in fractions of the field size in x and y
         * @param offset Offset of the field, given in fractions of the field size in x and y
         * @param thickness_domain Domain in local coordinates in the thickness direction where the field holds
         */
        void setElectricFieldGrid(const std::shared_ptr<std::vector<double>>& field,
@@ -133,6 +134,7 @@ namespace allpix {
                                  std::array<double, 3> size,
                                  FieldMapping mapping,
                                  std::array<double, 2> scales,
                                  std::array<double, 2> offset,
                                  std::pair<double, double> thickness_domain);
        /**
         * @brief Set the electric field in a single pixel using a function
@@ -168,6 +170,7 @@ namespace allpix {
         * @param size Size of the doping profile along the three dimensions of the field map
         * @param mapping Specification of the mapping of the field onto the pixel plane
         * @param scales Scaling factors for the field size, given in fractions of a pixel unit cell in x and y
         * @param offset Offset of the field, given in fractions of the field size in x and y
         * @param thickness_domain Domain in local coordinates in the thickness direction where the profile holds
         */
        void setDopingProfileGrid(std::shared_ptr<std::vector<double>> field,
@@ -175,6 +178,7 @@ namespace allpix {
                                  std::array<double, 3> size,
                                  FieldMapping mapping,
                                  std::array<double, 2> scales,
                                  std::array<double, 2> offset,
                                  std::pair<double, double> thickness_domain);
        /**
         * @brief Set the doping profile in a single pixel using a function
@@ -209,6 +213,7 @@ namespace allpix {
         * @param size Size of the weighting potential along the three dimensions of the field map
         * @param mapping Specification of the mapping of the field onto the pixel plane
         * @param scales Scaling factors for the field size, given in fractions of a pixel unit cell in x and y
         * @param offset Offset of the field, given in fractions of the field size in x and y
         * @param thickness_domain Domain in local coordinates in the thickness direction where the potential holds
         */
        void setWeightingPotentialGrid(const std::shared_ptr<std::vector<double>>& potential,
@@ -216,6 +221,7 @@ namespace allpix {
                                       std::array<double, 3> size,
                                       FieldMapping mapping,
                                       std::array<double, 2> scales,
                                       std::array<double, 2> offset,
                                       std::pair<double, double> thickness_domain);
        /**
         * @brief Set the weighting potential in a single pixel using a function
+4 −1
Original line number Diff line number Diff line
@@ -122,7 +122,8 @@ namespace allpix {
         * @param bins The bins of the flat field array
         * @param size Physical extent of the field
         * @param mapping Specification of the mapping of the field onto the pixel plane
         * @param scales Scaling factors for the field size, given in fractions of a pixel unit cell in x and y
         * @param scales Scaling factors for the field size, given in fractions of the field size in x and y
         * @param offset Offset of the field from the pixel center, given in fractions of the field size in x and y
         * @param thickness_domain Domain in local coordinates in the thickness direction where the field holds
         */
        void setGrid(std::shared_ptr<std::vector<double>> field,
@@ -130,6 +131,7 @@ namespace allpix {
                     std::array<double, 3> size,
                     FieldMapping mapping,
                     std::array<double, 2> scales,
                     std::array<double, 2> offset,
                     std::pair<double, double> thickness_domain);
        /**
         * @brief Set the field in the detector using a function
@@ -177,6 +179,7 @@ namespace allpix {
        std::array<size_t, 3> bins_{};
        FieldMapping mapping_{FieldMapping::FULL};
        std::array<double, 2> normalization_{{1., 1.}};
        std::array<double, 2> offset_{{0., 0.}};

        /**
         * Field definition
+7 −4
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@ namespace allpix {
        }

        // Shift the coordinates by the offset configured for the field:
        auto x = pos.x();
        auto y = pos.y();
        auto x = pos.x() + offset_[0];
        auto y = pos.y() + offset_[1];
        auto z = pos.z();

        auto pitch = model_->getPixelSize();
@@ -89,8 +89,8 @@ namespace allpix {
        }

        // Calculate the coordinates relative to the reference point:
        auto x = pos.x() - ref.x();
        auto y = pos.y() - ref.y();
        auto x = pos.x() - ref.x() + offset_[0];
        auto y = pos.y() - ref.y() + offset_[1];
        auto z = pos.z();

        T ret_val;
@@ -215,6 +215,7 @@ namespace allpix {
                                      std::array<double, 3> size,
                                      FieldMapping mapping,
                                      std::array<double, 2> scales,
                                      std::array<double, 2> offset,
                                      std::pair<double, double> thickness_domain) {
        if(model_ == nullptr) {
            throw std::invalid_argument("field not initialized with detector model parameters");
@@ -237,6 +238,8 @@ namespace allpix {
        // Calculate normalization of field from field size and scale factors:
        normalization_[0] = 1.0 / scales[0] / size[0];
        normalization_[1] = 1.0 / scales[1] / size[1];
        offset_[0] = offset[0] * size[0];
        offset_[1] = offset[1] * size[1];

        thickness_domain_ = std::move(thickness_domain);
        type_ = FieldType::GRID;