Recalculate the cross section of process for each event

Dear experts,

Happy new year.
Recently I had a problem about the cross section of diffraction process, I write the calculation of the cross section in “computecrosssectionperatom” method, however, the cross section of the process is different as the incident angle of X-ray changes, which means the cross section need to be re-calculated for each events if the incident angle is random. I don’t know how to achieve the function because the cross section is initialized before running. Could you please give some suggestion?Thanks very much.


Happy New Year!

in Geant4 processes cross section is called for each step of a particle. How it is computed - is a responsibility of the class, it may be a const value in some cases but normally it depends on many factors and is different.


Hi Jiang, did you find any way to recalculate the cross-section for each event? I am looking for the same thing but for each step and no luck so far. I’d appreciate if you can share your thoughts.
Thank you

Hi, rezareiazi,
In my opinion, maybe you have to create a file which Inherit class “G4VDiscreteProcess” if you want to implement a Discrete Process by yourself, in your own file, the cross-section can be recalculated as you invoke the function “GetMeanFreePath()”,in this function, the information of particles for each step can be obtained and the information can be transferred to the function “ComputeCrossSectionPerAtom(XX,XX,XX,XX)”, [XX means the interested parameters].


1 Like

Thank you Jienchen,

I am exactly doing the same and in my new model, I need to re-implement the CalculateCrossSectionPerAtom unction to receive the G4Step and extract the particle momentum, energy, and material atomic number to estimate the probability of photon reflection. Unfortunately, none of the current implementations allow me to do so.

you can see the Compton Scatter process from the source file,
G4VDiscreteProcess.hh is a virtual class and some virtual functions are implemented in the G4VEmProcess.hh, the is implemented such as in the G4ComptonScattering.hh,G4KleinNishinaCompton.hh provide the cross section model,
As you want to calculate the cross section model, however, the particles information is unknown.
The logical of the simulation of interaction in my opinion, first calculate the meanfreepath() and return the maximum one of process and give the related action in the function poststepdoit(), as you invoke the function meanfreepath(), the crosssectionpervolume() and crosssectionperatom() are invoked,
At the same time, the particles information can be obtained in the function meanfreepath() and can transfer these parameters to the function crosssectionpervolume() or crosssectionperatom().
Maybe a little mess due my poor understand, but you can try to explore in this way.

1 Like

Thank you so much Jienchen, I used the PostStepGetPhysicalInteactionLength() and it worked perfectly fine for my purpose. Thank you again for the great comment!