Commit b0f4c81a authored by Paul Schütze's avatar Paul Schütze
Browse files

Merge branch 'fix_weightingfield' into 'master'

WeightingPotential: replace hard-coded reference position calculation with model method

See merge request allpix-squared/allpix-squared!544
parents a95ff829 939eda0a
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -174,15 +174,11 @@ bool Detector::hasWeightingPotential() const {
 * strictly zero by definition.
 */
double Detector::getWeightingPotential(const ROOT::Math::XYZPoint& local_pos, const Pixel::Index& reference) const {
    auto size = model_->getPixelSize();

    // WARNING This relies on the origin of the local coordinate system
    auto local_x = size.x() * reference.x();
    auto local_y = size.y() * reference.y();
    auto ref = static_cast<ROOT::Math::XYPoint>(model_->getPixelCenter(reference.x(), reference.y()));

    // Requiring to extrapolate the field along z because equilibrium means no change in weighting potential,
    // Without this, we would get large jumps close to the electrode once charge carriers cross the boundary.
    return weighting_potential_.getRelativeTo(local_pos, {local_x, local_y}, true);
    return weighting_potential_.getRelativeTo(local_pos, ref, true);
}

/**