Commit 253895b8 authored by Håkan Wennlöf's avatar Håkan Wennlöf
Browse files

Merge branch 'b/trackingverbose' into 'v2.3-stable'

[v2.3-stable] DepositionGeant4: Allow Selection of Geant4 Tracking Verbosity

See merge request allpix-squared/allpix-squared!830
parents 76f66262 a7e955df
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -15,10 +15,12 @@
#include <utility>

#include <G4EmParameters.hh>
#include <G4HadronicParameters.hh>
#include <G4HadronicProcessStore.hh>
#include <G4LogicalVolume.hh>
#include <G4NuclearLevelData.hh>
#include <G4PhysListFactory.hh>
#include <G4ProcessTable.hh>
#include <G4RadioactiveDecayPhysics.hh>
#include <G4StepLimiterPhysics.hh>
#include <G4UImanager.hh>
@@ -125,9 +127,6 @@ void DepositionGeant4Module::initialize() {
        throw ModuleError("Cannot deposit charges using Geant4 without a Geant4 geometry builder");
    }

    // Get UI manager for sending commands
    G4UImanager* ui_g4 = G4UImanager::GetUIpointer();

    // Apply optional PAI model
    if(config_.get<bool>("enable_pai", false)) {
        LOG(TRACE) << "Enabling PAI model on all detectors";
@@ -214,7 +213,7 @@ void DepositionGeant4Module::initialize() {
        LOG(INFO) << "Setting G4 production cut to " << Units::display(production_cut, {"mm", "um"})
                  << ", derived from properties of detector \"" << min_detector << "\"";
    }
    ui_g4->ApplyCommand("/run/setCut " + std::to_string(production_cut));
    physicsList->SetDefaultCutValue(production_cut);

    // Set user limits on world volume:
    auto world_log_volume = geo_manager_->getExternalObject<G4LogicalVolume>("", "world_log");
@@ -230,11 +229,11 @@ void DepositionGeant4Module::initialize() {
    run_manager_g4_->InitializePhysics();

    // Disable verbose messages from processes
    ui_g4->ApplyCommand("/process/verbose 0");
    ui_g4->ApplyCommand("/process/eLoss/verbose 0");
    physicsList->SetVerboseLevel(0);
    G4ProcessTable::GetProcessTable()->SetVerboseLevel(0);
    G4EmParameters::Instance()->SetVerbose(0);
    G4HadronicProcessStore::Instance()->SetVerbose(0);
    physicsList->SetVerboseLevel(0);
    G4HadronicParameters::Instance()->SetVerboseLevel(0);
    G4NuclearLevelData::GetInstance()->GetParameters()->SetVerbose(0);

    // Initialize the full run manager to ensure correct state flags
@@ -282,6 +281,10 @@ void DepositionGeant4Module::initializeThread() {

        run_manager_mt->InitializeForThread();
    }

    // Set selected tracking verbosity, defaulting to zero. Higher levels can be useful for tracing individual Geant4 events
    G4RunManagerKernel::GetRunManagerKernel()->GetTrackingManager()->SetVerboseLevel(
        config_.get<int>("geant4_tracking_verbosity", 0));
}

void DepositionGeant4Module::run(Event* event) {
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ This module requires an installation Geant4.
* `cutoff_time` : Maximum lifetime of particles to be propagated in the simulation. This setting is passed to Geant4 as user limit and assigned to all sensitive volumes. Particles and decay products are only propagated and decayed up the this time limit and all remaining kinetic energy is deposited in the sensor it reached the time limit in. Defaults to 221s (to ensure proper gamma creation for the Cs137 decay).
Note: Neutrons have a lifetime of 882 seconds and will not be propagated in the simulation with the default `cutoff_time`.
* `record_all_tracks` : Switch to enable the recording of all Geant4 tracks in the event. By default, this parameter is set to `false` and MCTrack objects are only generated for particles interacting with sensor material, not those that never interact with any detector.
* `geant4_tracking_verbosity ` : Verbosity level for Geant4 tracking, defaults to `0`. Higher levels mean more output. It should be noted that the respective log output is redirected to the logging level set via the `log_level_g4cout` parameter in the *GeometryBuilderGeant4* module.
* `number_of_particles` : Number of particles to generate in a single event. Defaults to one particle.
* `output_plots` : Enables output histograms to be be generated from the data in every step (slows down simulation considerably). Disabled by default.
* `output_plots_scale` : Set the x-axis scale of the output plot, defaults to 100ke.
+33 −0
Original line number Diff line number Diff line
# SPDX-FileCopyrightText: 2022 CERN and the Allpix Squared authors
# SPDX-License-Identifier: MIT

#DESC executes the charge carrier deposition module with high tracking verbosity level. The individual tracking steps are observed as output.
[Allpix]
detectors_file = "detector.conf"
number_of_events = 1
random_seed = 0
#multithreading = false

[GeometryBuilderGeant4]
log_level_g4cout = INFO

[DepositionGeant4]
log_level = INFO
geant4_tracking_verbosity = 1

particle_type = "e+"
source_energy = 5MeV
source_position = 0um 0um -500um
beam_size = 0
beam_direction = 0 0 1

[ElectricFieldReader]
model = "linear"
bias_voltage = 100V
depletion_voltage = 150V

[ProjectionPropagation]
temperature = 293K
propagate_holes = true

#PASS (INFO) (Event 1) [Geant4]   942   -0.383   -0.218    0.842      4.64 8.25e-05   0.0985      1.48  OutOfWorld Transportation