Commit 0810e987 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'weightingPotentialDepth' into 'master'

Added `potential_depth` keyword, to constrain the depth of an imported weighting potential

See merge request allpix-squared/allpix-squared!1048
parents 77ad15e3 0ce96f82
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ void Detector::check_field_match(std::array<double, 3> size,
    // Check field dimension in z versus the requested thickness domain:
    auto eff_thickness = thickness_domain.second - thickness_domain.first;
    if(std::fabs(size[2] - eff_thickness) > std::numeric_limits<double>::epsilon()) {
        LOG(WARNING) << "Thickness of field is " << Units::display(size[2], "um") << " but the depleted region is "
        LOG(WARNING) << "Thickness of field is " << Units::display(size[2], "um") << " but the requested field depth is "
                     << Units::display(eff_thickness, "um");
    }

+2 −4
Original line number Diff line number Diff line
@@ -73,10 +73,8 @@ with $`x_{1,2} = x \pm \frac{w_x}{2} \qquad y_{1,2} = y \pm \frac{w_y}{2}`$. The
  pixel cell but the corner between pixels. Only used if the *model* parameter has the value **mesh**.
- `field_scale`:  Scaling factor of the weighting potential in x- and y-direction. By default, the scaling factors are set to
  `{1, 1}` and the field is used with its physical extent stated in the field data file.
- `field_offset`: Offset of the field in x- and y-direction. With this parameter and the mapping mode `SENSOR`, the field can
  be shifted e.g. by half a pixel pitch to accommodate for fields which have been simulated starting from the pixel center.
  The shift is applied in positive direction of the respective coordinate. Only used if the *model* parameter has the value
  **mesh**.
- `potential_depth` : Thickness of the weighting potential region. The weighting potential is set to zero in the region below the
  `potential_depth`. Defaults to the full sensor thickness. Only used if the *model* parameter has the value **mesh**.
- `ignore_field_dimensions`: If set to true, a wrong dimensionality of the input field is ignored, otherwise an exception is
  thrown. Defaults to false.
- `output_plots`:  Determines if output plots should be generated. Disabled by default.
+7 −14
Original line number Diff line number Diff line
@@ -43,8 +43,13 @@ void WeightingPotentialReaderModule::initialize() {

    // Calculate thickness domain
    auto model = detector_->getModel();
    auto potential_depth = config_.get<double>("potential_depth", model->getSensorSize().z());
    if(potential_depth - model->getSensorSize().z() > std::numeric_limits<double>::epsilon()) {
        throw InvalidValueError(
            config_, "potential_depth", "Weighting potential depth can not be larger than the sensor thickness");
    }
    auto sensor_max_z = model->getSensorCenter().z() + model->getSensorSize().z() / 2.0;
    auto thickness_domain = std::make_pair(sensor_max_z - model->getSensorSize().z(), sensor_max_z);
    auto thickness_domain = std::make_pair(sensor_max_z - potential_depth, sensor_max_z);

    // Calculate the potential depending on the configuration
    if(field_model == WeightingPotential::MESH) {
@@ -69,25 +74,13 @@ void WeightingPotentialReaderModule::initialize() {
            field_scale = {{scales.x(), scales.y()}};
        }

        // Get the field offset in fractions of the field size, default is 0.0x0.0, i.e. no offset
        auto offset = config_.get<ROOT::Math::XYVector>("field_offset", {0.0, 0.0});
        if(offset.x() > 1.0 || offset.y() > 1.0) {
            throw InvalidValueError(config_,
                                    "field_offset",
                                    "shifting weighting potential by more than one pixel (offset > 1.0) is not allowed");
        }
        if(offset.x() < 0.0 || offset.y() < 0.0) {
            throw InvalidValueError(config_, "field_offset", "offsets for the weighting potential have to be positive");
        }
        LOG(DEBUG) << "Weighting potential has offset of " << offset << " fractions of the field size";

        // Set the field grid, provide scale factors as fraction of the pixel pitch for correct scaling:
        detector_->setWeightingPotentialGrid(field_data.getData(),
                                             field_data.getDimensions(),
                                             field_data.getSize(),
                                             field_mapping,
                                             field_scale,
                                             {{offset.x(), offset.y()}},
                                             {0.0, 0.0},
                                             thickness_domain);
    } else if(field_model == WeightingPotential::PAD) {
        LOG(TRACE) << "Adding weighting potential from pad in plane condenser";