Incorrect pre and post step point information for fGeomBoundary

Hi, all.

I am simulating an RPC-PET scanner, which consists of a hollow box placed in the center of the world volume (via a G4PVPlacement). Inside the hollow box, four detection heads are placed through a G4PVParameterised by means of a translation vector and rotation matrices defining 0, 90, 180, and 270 degrees rotations about the Z axes.

Each detection head consists of a solid box, inside of which another solid box is placed by means of a G4PVPlacement. In this inner box, a given number of similar detectors (defined by solid boxes), are placed through a G4PVParameterised by means of translation vectors.

Inside of each detector, two tight detection modules (defined by solid boxes), are placed through G4PVParameterised. Even modules are placed by means of translation vectors, and odd modules are placed by means of translation vectors and a 180 degree rotation matrix about the Z axis.

Inside each detection module, several layers (solid boxes) with different dimensions are placed through a G4PVParameterised by means of translation vectors.

With the exception of the world volume, all objects share the same sensitive detector.

The geometry is depicted in the attached file.
Geometry.pdf (95.5 KB)

When a particle goes from the scanner to the outer box of the detection head, or from the outer box of the detection head to the inner box of the detection head, or from the inner box of the detection head to the first layer of a detection module, the post step point is fGeomBoundary, and the pre and post step points have different IDs (replica/copy numbers) and volume names (as expected). Equally, if the first step is in the scanner, in the outer box of the detection head, or in the inner box of the detection head the volume IDs and names of the pre and post step points are correct.

However, inside the layers of the the RPCs (all layers that are inside the volume of the modules), when a particle crosses the boundary the pre and post IDs (replica/copy numbers) of the layers are different and correct, but the pre and post volume names are the same.

Any suggestion for this behavior?

Thanks in advance.

Your issue is hard to troubleshoot without any code, but I will try to provide some guidance.

If I understand correctly your track is traversing a parameterized volume when you notice that it does not return different volume names. Is that right? If so, I think this might be expected behavior, I don’t believe that different copy numbers of a parameterized volume would yield a different volume name. Though I could be mistaken about this.

Keep in mind when you’re using G4VTouchable to get information about a volume, most of its functions have a depth parameter. If this depth parameter is set incorrectly you could be pulling information about the world or mother volume, rather than the volumes you’re looking for.

If this advice doesn’t solve your issue please feel free to share some of your code and output you are concerned about so that we can troubleshoot further,


Hi, Joseph.

First of all, thank you for your prompt answer.
If you do not mind, I answer/comment your post with quotes.

Yes, that is the problem.

I am using the “ComputeTransformation” virtual function of the G4VPVParameterisation class to set the name of the G4VPhysicalVolume, according to what I want it to be for the copy number, and the volume name in fact will change according to the copy number, but gives the same volume name for the pre and post step points, despite of the copy number being different.

Yeas, I am aware of that, but in this case I am always using depth equal to zero, which, I think, it is always the depth of the innermost parameterization, in which the particle is.

Thank you Joseph. Due to the limitation of two files and two links per post for new users, in this reply I send only the file with the output using geantino for testing (RPCScanner_Output.txt (253.6 KB)). The remaining files that can be relevant are in the next replies.

Best regards,

Files with:

Detector construction: (18.8 KB)
Sensitive detector: (59.5 KB)

Files with:

Parameterization base class: (4.7 KB)
Scanner parameterization: (5.0 KB)

Files with:

Head parameterization: (4.6 KB)
Detector parameterization: (3.6 KB)

File with the module parameterization, which contains the layers: (4.1 KB)

Once again, thanks in advance.

Best regards,

Hi Miguel,

I have skimmed the code you sent and it appears to be correct (although I have not done a line by line code review).

Could you verify that the behavior is occuring when the post-step status is fGeomBoundary? In either your ProcessGammaHits or ProcessElectronHits could you try copying the following code at the bottom:

	if (postStepStatus == fGeomBoundary)
		G4cout << "Track on geometric boundary." << G4endl;
		G4cout << "Pre step volume: " << preDepthName << " Post step volume: " << postDepthName << G4endl;
		G4cout << "Pre step ID: " << preLayerID << " Post step ID: " << postLayerID << G4endl;
        G4cout << G4endl; // to give an extra line of space between outputs


Hi Joseph

Thank you. Here is the output file:
RPCScanner_Test.txt (41.6 KB)


Hi Joseph, Can I ask for your email?. There is a project I would like to discuss with you.

Hi Farnaz,

Sure, you can reach me at


Thanks, I sent you an email :slight_smile: