Commit 2a60e4d3 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'p-wp-sensor' into 'master'

WeightingPotentialReader: Exclude SENSOR mapping

See merge request allpix-squared/allpix-squared!882
parents 7ed7c1f0 0be03d16
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ with $`x_{1,2} = x \pm \frac{w_x}{2} \qquad y_{1,2} = y \pm \frac{w_y}{2}`$. The
  `PIXEL_QUADRANT_II`, `PIXEL_QUADRANT_III`, `PIXEL_QUADRANT_IV` stating that the field only covers the respective quadrant
  of the 2D pixel plane. In addition, the `PIXEL_FULL_INVERSE` mode allows loading full-plane field maps which are not
  centered around a pixel cell but the corner between pixels. Only used if the *model* parameter has the value **mesh**.
- `field_scale`:  Scaling factor of the electric field in x- and y-direction. By default, the scaling factors are set to
- `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.
@@ -72,7 +72,10 @@ with $`x_{1,2} = x \pm \frac{w_x}{2} \qquad y_{1,2} = y \pm \frac{w_y}{2}`$. The
- `output_plots_steps` : Number of bins along the z-direction for which the weighting potential is evaluated. Defaults to
  500 bins and is only used if `output_plots` is enabled.
- `output_plots_position`: 2D Position in x and y at which the weighting potential is evaluated along the z-axis. By default,
  the potential is plotted for the position in the pixel center, i.e. (0, 0). Only used if `output_plots` is enabled.
  the potential is plotted for the position in the pixel center, i.e. (0, 0). This parameter only affects the 1D weighting
  potential histogram. Only used if `output_plots` is enabled.
- `output_plots_zcut`: Position along the sensor `z` axis at which the 2D `x`-`y` weighting potential profile is evaluated.
  Defaults to `0um`, i.e. the center plane of the sensor.

## Usage
An example to add a weighting potential form a field data file to the detector called "dut" is given below.
+13 −3
Original line number Diff line number Diff line
@@ -50,6 +50,12 @@ void WeightingPotentialReaderModule::initialize() {
    if(field_model == WeightingPotential::MESH) {
        // Read field mapping from configuration
        auto field_mapping = config_.get<FieldMapping>("field_mapping");

        // SENSOR style mapping does not work for Weighting potentials, we always need to center on an electrode:
        if(field_mapping == FieldMapping::SENSOR) {
            throw InvalidValueError(
                config_, "field_mapping", "the weighting potential needs to be centered around an electrode");
        }
        LOG(DEBUG) << "Weighting potential maps to " << magic_enum::enum_name(field_mapping);
        auto field_data = read_field();

@@ -172,7 +178,12 @@ void WeightingPotentialReaderModule::create_output_plots() {
        histogram->Fill(z, potential);
    }

    // Create 2D histogram
    auto zcut = config_.get<double>("output_plots_zcut", 0.0);
    if(!model->isWithinSensor(ROOT::Math::XYZPoint(0, 0, zcut))) {
        throw InvalidValueError(config_, "output_plots_zcut", "Position is outside the sensor");
    }

    // Create 2D histograms
    auto* histogram2Dx = new TH2F("potential_x",
                                  "#phi_{w}/V_{w} of Pixel(1,1);x (mm); z (mm); unit potential",
                                  static_cast<int>(steps),
@@ -182,7 +193,6 @@ void WeightingPotentialReaderModule::create_output_plots() {
                                  z_min,
                                  z_max);

    // Create 2D histogram
    auto* histogram2Dy = new TH2F("potential_y",
                                  "#phi_{w}/V_{w} of Pixel(1,1);y (mm); z (mm); unit potential",
                                  static_cast<int>(steps),
@@ -229,7 +239,7 @@ void WeightingPotentialReaderModule::create_output_plots() {
        for(size_t k = 0; k < steps; ++k) {
            double y =
                center.y() - size.y() / 2.0 + ((static_cast<double>(k) + 0.5) / static_cast<double>(steps)) * size.y();
            auto potential_z = detector_->getWeightingPotential(ROOT::Math::XYZPoint(x, y, 0), Pixel::Index(1, 1));
            auto potential_z = detector_->getWeightingPotential(ROOT::Math::XYZPoint(x, y, zcut), Pixel::Index(1, 1));
            histogram2Dz->Fill(x, y, potential_z);
        }
    }