Cannot change logical volume in G4VPVParameterisation

Dear Geant4 experts,
I has recently played with example B5.
In VoxelParameterisation::ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) function, I would like to change the logical volume of voxel with copyNo of 40. I used functions:
if (copyNo == 40) physVol->SetLogicalVolume(newLogicalVol);
However, I got unwanted results: All the voxels were set to the newLogicalVol. It likes all physVols point to the same logical volume address.

Can any one show me how to set different logical volumes for different voxels?
I ran the code on Geant4v11.
And other strange thing, the value of copyNo is different from the value from physVol->GetCopyNo(). What is the meaning of this different?

Thank you very much

That’s correct. The point of a parameterized volume is that there is only one actual physVol in memory. If you change the LV, you change it for all the pseudo-copies.

You don’t.

Thank you @mkelsey for your enlightenment. Is this fact also correct for ComputeMaterial() function? Ones cannot set different materials for different voxels?

I think, but I could be wrong, that the parameterisation handles materials differently, such that (behind the scenes), the copy number can point to your desired material for that voxel. I have used G4PVParameterised with position and orientation changes, and also learned that you can only use a very limited number of simple solids with it :frowning:

Thank you very much @mkelsey. Regarding to copy number, It sounds weird to me that why ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) function needs copyNo as one of arguments. Anyway, I checked that copyNo is different to physVol->GetCopyNo(). Aren’t these two values should be the same?

Because that’s the fundamental point of the parametrized placement. You write your own implementation of ComputeTransformation, and use the copy number as a parameter (index) to compute where that specific instance of the shape is supposed to be placed within the mother volume.

Only for the simple G4PVPlacement case. For the parameterised and replica placements, the particular PV instatiation is a “template”, and the copy number specifies how the “template” is modified for a particular location in the geometry. The copy number is fed “from outside.”

If the documentation on parameterised volumes isn’t clear, maybe create a Bugzilla report describing what isn’t clear and what additional information you need in the documentation?

Thank you so much @mkelsey for you quick response. You help me a lot.