Can someone explain how to use a histogram energy spectrum as a source input for GPS

Hi all,

I have a precise energy spectrum for a clinical LINAC and is energy-fluence as a function of energy. I cannot figure out the documentation on the use of histograms as input in the macro file gps commands. I have also seen the examples which use the /gps/hist/point command. I have tried also to create 600 bins with each energy I require using the command above and I have also tried using a .txt file as input. These tries either result in no output or create a completely wrong spectrum. Can anyone explain clearly how to make use of the hist feature in gps so that I can recreate exactly the LINAC spectrum as a gps source?

Thanks for your time!

Michael

hello dear
i send you a example for defining histogram in gps macro file.
/gps/particle e-
/gps/source/intensity 0.99715
/gps/ene/type User
/gps/hist/type energy
/gps/hist/point 0.000 0.337871
/gps/hist/point 0.003 0.338376
/gps/hist/point 0.006 0.339304
/gps/hist/point 0.009 0.340535
/gps/hist/point 0.012 0.341990
/gps/hist/point 0.015 0.343614
/gps/hist/point 0.018 0.345368
/gps/hist/point 0.021 0.347224
/gps/hist/point 0.024 0.349162
/gps/hist/point 0.027 0.351165
/gps/hist/point 0.030 0.353220
/gps/hist/point 0.033 0.355318
/gps/pos/type Volume
/gps/pos/shape Sphere
/gps/pos/centre 0. 0. 0 nm
/gps/pos/radius 5 cm
/gps/ang/type iso

if you want to use text file for defining spectrum. you should define spectrum in macro file then use this commend in the gps file /contorl/execute spectrum.mac
/gps/source/intensity 0.99715
/gps/ene/type User
/gps/hist/type energy
/contorl/execute spectrum.mac
/gps/pos/type Volume
/gps/pos/shape Sphere
/gps/pos/centre 0. 0. 0 nm
/gps/pos/radius 5 cm
/gps/ang/type iso

@asra_talebi This is a nice working example, but your answer only partially answers the question asked by @michaelmcmanus1 , because you do not explain what these commands mean and how to use them.

For example what do the numbers in /gps/hist/point actually mean?
What is the first number, what is the second number and what are the units?

What does the command /gps/source/intensity do? Why is it needed?
What does the command /gps/ene/type User do? Why is it needed?
What does the command /gps/ang/type iso do? Why is it needed?

Is there a detailed documentation about these commands?
Where can I read more about the commands?

There is some brief descriptions in the General Particle Source Section “User-defined histograms and interpolated functions” in the Book for Application Developers.

1 Like

The descriptions in the Book for Application Developers are very short and don’t fully explain what is going on there.
When I use Spenvis to generate a particle spectrum, the macro contains the command

/gps/hist/type biase

for which I cannot find any documentation.
Followed by a spectrum like this:

/gps/hist/point 0.0000000000 0.2125E-08
/gps/hist/point 0.3272324574 0.2842E-08
/gps/hist/point 0.6627276239 0.5427E-08
/gps/hist/point 0.8160055192 0.1171E-07
/gps/hist/point 0.8892346073 0.2313E-07
/gps/hist/point 0.9306980220 0.4274E-07
/gps/hist/point 0.9513004173 0.7720E-07
/gps/hist/point 0.9650578942 0.1189E-06
/gps/hist/point 0.9736044267 0.1807E-06

The Book for Application Developers says that the first number in each line is supposed to be the upper bound of the energy bin. But that clearly makes no sense. The spectrum is not only below 1 MeV.
The Book also says the second number is the weight, but I don’t understand how this weight is applied.

Ok, I think I found the paragraph in the Book for Application Developers that explains the behaviour of the bias histogram.

The user can bias distributions by entering a histogram. It is the random numbers from which the quantities are picked that are biased and so one only needs a histogram from 0 to 1.

This is what confused me.
Apparently, the energy histogram uses the upper energy bound of the energy bin as its first parameter, while the biasing histogram is based on the random number generator that selects the energy bin, which is why the biasing has bins in the range 0 to 1 as its first parameter.

But how to renormalise the results to compensate for the biasing?

Hello,
I am also trying to do this, since mine is little bit different.

  1. i am changing /Examples/Extended/persistency/gdml/G01.
    2.in this i am trying to change particle gun to GPS.
    3.But the problem is when i put primary.mac file (that is used in example/advanced/radio-protection…for the GCR spectra) it is not compiling also not giving any error.
    4.To implement this (primary.mac), i am also giving the command in the vis.mac file of G01 example and also changed some commands of particle gun to GPS in primarygenerator.cc and actioninitialization.cc and also in the header files.
  2. Though it is not giving me any error but when i compile this after that in the build directly i can see in the vis.mac file the command (/control/execute primary.mac…that is given to execute primary.mac file) becomes # /control/execute primary.mac.
  3. also in the build directly the files that i put outside the build directory it is not in the build directory.
    why it is so, why i am not able to throw the GCR spectra in this example?
    can you please help me to solve this problem. it will be very helpful.
    Thanks in advance !

Your question does not seem to be related to the orginal question of the thread.
You seem to have several problems at once.
Try asking only one isolated problem at once and open a new thread.

I don’t understand what is going on under your point 1.
For point 2 you should know that the # marks the beginning of a comment in the macro file. This means the rest of that line is ignored.
For point 3 you need to check your CMakeList file and your cmake settings.

For point 2 you should know that the # marks the beginning of a comment in the macro file. This means the rest of that line is ignored.
Thanks for your reply !
Yes, this is i know, i am just asking why automatically it is commenting even i am giving primary.mac file, can you please tell ?