Defining Gaussian distribution for time at the Source

Greetings all,

I am trying to simulate a realistic beam coming from GPS hitting a target. I managed to get the Gaussian distribution for the incoming beam : positions (beam size) and energy. I need to do the same for the time to get at the end the bunch length.

Appreciate the help.

Regards,
Fahad

1 Like

You could probably do

G4double time;
time = G4RandGauss::shoot(0.,1.);
ParticleGun->SetParticleTime(time*ns);

in

PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)

right before
G4GeneralParticleSource()->GeneratePrimaryVertex(anEvent);
is called to get a gaussian time distribution centered around 0.ns with a sigma of 1ns. This should take all the specifications done with GPS and add the time smearing to the event.

You also probably need to include the line
#include "Randomize.hh"
at the beginning of your PrimaryGeneratorAction.cc-file.