"Scoring" particles passing through a plane

Dear all,

i’ve mostly used Geant4 integrated into other applications, so maybe I’m not really deep into the philosophy of how to do things in Geant4 and hence I thought it would be good to ask a question here before writing an implementation of something.

I want to have the functionality to define a(n infinite) plane through my entire simulation and record any particles which cross this plane. I.e. something like a scorer, but at the same time, I’d like to save particle-by-particle information in each event, and not sum up (integrate) a quantity: to be very precise, I’d like to store the particle type/energy/direction as the particle crosses the plane. I have an external framework which provides all the output quantities and such - my question is more, how do I efficiently get the information when a particle crosses the plane. Also, the plane should not interact with the simulates particles - i.e. it should be a zero-thickness “scorer”.

Initially, I started looking into the provided G4 scorers - but I think they are more to aquire integrated quantities. With SensitiveDetector I have the problem, that they seem to always have a physical volume attached - so I can’t use that to just “monitor” the MC truth information.

The idea I have right now, it to implement this as a stepping hook - check for every step, if the particle crossed the plane. However, I somewhat have the feeling, that there might be already something implemented and I’m just missing that.

Could you help me?

Cheers and thanks,

Geant4 Version: 11.2.0-3fbe2
Operating System: Centos7/EL9
Compiler/Version: gcc12
CMake Version: N/A

Hi! A possible solution that I tend to use in this scenario is setting a sensitive detector volume at the coordinates in the world volume where I want to record these values (ie. the plane you mention) but setting the material of this layer to be the same as the world volume, thus the behaviour of the particles at this point is not changed. The layer thus acts simply as a recording plane which you can set to output the desired quantities per hit using the sensitive detector functinonality

Thanks for the quick reply - however, what if my plane intersects existing (non-world) volumes? E.g. cuts through part of my detector - then this will screw up any overlap check, no? Also, then selecting a material doesn’t really work … :confused:


This is probably an ideal use case for the Parallel World functionality. Though a true plane can’t be defined (AFAIK), the parallel world could be constructed as a (very) thin slab of G4_galactic or arbitrary material. Provided the parallel geometry is set to not use layered mass geometry, it won’t affect the physics at all. The simplest examples demoing this are extended/runAndEvent/RE01,RE05, but there are several others (search for those using G4VUserParallelWorld).

It sounds like custom sensitive detectors would be needed to record what’s needed, but these and their output can be implemented using the existing mechanisms (G4VSensitiveDetector/G4VHit, G4MultiFunctionalDetector/G4PVPrimitiveScorer etc). It’s mostly just a case of attaching these to the parallel volume rather than the “mass” volume(s) together with making Geant4 aware of the parallel world.