Implementing custom energy spectra

Hello all,

I am working on a simulation investigating hybrid pixel detectors in an electron microscope. I want to implement a custom energy spectra into my AllPix simulations to recreate the distribution seen in an SEM, however I am running into some issues.

This is how I have gone about tackling the issue:

  • First I generate a normalised histogram of electron energies and associated probabilities as a .txt file.

  • I then call this in a Geant4 macro file as such:
    /gps/particle e-
    /gps/pos/type Beam
    /gps/pos/radius 1 mm
    /gps/direction 0 0 1
    /gps/ene/type Arb
    /gps/hist/type arb
    /gps/hist/file/ electron_hist.txt

  • I then call this macro as my source file in my configuration file.

There seems to be some issues with this though and I haven’t been able to work out how to fix them. Running the simulation results in the following error:

|16:04:12.634| (STATUS) Starting event loop
|16:04:12.873| (FATAL) Error during execution of run:
Caught Geant4 exception Event0302: Error: IntType unknown type
Please check your configuration and modules. Cannot continue.

I have also tried implementing a histogram directly within the macro:
/gps/particle e-
/gps/pos/type Plane
/gps/pos/shape Circle
/gps/pos/radius 1.1 mm
/gps/ene/type Lin
/gps/ene/min 0.01 MeV
/gps/ene/max 0.02 MeV

In this case the simulation does run, however I get the following warning:

(WARNING) [F:DepositionGeant4] No charges deposited

And when I inspect the output and check the initial kinetic energy histogram there is nothing there.

I have tried this on both a local build of allpix and on lxplus and I get the same errors on both. If anyone has any idea how to fix this, or how to implement custom energy spectra in a different way it would be greatly appreciated.

Hi @rory_mcfeely ,

Sounds like a very interesting application!

I don’t have experience in doing it this way (I have done similar things with the GPS, but then using an energy histogram and a point source to emulate a Sr-90 source, more similar to your second example in the end I suppose), but it seems that IntType has nothing to do with integers as I first assumed, but rather interpolation. So i think that what is missing is a definition of the interpolation method to use for the histogram. I found this in the Geant4 user’s guide, p.33, which deals with the “general particle source”;
The command /gps/hist/inter type needs to be placed directly after the histogram for point-wise spectra as I understand it, and the possible types are Lin linear, Log logarithmic, Exp exponential, Spline cubic spline.

So i would suggest trying to include this and see if it works better! Otherwise feel free to post your full configuration, and we can try to work this out!

For your second case, it might be that no particles hit your sensor. You can enable record_all_tracks in [DepositionGeant4] and see if this changes things. by default, tracks are only generated when there is an interaction with sensor material, so if the particles miss the sensor for some reason the histograms will be empty.
With energies this low, also make sure that the world material is not air (can be set in [GeometryBuilderGeant4] with the world_material = "vacuum" keyword) and that there is nothing in front of the sensor in the simulations.

Kind regards,
HĂĄkan

Hi @hwennlof ,

I completely forgot to reply to this, but I did find a solution that worked for me. I haven’t tried yet defining the interpolation type in my macro file but I will try this at some point. The way I am currently doing it (which probably isn’t the most convenient) is to define my spectrum in the macro file with each point individually like so:

/gps/particle e-
/gps/pos/type Beam
/gps/pos/radius 1 mm
/gps/direction 0 0 1
/gps/ene/type User
/gps/hist/type energy
/gps/hist/point 0.000040 1.648219e-02
/gps/hist/point 0.000120 2.897113e-02
/gps/hist/point 0.000200 1.616059e-02
/gps/hist/point 0.000280 7.343285e-03
/gps/hist/point 0.000360 4.529252e-03
/gps/hist/point 0.000440 4.904456e-03
/gps/hist/point 0.000520 3.939646e-03
/gps/hist/point 0.000600 3.832445e-03
/gps/hist/point 0.000680 3.484040e-03
/gps/hist/point 0.000760 3.028435e-03
/gps/hist/point 0.000840 2.680032e-03
/gps/hist/point 0.000920 2.787233e-03
/gps/hist/point 0.001000 2.278026e-03
/gps/hist/point 0.001080 2.278026e-03
/gps/hist/point 0.001160 2.063624e-03
/gps/hist/point 0.001240 1.715220e-03
/gps/hist/point 0.001320 1.795621e-03
/gps/hist/point 0.001400 1.688420e-03
/gps/hist/point 0.001480 1.393616e-03
/gps/hist/point 0.001560 1.259615e-03
/gps/hist/point 0.001640 1.554418e-03
/gps/hist/point 0.001720 1.554418e-03
/gps/hist/point 0.001800 1.232814e-03
/gps/hist/point 0.001880 1.232814e-03
/gps/hist/point 0.001960 1.018412e-03
…

I will post an update if I can get it to work with the histogram in a seperate file.

1 Like