How to change sensitive detector function

I have a volume specified as a sensitive detector in my application, and currently it records interactions at the surface of the detector only, as far as I can tell. Instead, I want to record a hit anytime any energy is deposited within the volume of the sensitive detector. For example, right now if I generate particles inside the sensitive detector, no hits are recorded, and I’d like to change this.

How do I change my sensitive detector so it registers physical interactions within the detector, not just at the surface, and accurately registers the positions of these?


There are many sensitive detector implementations in the examples of G4. Try having a look et e.g. examples/basic/B4/B4c/src/ It all depends on what you implement in ProcessHits method (which will be invoked as long as step is taken within the volume with SD, not only at the boundary).

To complement Anna answer, let me recall again : sensitive detector and scorers are facilities provided in Geant4 to help to collect informations, but they are not mandatory.
B4a and B4b illustrate other ways to do the same thing. See B4 readme.