I have MC simulation batches that run for hours or days, although there are warnings like the following at the very beginning when constructing the geometry:
Checking overlaps for volume Tankwall:0 (G4Tubs) ...
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
issued by : G4PVPlacement::CheckOverlaps()
Overlap with volume already placed !
Overlap is detected for volume Tankwall:0 (G4Tubs) with Detector0:100000 (G4Tubs)
overlap at local point (-86.2826,-53.5501,-57.493) by 450.487 um (max of 1 cases)
NOTE: Reached maximum fixed number -1- of overlaps reports for this volume !
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------
Why does Geant consider these exceptions as mere warnings and continue with the simulation?
I want Geant to actually throw that exception, so that I can catch it and abort the simulation, instead of wasting hours of simulation time on a non-sense geometry.
Thank you.
Would G4PVPlacement::CheckOverlaps() also generate the console output?
Is there a way to actually make Geant THROW the G4Exception? That would be easier for our setup, since the Exception would contain the detailed error message about what went wrong in the geometry.
Also your suggestion means that the overlap has to be computed twice. Once internally by Geant and once by me manually. This seems to be unnecessary overhead.
G4PVPlacement::CheckOverlaps() is the method which will be in invoked by the G4PVPlacement contructor if the overlap check is requested. You can switch off the overlap check by setting the last parameter in the G4PVPlacement constructor equal to false (btw, pSurfChk = false is the default).
The overlap check, in case if it is requested, is done at the initialisation time, when the geometry model is constructed. It is assumed that the overlap check is used for checking geometry correctness. If you are happy with the geometry, then you can switch it off.
BTW, in your case the overlap is very tiny, and very probably will not affect the result of simulation.
G4PVPlacement::CheckOverlaps() returns true if an overlap detected, false otherwise. So, instead of asking G4PVPlacement to perform the check, you can call CheckOverlaps() explicitly and stop the execution of the program in case of overlap.
Thank you for your answer. I will look into this.
However, due to our software architecture, I will probably not be able to call CheckOverlaps() explicitly, because the geometry construction and placement is abstracted away in some software component.
It would really be helpful if Geant had a global setting that makes the G4PVPlacement throw the G4Exception properly. In fact, I would like Geant to throw ALL G4Exceptions and not swallow any of them.
You can customise the behaviour of G4Exception by implementing your own exception handler derived from G4VExceptionHandler and registering it to the G4StateManager before G4RunManager is created in your application.
You just need to implement the Notify virtual method of the handler and define the behaviour you want.
There’s no explicit documentation on that and I agree it should be added…
The mechanism is anyhow simple, here you find the definition of the base class G4VExceptionHandler: