Biasing an initial distribution


I am trying to generate an initial distribution in the surface of a sphere. I want the particles to be generated only from the first half of a sphere.

I am using the following commands in my macro:

/gps/particle proton
/gps/energy 10 MeV
/gps/ene/type Mono
/gps/pos/type Surface
/gps/pos/shape Sphere
/gps/pos/radius 0.000025 mm
/gps/pos/centre 0 0 0 mm
/gps/direction 0 0 1

/gps/hist/type biasz
/gps/hist/point 0. 0.
/gps/hist/point 0.5 1.
/gps/hist/point 1. 0.

But I don’t get the result I want.

If instead, I use:

/gps/pos/type Volume
/gps/pos/shape Sphere

the bias in z works but as expected I also have initial particles from the inside of the sphere and I only want them to be generated from the surface.

Thank you very much in advance!

I have not tried it, but maybe confining helps you to achieve what you need?

/gps/pos/confine <name>
Allows the user to confine the source to the physical volume name [default NULL].

I am going to try this option! Thanks!


I have tried to use the /gps/pos/confine option and it works partially. I have defined a sphere with two half spheres and attached the generation of the distribution to one of the half spheres. However, I still get about 1% of the particles generated on the second half sphere and the following warning when this happens:

-------- WWWW ------- G4Exception-START -------- WWWW -------

*** G4Exception : G4GPS001

issued by : G4SPSPosDistribution::GenerateOne()

LoopCount = 100000

Either the source distribution >> confinement

or any confining volume may not overlap with

the source distribution or any confining volumes

may not exist

If you have set confine then this will be ignored

for this event.

*** This is just a warning message. ***

I don’t understand why this is happening. Maybe someone has some clue about the origin of this warning. I can kill the tracks inside the proper class but I would like to understand the problem.

I have uploaded the initial distribution I am getting.

Thank you very much in advance!

might be that the confining half-spheres share the same surface as the sphere on which you generate the photons? I would naively guess that the problem vanishes when you confine to a G4Box that completely embedds the proper half.

Can you please tell me how you short out this problem ?
I am also facing this problem.
/gps/pos/confine this command gives me error that volume does not exist.
here what i want that i have made a sphere and generated GPS.
and in that all radiation is coming at a point inside that sphere but i want that radiation should fall only on the surface.
i am getting like this…

Can you please help me with this ?
Thanks in advance !


Did you define the shape of your beam?
Maybe you need to define in your macro file also:
/gps/pos/type Volume
/gps/pos/shape Sphere
/gps/pos/radius XXX → the radius of your sphere
/gps/pos/center 0,0,0
/gps/pos/direction 0,0,1

I hope it helps!

Thanks for your reply!
yes, i have defined all these…please
primary.txt (25.7 KB)
see in my primary.mac.
and one more thing is…here you are writing that (/gps/pos/radius XXX → the radius of your sphere) , is it the radius of sphere ?
i think it is the radius of Source (GPS).
i don’t want the radiation concentate at a point, it should incident on the surface of the sphere. i want distribution of particles like the below pictur

can you please help me with this ?