Commit 259d48e2 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

MagneticField: Start allowing position-dependent field values

parent 347e7067
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -138,8 +138,8 @@ bool Detector::hasElectricField() const {
 * The electric field is replicated for all pixels and uses flipping at each boundary (side effects are not modeled in this
 * stage). Outside of the sensor the electric field is strictly zero by definition.
 */
ROOT::Math::XYZVector Detector::getElectricField(const ROOT::Math::XYZPoint& pos) const {
    return electric_field_.get(pos);
ROOT::Math::XYZVector Detector::getElectricField(const ROOT::Math::XYZPoint& local_pos) const {
    return electric_field_.get(local_pos);
}

/**
@@ -225,7 +225,7 @@ void Detector::setMagneticField(ROOT::Math::XYZVector b_field) {
/**
 * The magnetic field is evaluated for any sensor position.
 */
ROOT::Math::XYZVector Detector::getMagneticField() const {
ROOT::Math::XYZVector Detector::getMagneticField(const ROOT::Math::XYZPoint&) const {
    return magnetic_field_;
}

+3 −3
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ namespace allpix {
        FieldType getElectricFieldType() const;
        /**
         * @brief Get the electric field in the sensor at a local position
         * @param pos Position in the local frame
         * @param local_pos Position in the local frame
         * @return Vector of the field at the queried point
         */
        ROOT::Math::XYZVector getElectricField(const ROOT::Math::XYZPoint& local_pos) const;
@@ -240,10 +240,10 @@ namespace allpix {
        bool hasMagneticField() const;
        /**
         * @brief Get the magnetic field in the sensor at a local position
         * @param pos Position in the local frame
         * @param local_pos Position in the local frame
         * @return Vector of the field at the queried point
         */
        ROOT::Math::XYZVector getMagneticField() const;
        ROOT::Math::XYZVector getMagneticField(const ROOT::Math::XYZPoint& local_pos) const;

        /**
         * @brief Get the model of this detector
+2 −2
Original line number Diff line number Diff line
@@ -519,7 +519,6 @@ void GenericPropagationModule::initialize() {
            LOG(WARNING) << "A magnetic field is switched on, but is set to be ignored for this module.";
        } else {
            LOG(DEBUG) << "This detector sees a magnetic field.";
            magnetic_field_ = detector_->getMagneticField();
        }
    }

@@ -773,7 +772,8 @@ GenericPropagationModule::propagate(const ROOT::Math::XYZPoint& pos,
        Eigen::Vector3d efield(raw_field.x(), raw_field.y(), raw_field.z());

        Eigen::Vector3d velocity;
        Eigen::Vector3d bfield(magnetic_field_.x(), magnetic_field_.y(), magnetic_field_.z());
        auto magnetic_field = detector_->getMagneticField(static_cast<ROOT::Math::XYZPoint>(cur_pos));
        Eigen::Vector3d bfield(magnetic_field.x(), magnetic_field.y(), magnetic_field.z());

        auto doping = detector_->getDopingConcentration(static_cast<ROOT::Math::XYZPoint>(cur_pos));

+0 −1
Original line number Diff line number Diff line
@@ -125,7 +125,6 @@ namespace allpix {

        // Magnetic field
        bool has_magnetic_field_;
        ROOT::Math::XYZVector magnetic_field_;

        // Statistical information
        std::atomic<unsigned int> total_propagated_charges_{};
+3 −3
Original line number Diff line number Diff line
@@ -56,10 +56,10 @@ void MagneticFieldReaderModule::initialize() {
        for(auto& detector : detectors) {
            // TODO the magnetic field is calculated once for the center position of the detector. This could be extended to
            // a function enabling a gradient in the magnetic field inside the sensor
            detector->setMagneticField(detector->getOrientation().Inverse() *
                                       geometryManager_->getMagneticField(detector->getPosition()));
            auto position = detector->getPosition();
            detector->setMagneticField(detector->getOrientation().Inverse() * geometryManager_->getMagneticField(position));
            LOG(DEBUG) << "Magnetic field in detector " << detector->getName() << ": "
                       << Units::display(detector->getMagneticField(), {"T", "mT"});
                       << Units::display(detector->getMagneticField(detector->getLocalPosition(position)), {"T", "mT"});
        }
        LOG(INFO) << "Set constant magnetic field: " << Units::display(b_field, {"T", "mT"});
    }
Loading