Commit 072f1973 authored by Paul Schütze's avatar Paul Schütze
Browse files

Merge branch 'g4_passive_mctracks' into 'master'

DepositionGeant4: Enable Recording of All Tracks

Closes #183

See merge request allpix-squared/allpix-squared!675
parents 308ce511 270da399
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ The MCTrack objects reflects the state of a particle's trajectory when it was cr
Moreover, it allows to retrieve the hierarchy of secondary tracks.
This can be done via the parent-child relations the MCTrack objects store, allowing retrieval of the primary track for a given track.
Combining this information with MCParticles allows the Monte-Carlo trajectory to be fully reconstructed.
In addition to these relational information, the MCTrack stores information on the initial and final point of the trajectory (in \underline{global} coordinates), the energies (total as well as kinetic only) at those points, the creation process type, name, and the volume it took place in.
In addition to these relational information, the MCTrack stores information on the initial and final point of the trajectory (in \underline{global} coordinates), the initial and final timestamps in global coordinates of the event, the energies (total as well as kinetic only) at those points, the creation process type, name, and the volume it took place in.
Furthermore, the particle's PDG id is stored.

\nlparagraph{MCParticle}
+22 −20
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ CREATE TABLE MCTrack(
    finalPositionX FLOAT NOT NULL,
    finalPositionY FLOAT NOT NULL,
    finalPositionZ FLOAT NOT NULL,
    initialTime FLOAT,
    finalTime FLOAT,
    initialKineticEnergy FLOAT NOT NULL,
    finalKineticEnergy FLOAT NOT NULL,
    PRIMARY KEY (mctrack_nr)
+9 −5
Original line number Diff line number Diff line
@@ -68,11 +68,13 @@ void DatabaseWriterModule::prepare_statements(std::shared_ptr<pqxx::connection>

    connection->prepare("add_event", "INSERT INTO Event (run_nr, eventID) VALUES ($1, $2) RETURNING event_nr;");

    connection->prepare("add_mctrack",
    connection->prepare(
        "add_mctrack",
        "INSERT INTO MCTrack (run_nr, event_nr, detector, address, parentAddress, particleID, "
        "productionProcess, productionVolume, initialPositionX, initialPositionY, initialPositionZ, "
                        "finalPositionX, finalPositionY, finalPositionZ, initialKineticEnergy, finalKineticEnergy) VALUES ("
                        "$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING mctrack_nr;");
        "finalPositionX, finalPositionY, finalPositionZ, initialTime, finalTime, initialKineticEnergy, finalKineticEnergy) "
        "VALUES ("
        "$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18) RETURNING mctrack_nr;");

    connection->prepare("add_mcparticle",
                        "INSERT INTO MCParticle (run_nr, event_nr, mctrack_nr, detector, address, parentAddress, "
@@ -269,6 +271,8 @@ void DatabaseWriterModule::run(Event* event) {
                                                                  track.getEndPoint().X(),
                                                                  track.getEndPoint().Y(),
                                                                  track.getEndPoint().Z(),
                                                                  track.getGlobalStartTime(),
                                                                  track.getGlobalEndTime(),
                                                                  track.getKineticEnergyInitial(),
                                                                  track.getKineticEnergyFinal());
                    mctrack_nr = mctrack_row.front().as<int>();
+4 −2
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ DepositionGeant4Module::DepositionGeant4Module(Configuration& config, Messenger*
    config_.setDefault<double>("max_step_length", Units::get(1.0, "um"));
    // Default value chosen to ensure proper gamma generation for Cs137 decay
    config_.setDefault<double>("cutoff_time", 2.21e+11);
    // By default, only record MCTracks connected to MCParticles in the sensitive volume
    config_.setDefault<bool>("record_all_tracks", false);

    // Create user limits for maximum step length and maximum event time in the sensor
    user_limits_ =
@@ -256,7 +258,7 @@ void DepositionGeant4Module::initialize() {
    // Construct the sensitive detectors and fields.
    if(run_manager_mt == nullptr) {
        // Create the info track manager for the main thread before creating the Sensitive detectors.
        track_info_manager_ = std::make_unique<TrackInfoManager>();
        track_info_manager_ = std::make_unique<TrackInfoManager>(config_.get<bool>("record_all_tracks"));
        construct_sensitive_detectors_and_fields(fano_factor, charge_creation_energy, cutoff_time);
    } else {
        // In MT-mode we register a builder that will be called for each thread to construct the SD when needed.
@@ -286,7 +288,7 @@ void DepositionGeant4Module::initializeThread() {
        // In MT-mode the sensitive detectors will be created with the calls to BeamOn. So we construct the
        // track manager for each calling thread here.
        if(track_info_manager_ == nullptr) {
            track_info_manager_ = std::make_unique<TrackInfoManager>();
            track_info_manager_ = std::make_unique<TrackInfoManager>(config_.get<bool>("record_all_tracks"));
        }

        run_manager_mt->InitializeForThread();
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ This module requires an installation Geant4.
* `source_type` : Shape of the source: **beam** (default), **point**, **square**, **sphere**, **macro**.
* `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.
* `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.
Loading