Commit 8ab1fd1b authored by Simon Gardner's avatar Simon Gardner
Browse files

Add configuration to set particle start time within uniform time window

parent 7e304b2f
Loading
Loading
Loading
Loading
+10 −4
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,12 @@ void GeneratorActionG4::GeneratePrimaries(G4Event* event) {
        }
    }

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

    particle_source_->GeneratePrimaryVertex(event);
}

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

        bool initialize_ion_as_particle_{false};

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

    /**