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

Merge branch 'Generator_time_offset' into 'master'

GH#51: Generator time offset

See merge request allpix-squared/allpix-squared!1121
parents 7e304b2f 6d25135a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ The following authors, in alphabetical order, have developed or contributed to A
* Malinda de Silva, DESY, [ldesilva](https://gitlab.cern.ch/ldesilva)
* Mauricio Donatti, Brazilian Synchrotron Light Laboratory, [mmdonatti](https://github.com/mmdonatti)
* Katharina Dort, University of Gießen, [kdort](https://gitlab.cern.ch/kdort)
* Simon Gardner, University of Glasgow, [simonge](https://github.com/simonge)
* Neal Gauvin, Université de Genève, [ngauvin](https://gitlab.cern.ch/ngauvin)
* Yajun He, DESY, [yajun](https://gitlab.cern.ch/yajun)
* Ryan Heller, LBNL, [heller3](https://github.com/heller3)
+10 −3
Original line number Diff line number Diff line
@@ -272,7 +272,9 @@ GeneratorActionG4::GeneratorActionG4(const Configuration& config)
            single_source->SetNumberOfParticles(1);
            single_source->SetParticleDefinition(particle);
            // Set the primary track's start time in for the current event to zero:
            single_source->SetParticleTime(0.0);
            time_ = config_.get<double>("source_time", Units::get(0.0, "ns"));
            time_window_ = config_.get<double>("source_time_window", Units::get(0.0, "ns"));
            single_source->SetParticleTime(time_);
        }

        // Set energy parameters
@@ -337,8 +339,6 @@ void GeneratorActionG4::GeneratePrimaries(G4Event* event) {
            // Set global parameters of the source
            single_source->SetNumberOfParticles(1);
            single_source->SetParticleDefinition(particle);
            // Set the primary track's start time in for the current event to zero:
            single_source->SetParticleTime(0.0);

            // mark the initialization done
            initialize_ion_as_particle_ = false;
@@ -350,6 +350,13 @@ void GeneratorActionG4::GeneratePrimaries(G4Event* event) {
        }
    }

    // Set the time of the particle source within the time window
    if(time_window_ > 0) {
        auto* single_source = particle_source_->GetCurrentSource();
        double event_time = time_ + G4UniformRand() * time_window_;
        single_source->SetParticleTime(event_time);
    }

    particle_source_->GeneratePrimaryVertex(event);
}

+3 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ namespace allpix {
        std::string particle_type_;

        bool initialize_ion_as_particle_{false};

        double time_{0.0};
        double time_window_{0.0};
    };

    /**
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ This module requires an installation Geant4.
* `source_energy` : Mean kinetic energy of the generated particles.
* `source_energy_spread` : Energy spread of the source.
* `source_position` : Position of the particle source in the world geometry.
* `source_time` : Offset from 0 to start the Geant4 particles. Default 0ns.
* `source_time_window` : Range of particle start times starting from the offset (`source_time`). Individual particle start times are randomly drawn from a uniform distribution within [`source_time`, `source_time+source_time_window`]. Default 0ns (off).
* `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`.