# GPS bunch creation

Hello all!

I’m trying to create ellipsoid particle bunches with GPS, I’m using this macro,

/gps/particle e+
/gps/ene/mono 4 GeV
/gps/pos/type Volume
/gps/pos/shape Ellipsoid
/gps/pos/centre 530 0 -43.5 cm
/gps/pos/halfx 0.5 mm
/gps/pos/halfy 0.5 mm
/gps/pos/halfz 0.5 mm
/gps/ang/type beam2d
/gps/ang/rot1 0 0 -1
/gps/number 1000000
/gps/particle e-
/gps/ene/mono 7 GeV
/gps/pos/type Volume
/gps/pos/shape Ellipsoid
/gps/pos/centre -530 0 -43.5 cm
/gps/pos/halfx 0.5 mm
/gps/pos/halfy 0.5 mm
/gps/pos/halfz 0.5 mm
/gps/ang/type beam2d
/gps/ang/rot1 0 0 1
/gps/number 1000000
/gps/source/multiplevertex true

from what I understand, this should create an ellipsoidal volume of 0.5x0.5x0.5 mm^3 and put 1,000,000 particles in there, but once I run the simulation and run 1 event ("/run/beamOn 1") it seems like what the GPS does is choose 1 positions limited by the ellipsoidal volume and send all the particles from there instead of sending the particles from different positions inside the volume.

Can someone tell me what I’m doing wrong? Thanks in advance!

/gps/number N acts like this.

• Shoot N number of particles for each beamOn event.

If I understood correctly, I think you want to shoot 1,000,000 particle at all different position.

In that case, I would set like this.

• /gps/number 1
/run/beamOn 1000000

yes I want to do this, I want to shoot 1,000,000 particles per event, all at the same time from different positions within an ellipsoidal volume

but if I do this, this will send 1 particle per event, not a bunch.

Geant4 is really “meant” to do one interaction per event. You accumulate high statistics by running many events and collecting data in histograms or N-tuples.

If you think you’re going to see interactions between the different particles in the event, you won’t. Tracks are entirely independent of one another – they only interact with the geometry (material, fields, etc.).

Then whats the use of the /gps/number command? I thought that because of that command i was going to be able to do bunches of particles.

You can shoot as many primary particles as you want within an event. In your GeneratePrimaries() method of your UserPrimaryGeneratorAction, just make a loop.

void MyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
for(G4int i=0; i<1000000; i++)
{ gps->GeneratePrimaryVertex(anEvent); }
}

That’s it.

That would be equivalent to doing a macro with 1,000,000 sources right? once the ellipsoidal volume is defined it will generate the vertex of the source within the volume? thanks!

This is correct. One invocation to GeneratePrimaryVertex() can generate only one vertex, i.e. staring point of the primary particle. But if you invoke this method multiple times, the vertex is sampled every time. If you want this hard-coded 1000000 to be a variable and controlled by a macro file, you should create your own UI command.

Thanks a lot! this is perfect!!