Question about PhantomParameterisation class

Geant4 Version: 11.4
Operating System: win11
Compiler/Version: vs2022
CMake Version: 3.21


I tried to use the PhantomParameterisation class to construct a large number of voxels. At first the voxels didn’t fit in the container logical volume. After debugging, I found that the fContainerWall parameters didn’t set. So I got the weird results shown as the uploaded pics.

I want to ask you guys, are there proper way or nominal procedures to use the phantom class?

In my code, i used codes as follows:

fParam->SetVoxelDimensions(fDx / 2, fDy / 2, fDz / 2);
fParam->SetNoVoxels(fNx, fNy, fNz);
fParam->SetMaterials(mats);
fParam->SetSkipEqualMaterials(true);
fParam->BuildContainerSolid(contSolid); //this set the containerWall params

Looking at the geant4 example usage, your code looks fine….
I would suggest printing a few values, for example:

G4cout << "translation(0) = " << fParam->GetTranslation(0) << G4endl;
G4cout << "translation(last) = "
<< fParam->GetTranslation(fParam->GetNoVoxels()-1) << G4endl;

Put it right after BuildContainerSolid(…), and before creating the G4PVParameterised.
This will show whether the phantom is really shifted, or whether the picture is misleading.

If possible, it would also be very helpful to have a small reproducer. That would make it much easier to tell whether this is a real geant4 issue or something specific to your setup.