Commit 0baad526 authored by Paul Schütze's avatar Paul Schütze
Browse files

DepG4: round up maximum value for new plot

parent 87b984e5
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -425,8 +425,10 @@ void DepositionGeant4Module::construct_sensitive_detectors_and_fields(double fan
            LOG(TRACE) << "Creating output plots for detector " << sensitive_detector_action->getName();

            // Plot axis are in kilo electrons - convert from framework units!
            int maximum = static_cast<int>(Units::convert(config_.get<int>("output_plots_scale"), "ke"));
            int nbins = 5 * maximum;
            int maximum_charge = static_cast<int>(Units::convert(config_.get<int>("output_plots_scale"), "ke"));
            double maximum_energy =
                (static_cast<int>(maximum_charge / 2. * Units::convert(charge_creation_energy, "eV")) / 10) * 10 + 10;
            int nbins = 5 * maximum_charge;

            // Create histograms if needed
            {
@@ -434,8 +436,12 @@ void DepositionGeant4Module::construct_sensitive_detectors_and_fields(double fan
                std::string plot_name = "deposited_charge_" + sensitive_detector_action->getName();

                if(charge_per_event_.find(sensitive_detector_action->getName()) == charge_per_event_.end()) {
                    charge_per_event_[sensitive_detector_action->getName()] = CreateHistogram<TH1D>(
                        plot_name.c_str(), "deposited charge per event;deposited charge [ke];events", nbins, 0, maximum);
                    charge_per_event_[sensitive_detector_action->getName()] =
                        CreateHistogram<TH1D>(plot_name.c_str(),
                                              "deposited charge per event;deposited charge [ke];events",
                                              nbins,
                                              0,
                                              maximum_charge);
                }

                plot_name = "deposited_energy_" + sensitive_detector_action->getName();
@@ -446,7 +452,7 @@ void DepositionGeant4Module::construct_sensitive_detectors_and_fields(double fan
                                              "deposited energy per event;deposited energy [keV];events",
                                              nbins,
                                              0,
                                              maximum / 2. * Units::convert(charge_creation_energy, "eV"));
                                              maximum_energy);
                }
            }
        }