Commit 065f6653 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

TransientPropagation: use getSensorIntercept method

parent 2641462c
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -342,21 +342,11 @@ TransientPropagationModule::propagate(Event* event,
            LOG(TRACE) << "Carrier outside sensor: " << Units::display(static_cast<ROOT::Math::XYZPoint>(position), {"nm"});
            state = CarrierState::HALTED;

            auto check_position = position;
            check_position.z() = last_position.z();
            // Correct for position in z by interpolation to increase precision:
            if(detector_->getModel()->isWithinSensor(static_cast<ROOT::Math::XYZPoint>(check_position))) {
                LOG(DEBUG) << "Stopping carrier " << type << " at "
                           << Units::display(static_cast<ROOT::Math::XYZPoint>(position), {"um"});

                // Carrier left sensor on top or bottom surface, interpolate
                auto z_cur_border = std::fabs(position.z() - model_->getSensorSize().z() / 2.0);
                auto z_last_border = std::fabs(model_->getSensorSize().z() / 2.0 - last_position.z());
                auto z_total = z_cur_border + z_last_border;
                position = (z_last_border / z_total) * position + (z_cur_border / z_total) * last_position;
            auto intercept = model_->getSensorIntercept(static_cast<ROOT::Math::XYZPoint>(last_position),
                                                        static_cast<ROOT::Math::XYZPoint>(position));
            position = Eigen::Vector3d(intercept.x(), intercept.y(), intercept.z());
            LOG(TRACE) << "Moved carrier to: " << Units::display(static_cast<ROOT::Math::XYZPoint>(position), {"nm"});
        }
        }

        // Find the nearest pixel - before and after the step
        auto [xpixel, ypixel] = model_->getPixelIndex(static_cast<ROOT::Math::XYZPoint>(position));