For X = 1,10,100,1000 it works fine, about 600 photons produced / event. However, at X = 10000 the simulation starts fine, runs for a while and then “stops” doesnt crash, doesnt error, the events simply stop and the program hangs. A little investigation shows this occurs when the no. of photons ~= 1,000,000 Im wondering is there some sort of max track ID baked into G4?
sorry if this is dumb question, my experience with G4 is somewhat less than expert
Hi, to me it is totally unclear. What does “the program hangs” mean? i.e., what happens to system memory and CPU? Does the memory fill up, which can certainly happen with optical photons (do you mean optical photons or gammas?). Does the CPU keep working? Maybe there is an infinite loop, which you might be able to find in debug mode. Or, start with different random number seeds, and see if it always hangs around N=1,000,000. This would differentiate between an occasional strange occurrence, and something dependent on size of something.
Yeah I’ve done further investigation since the last post. Its definitely an infinite loop in the stepping manager (G4SteppingManager::Stepping() specifically). I’ve linked to different versions of G4 (10.7.2 and 10.7.4) and it hangs at a different number of events/tracks in each. The memory is not filling up, nor is it maxing out the CPU. I’m currently trying to determine what the difference is between the event where it hangs and the event before, to see if there is something obviously. Also, for reference these are Cherenkov photons so they’re optical not gamma.
If they’re Cherenkov photons does the volume they’re contained in have any absorption? If the walls are perfectly reflecting, and there’s nothing to kill them, those photons will bounce around forever (I’ve done this by mistake myself).
Its possible, though unlikely. The simulation is of a Rich detector and yes the volume is absorbative, I suppose theres a slight possibility that a photon could have the necessary momentum to perfectly reflect between two points infinitely. The infinite loop occurs on event 1544 by which point ~10^6 photons have been emitted (sidenote: built with G4 10.7.4 the infinite loop occurs on event 1961).
Im currently trying to get stepping/tracking information specifically on event 1544 so I can see if one track is just bouncing infinitely
Update I located the issue, it occurs when an OpticalPhoton is emitted (by a secondary electron) inside a quartz window (part of the geometry) and for whatever reason our simulation doesnt know what should happen when the photon reaches the quartz-air interface so instead reflects it with 100% probability