I have a question regarding how Geant4 works. Say I shoot a gamma ray into a scintillator crystal in which Compton/Rayleigh scattering occurs, and then I detect the gamma ray that reaches a detector after the crystal. I made a macro in which I /run/beamOn 1000. What I find is that I see exact same angles of trajectories of gamma rays hitting the detector in different runs, while I would expect that say in one run I would detect gamma rays ariving at one set of angles, and in other run at other, because the scattering happens randomly with some probability. Moreover, if I change a scintillating property of the scintillating crystal (like Birks constant, for example), I anyway get points with exact same angle of arrival at the detector (relative to axis of initial propagation) as before changing. Is this how Geant4 works for debugging or I am doing something wrong?
This is a “feature” of Geant4. If you don’t do anything, Geant4 uses the same random seed to start every job. It’s a true feature because it allows for easy and clean regression testing.
To have unique output for every run, you need to set the starting random seed yourself. You can use the UI command /random/setSeeds and hardcoded numbers, but that’s pretty awkward for large numbers of jobs. Or you can write RunAction::BeginOfRunAction() to set the seeds using something like time() or UUID (the latter gets you uniqueness across simultaneous batch jobs).
I expected this feature to be true only for identical simulations (meaning I run exactly the same program many times, say today vs tomorrow). However, I observe this feature even if I change the physical optical property of the crystal (Birks constant), thus changing my DetectorConstruction.cc file, while not changing anything else in that file or elsewhere. Apparently, this means that this Geant4 feature is actually even stronger - it preserves the random seeds for some subset of events which weren’t affected by the change. Is that correct?
The optical properties only affect G4OpticalPhoton production. If you didn’t include optical physics in your physics list, they won’t affect the gamma rays. So if that’s your only change, then it’s effectively no change, and the random sequence will be the same.
Conversely, if you do add optical physics, then your physics lists will have additional processes, which will trigger computation of the per-track interaction lengths via random throws, which would change the random sequence.
Yes, I do. I am talking only about the scattered gamma-ray. For it I see identical results with (a) not specifying Birks constant and (b) specifying it (the only difference). I can imagine that changing the Birks constant changes only the number of scintillation photons (it does, I checked), but because of Geant4 not changing the primary gamma ray “random” tracks its properties stay the same (I mean, changing how light yield depends on the deposited energy doesn’t have anything to do with the primary gamma ray track, does it?)
Oh, wait a minute. Let me ask a question which reveals my ignorance of plastic scintillator detectors… Do gammas directly produce optical photons in the scintillator, or is that an indirect process (only secondary electrons produce subsequent photons)?
If the answer to (2) is No, the the answer to (1) explains what you’re seeing: the gamma enters does its scattering (one or multiple), then exits the target and goes off to get killed. Only then are the liberated electron(s) from the gamma scatters tracked, and those electrons will go off and create optical photons.
Also, note that using the top-level random seed, Geant4 generates an array of event-by-event random seeds, which it passes to each worker thread for a new event. That’s to support reproducibility in multithreading (the random sequence is isolated to per thread, and doesn’t depend on the job’s specific history of which event ran in each thread).
Gammas deposit energy and produce secondary electrons which then in turn produce optical photons. I am not 100% sure I understood the the mechanism you described, but the bottom line is that since scintillation is an indirect process with respect to the primary gamma photon, then what I am seeing makes sense - the primary gamma scattering is unaffected from run to run (meaning say Event 1 primary gamma trajectory from the first run is identical to Event 1 primary gamma trajectory from the second run) even if the scintillator crystal properties affecting the number of optical photons is changed, is this correct?
Yes, that’s exactly right. Thank you for confirming the behaviour, and your description above, for why the gamma scatters will be the same on each run (if you don’t seet different seeds) is accurate.
Birk’s constant relates to the ability of a scintillator to convert LET along a track into light, specifically how that conversion deviates from a pure linear relationship assumed with dL/dx = (dE/dx)/(1+CdE/dX) with C the constant. Generally speaking, at low LET values and for most materials the correction is negligible i.e. that the denominator is nearly equal to 1. But for high LET radiation such as heavy ions and near the end of all charged particle tracks, the energy deposition is so concentrated that it begins to modify the steady state assumptions of the scintillator. For organic scintillators that typically translates to breaking carbon rings. Break carbon rings means no state to optically radiate from.
None of this has anything to do with the physics of the compton interactions themselves. Compton kinematics does not actually depend on the material or its properties at all except in very high order corrections for the binding energy of the electron. The only thing you can “influence” with the material for compton interaction is the probability of that reaction in the first place, and that is related entirely to the density and effective Z of the material, not the Birk’s constant. The angles are completely independent.
Edit - If you, for example, require that the gamma ray interacts in one volume and is detected in another than you have fully constrained the kinematics. You will always measure the same compton electron, compton photon energies, and angles. The only variability comes from slightly different interaction positions in the crystal and detector.
Thanks, Justin. I did half my career on drift chambers (BaBar and a little ATLAS), and then pivoted to cryogenic crystals (CDMS). Scintillators were just “vetoes” for me