Problem 2131

Summary: Hits get registered twice
Product: Examples/Extended Reporter: vonsturm
Component: optical/LXeAssignee: Daren Sawkey <daren.sawkey>
Status: RESOLVED INVALID    
Severity: trivial    
Priority: P4    
Version: 10.0   
Hardware: All   
OS: All   

Description vonsturm 2019-02-12 10:31:06 CET
Since Geant4.10.0 optical photons trigger ProcessHits method at boundaries automatically. Watching the boundary in the RootSteppingAction and triggering this method by hand is not necessary anymore. If implemented nevertheless each hit will be written down twice. I suggest to update the example.
Comment 1 Daren Sawkey 2019-02-20 18:01:46 CET
Thanks for pointing this out.
Comment 2 Daren Sawkey 2019-08-26 22:07:03 CEST
Hi, thanks. 

How are you able to see that hits are recorded twice? I don't see any double counting occurring. 

The automatically-invoked LXePMTSD::ProcessHits(...) doesn't do anything. Counting is done by LXePMTSD::ProcessHits_constStep(...), called by Stepping action. 

The code might be more readable if LXePMTSD::ProcessHits(...) was used. I'll investigate.
Comment 3 Daren Sawkey 2020-01-30 15:18:10 CET
It seems the LXe output is correct, even with the automatic triggering of ProcessHits. This can be verified by turning of the automatic triggering with
/process/optical/boundary/setInvokeSD false
in the macro. This is because LXePMTSD::ProcessHits simply returns false. UserSteppingAction calls LXePMTSD::ProcessHits_constStep.

The next question is, why not use the automatic G4OpBoundaryProcess::InvokeSD, rather than the LXeSteppingAction? G4OpBoundaryProcess::InvokeSD is only triggered for Detection events, but LXeSteppingAction deals with other types of interaction like Absorption and Backscattering as well. [1]

However, I don't think G4OpBoundaryProcess::InvokeSD works exactly as advertised. In G4OpBoundaryProcess::PostStepDoIt, InvokeSD is only explicitly called for Detection. [2]. But G4OpBoundaryProcess::PostStepDoIt can return early, for example for case StepTooSmall [3], calling the base G4VDiscreteProcess::PostStepDoIt whcih eventually calls LXePMTSD::ProcessHits. Therefore, to use G4OpBoundaryProcess::InvokeSD, it is necessary to check in the application SD ProcessHits (e.g. LXePMTSD::ProcessHits) that the status is Detection. A better approach might be to remove the Detection check in G4OpBoundaryProcess::PostStepDoIt [2] and have the user check for boundary status in ProcessHits. This way one can handle all boundary statuses with a sensitive detector.  This should maybe be a separate bug report.

The above isn't in agreement with the README [4].

I'm going to mark this bug report as Invalid, because I have to mark it as something and none of the options really fit. 

Thanks for reporting this.


[1] https://geant4.kek.jp/lxr/source/examples/extended/optical/LXe/src/LXeSteppingAction.cc#L173

[2] https://geant4.kek.jp/lxr/source/processes/optical/src/G4OpBoundaryProcess.cc#L480

[3] https://geant4.kek.jp/lxr/source/processes/optical/src/G4OpBoundaryProcess.cc#L187

[4] https://geant4.kek.jp/lxr/source/examples/extended/optical/LXe/README#L138
Comment 4 Daren Sawkey 2020-01-30 15:31:26 CET
new bug report:

https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2222