Can GPS generate a discrete theta distribution?

I am trying to generate particles on a plane with discrete polar angles (i.e. theta in {0,5,10,15,20,25,30}). When I use the GPS it seems the angles are being linearly interpolated between instead of the values of theta being pinned to exactly 0,5,10,etc. Here is the macro file that sets up the source. Any suggestions on how to generate a discrete user-histogram is appreciated!

/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 5 MeV

/gps/ang/type user
/gps/hist/type theta
/gps/hist/point 0 1
/gps/hist/point 0.08726646259 1
/gps/hist/point 0.17453292519 1
/gps/hist/point 0.26179938779 1
/gps/hist/point 0.34906585039 1
/gps/hist/point 0.43633231299 1
/gps/hist/point 0.52359877559 1
/gps/hist/point 0.61086523819 1
/gps/hist/type phi
/gps/hist/point 0 1

The behaviour you see is correct: /gps/hist defines a binned distribution, which is then interpolated to approximate thye assumed underlying smooth PDF. If you want to produce a set of discrete values, I think you can do that by using GPS commands to define a set of sources, each one with a different fixed theta value.

1 Like

This worked thanks! Here is the new code I used in case someone needs it in the future

#/gps/verbose 2
# 0 degree source
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta 0 deg
/gps/ang/maxtheta 0 deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

# 5 degree source
/gps/source/add 1.
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta 5 deg
/gps/ang/maxtheta 5 deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

# 10 degree source
/gps/source/add 1.
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta 10 deg
/gps/ang/maxtheta 10 deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

 # 15 degree source
/gps/source/add 1.
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta 15 deg
/gps/ang/maxtheta 15 deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

 # 20 degree source
/gps/source/add 1.
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta 20 deg
/gps/ang/maxtheta 20 deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

 # 25 degree source
/gps/source/add 1.
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta 25 deg
/gps/ang/maxtheta 25 deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

 # 30 degree source
/gps/source/add 1.
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta 30 deg
/gps/ang/maxtheta 30 deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

Glad that worked! If you want your macro file to be shorter (at the cost of multiple files), you could do something like this:

/control/loop ebeam.mac THETA 0 10 5

or

/control/foreach ebeam.mac THETA 0 10 15 25 40 60

if you don’t have/want evenly spaced steps.

The separate file ebeam.mac contains the setup for adding a single source:

/gps/add 1.
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/halfx 5 cm
/gps/pos/halfy 5 cm
/gps/pos/halfz 0 cm
/gps/pos/centre 0 0 65 mm
/gps/ene/type Mono
/gps/ene/mono 1 MeV
/gps/ang/type iso
/gps/ang/mintheta {THETA} deg
/gps/ang/maxtheta {THETA} deg
/gps/ang/minphi 0 deg
/gps/ang/maxphi 0 deg

I need to check whether GPS is happy getting an add directive when no source has been defined yet, but I would hope it behaves sensibly :-/

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.