Issue detecting optical photons in 10.7 or higher


Has anyone successfully detected an optical photon in 10.7 or higher?

I define a G4LogicalSkinSurface that I attach to a logical volume, which is also designated as a sensitive detector. I correctly define the efficiency (100%) and reflectivity (0%) settings. My code works just fine in 10.6.2.

But after upgrading to 10.7, I’ve not been able to tally a “detection” event for an optical photon. Through the GUI I can see optical photons being absorbed by the sensitive detector, and yet no hits are collected. Even stranger, if I increase the reflectivity from 0% to something like 50%, all of a sudden the sensitive detector will register reflections as hits. It seems like “detection” events where a photon is absorbed go unnoticed. The patch for 10.7 does not fix the issue, but I find it interesting that the patch does fix an issue with GDML material property definitions.

I ran the optical/WLS example in the 10.7 directory and at the end of its runtime it recorded zero optical photon detections, even though an efficiency value is clearly specified in its detector construction.

Any ideas? Maybe there’s a new way to define an optical photon detection surface that I’m not aware of? But like I said, the code works in 10.6.2.


There shouldn’t be any difference in optical photon detection in 10.7. You can see detection using OpNovice2 example and macro boundary.mac.

You mention GDML–do you use a GDML volume? Can you replicate the problem without GDML?

As for wls example: I don’t know how many photons are detected in 10.6. The printout was added for 10.7.

Did you make any progress on this?

The folklore in my neck of the woods suggests that this might be related to 10.7 reverting to behaviour which disappeared sometime after 10.3. The folkloric workaround that was used in the past, and appears to be necessary once again in 10.7, is to place the sensitive detector on an infinitesimally thin volume (with identical refractive index to the surrounding material) just in front of the skin surface.

This seems absurd, so I really hope that it’s a folkloric superstition that can be eliminated by finding the documentation that shows the correct way of solving this problem.

Can anyone shed any light … into my sensitive detector?

1 Like

There hasn’t been an intentional change in functionality in 10.7. (nor in 10.3). The behavior you are describing sounds incorrect, so I will investigate.

Hmmm… Could you please provide more information on your setup? I’m not sure how SDs work with optical photons.

Detection works with 10.7 in the extended LXe example. However, the examples don’t call SD->ProcessHits(). Instead, the user stepping action calls a separate function to process the hits.

Do you use the invokeSD macro command?

Any advance with this problem ? I recently changed to 10.7 and am facing exactly the same as posted by @charles.s.sosa. In method ProcessHits of the SD we test the BoundaryStatus (in the line of an Example I found several years ago, don’t remember which) :

if (posStepPoint->GetStepStatus() == fGeomBoundary) {
// G4cout << boundary->GetProcessName() << " " << boundaryStatus << G4endl;
case Absorption:
case Detection:
status = ProcessHit(aStep,theTouchable,0);

This worked nicely with 10.6.1, but with 10.7 just get “StepTooSmall” statuses.
Could this have something to do with the following Release note for 10.7 :
" G4OpBoundaryProcess: increase geometry tolerance to kCarTolerance." ?

1 Like

It might very well be. Good sleuthing. I’ll investigate. Meanwhile, if you want to try yourself, you could change this line:
if(aTrack.GetStepLength() <= kCarTolerance / 2.)

I don’t know what is correct. The line was changed for 10.7 because in the LXe example there are occasionally cases where kCarTolerance/2 < stepLength < kCarTolerance and the status should be StepTooSmall.

If you like, please open a bug report.

Thank’s for the quick feedback. I’ll test as you suggest and if the the behaviour is indeed reverted I can post a bug report, if you think it is the best approach.

Hi again,
Finally I was able to test as you suggested, using version 10.7.p02. Unfortunately, changing the condition in G4OpBoundaryProcess to if(aTrack.GetStepLength() <= kCarTolerance / 2.)
didn’t change the behaviour…
However, looking a bit to the code of G4OpBoundaryProcess, I found the method InvokeSD, which is called when the status is Detection :

if(theStatus == Detection && fInvokeSD)

InvokeSD calls the method Hit of G4VSensitiveDetector.
Activating the flag fInvokeSD with
/process/optical/boundary/setInvokeSD true

worked ! So, I think this is the proper way to deal with opticalphoton detections. Am I wrong ?
Could someone confirm that this is indeed the case ?

Bernardo Tomé

I believe you are correct.

Just now, I’ve rehabilitated the wls example, and both invokeSD and UserSteppingAction detect the correct number of opticalphotons.

Looking back at your post, the issue may be calling the SD ProcessHits:

In the wls example (in 10.7) there is a separate ProcessHits_boundary defined.

1 Like

Thanks ! But the way I was doing it worked fine before 10.7 … I reckon that maybe it is more robust to activate invokeSD… I’ll have a look at the wls example anyway.

Ok. I think I understood the change in behaviour regarding optical photon detection in version 10.7.
In previous versions the boolean fInvokeSD was true by default (10.05.01/source/processes/optical/src/
In 10.7 it is defined in and its value is false by default :
boundaryInvokeSD = false;

So, even in previous versions it was required that fInvokeSD was set to true.


I actually had a quick question for you. How did you define the efficiency of the sensitive detector to be 100% ? I am struggling to detect optical photons on my detector. They get absorbed but not detected and I am not sure of how to do it. Any help is appreciated!

Hi, Sorry I was wondering if you figured out what happened here. I’m having a similar issue with my code. I have a plastic scintillator with fiber embedded being readout to a SiPM which is G4OpticalSurface of dielectric-metal with 0 reflectivity and I believe 100% efficiency. I can see that photons die in the SiPM and are counted as absorbed but they are still not being detected. The simulation is based on this example: examples/extended/optical/wls/src/ · d0f911957d8e02c06c12056c7174e65bef10b84b · geant4 / geant4 · GitLab

any feedback/advice is welcomed!

Do you have invokeSD set to true?