Commit 48e9a210 authored by Håkan Wennlöf's avatar Håkan Wennlöf
Browse files

Added `max_charge_groups` functionality to [ProjectionPropagation] as well.

parent dff7d829
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ ProjectionPropagationModule::ProjectionPropagationModule(Configuration& config,

    // Set default value for config variables
    config_.setDefault<int>("charge_per_step", 10);
    config_.setDefault<unsigned int>("max_charge_groups", 10000);
    config_.setDefault<double>("integration_time", Units::get(25, "ns"));
    config_.setDefault<bool>("output_plots", false);
    config_.setDefault<bool>("diffuse_deposit", false);
@@ -50,6 +51,7 @@ ProjectionPropagationModule::ProjectionPropagationModule(Configuration& config,
    output_plots_ = config_.get<bool>("output_plots");
    diffuse_deposit_ = config_.get<bool>("diffuse_deposit");
    charge_per_step_ = config_.get<unsigned int>("charge_per_step");
    max_charge_groups_ = config_.get<unsigned int>("max_charge_groups");

    // Set default for charge carrier propagation:
    config_.setDefault<bool>("propagate_holes", false);
@@ -134,6 +136,12 @@ void ProjectionPropagationModule::initialize() {
                                  0,
                                  1);

        group_size_histo_ = CreateHistogram<TH1D>("group_size_histo",
                                                  "Charge carrier group size;group size;number of groups transported",
                                                  static_cast<int>(100 * charge_per_step_),
                                                  0,
                                                  static_cast<int>(100 * charge_per_step_));

        if(diffuse_deposit_) {
            diffusion_time_histo_ =
                CreateHistogram<TH1D>("diffusion_time_histo",
@@ -167,6 +175,8 @@ void ProjectionPropagationModule::run(Event* event) {
            continue;
        }

        total_deposits_++;

        LOG(DEBUG) << "Set of " << deposit.getCharge() << " charge carriers (" << type << ") on "
                   << Units::display(initial_position, {"mm", "um"});

@@ -176,6 +186,13 @@ void ProjectionPropagationModule::run(Event* event) {
        total_charge += charges_remaining;

        auto charge_per_step = charge_per_step_;
        if(max_charge_groups_ > 0 && deposit.getCharge() / charge_per_step > max_charge_groups_) {
            charge_per_step = static_cast<unsigned int>(ceil(static_cast<double>(deposit.getCharge()) / max_charge_groups_));
            deposits_exceeding_max_groups_++;
            LOG(INFO) << "Deposited charge: " << deposit.getCharge()
                      << ", which exceeds the maximum number of charge groups allowed. Increasing charge_per_step to "
                      << charge_per_step << " for this deposit.";
        }
        while(charges_remaining > 0) {
            if(charge_per_step > charges_remaining) {
                charge_per_step = charges_remaining;
@@ -325,6 +342,7 @@ void ProjectionPropagationModule::run(Event* event) {
            if(output_plots_) {
                initial_position_histo_->Fill(static_cast<double>(Units::convert(initial_position.z(), "um")),
                                              charge_per_step);
                group_size_histo_->Fill(charge_per_step);
            }

            auto global_position = detector_->getGlobalPosition(local_position);
@@ -368,13 +386,18 @@ void ProjectionPropagationModule::run(Event* event) {

void ProjectionPropagationModule::finalize() {
    if(output_plots_) {
        group_size_histo_->Get()->GetXaxis()->SetRange(1, group_size_histo_->Get()->GetNbinsX() + 1);

        // Write output plots
        drift_time_histo_->Write();
        propagation_time_histo_->Write();
        initial_position_histo_->Write();
        recombine_histo_->Write();
        group_size_histo_->Write();
        if(diffuse_deposit_) {
            diffusion_time_histo_->Write();
        }
    }
    LOG(INFO) << deposits_exceeding_max_groups_ * 100.0 / total_deposits_ << "% of deposits have charge exceeding the "
              << max_charge_groups_ << " charge groups allowed, with a charge_per_step value of " << charge_per_step_ << ".";
}
+4 −1
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ namespace allpix {
        double integration_time_{};
        bool diffuse_deposit_;
        unsigned int charge_per_step_{};
        unsigned int max_charge_groups_{};

        // Carrier type to be propagated
        CarrierType propagate_type_;
@@ -93,11 +94,13 @@ namespace allpix {
        // Precalculated value for Boltzmann constant:
        double boltzmann_kT_;

        // Output plot for drift time
        // Statistical information
        std::atomic<unsigned int> total_deposits_{}, deposits_exceeding_max_groups_{};
        Histogram<TH1D> drift_time_histo_;
        Histogram<TH1D> diffusion_time_histo_;
        Histogram<TH1D> propagation_time_histo_;
        Histogram<TH1D> initial_position_histo_;
        Histogram<TH1D> recombine_histo_;
        Histogram<TH1D> group_size_histo_;
    };
} // namespace allpix
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ Lorentz drift in a magnetic field is not supported. Hence, in order to use this
* `temperature`: Temperature in the sensitive device, used to estimate the diffusion constant and therefore the width of the diffusion distribution.
* `recombination_model`: Charge carrier lifetime model to be used for the propagation. Defaults to `none`, a list of available models can be found in the documentation. This feature requires a doping concentration to be present for the detector.
* `charge_per_step`: Maximum number of electrons placed for which the randomized diffusion is calculated together, i.e. they are placed at the same position. Defaults to 10.
* `max_charge_groups`: Maximum number of charge groups to propagate from a single deposit point. Temporarily increases the value of `charge_per_step` to reduce the number of propagated groups if the deposit is larger than the value `max_charge_groups`*`charge_per_step`, thus reducing the negative performance impact of unexpectedly large deposits. The default value is 10 000 charge groups. If it is set to 0, there is no upper limit on the number of charge groups propagated.
* `propagate_holes`: If set to `true`, holes are propagated instead of electrons. Defaults to `false`. Only one carrier type can be selected since all charges are propagated towards the implants.
* `ignore_magnetic_field`: Enables the usage of this module with a magnetic field present, resulting in an unphysical propagation w/o Lorentz drift. Defaults to false.
* `integration_time` : Time within which charge carriers are propagated. If the total drift time exceeds, the respective carriers are ignored and do not contribute to the signal. Defaults to the LHC bunch crossing time of 25ns.