Change mother volume

Hi~
I imported my model into GEANT4 using GDML file. My model consists about 1000 volumes except for world volume. Then I constructed a new volume by means of hard-coded programing(i.e., G4Sphere…). I want to set all the volumes in the gdml file(except world volume) as daughter volumes of this new volume. In other words, I want to change the mother volume of those cells from world volume to this new volume. Can anyone tell me how to achieve this?
I have tried
SetMotherLogical(G4LogicalVolume pMother) in G4VPhysicalVolume.hh file
and
AddDaughter(G4VPhysicalVolume
p) in G4LogicalVolume.hh file,
but it doesn’t work.
Can anyone help me?
Thank you very much.

jcren.

hello.
To change the solid which corresponds to any logical volume you need to use the G4LogicalVolume’s SetSolid method.
Regards,
John

Thank you, John.
I found out that the SetSolid method was used to set the solid of a logical volume. However, what I want is to change the mother volume of several logical volumes. For example, there are 5 volumes in world volume. The mother volume of these 5 volumes is world volume. Then I construct a volume named X, which is also a daughter volume of world volume. What I want to do is to set those 5 volumes as daughter volumes of X volume. So what should I do?
Thank you sincerely,
jcren.

Hi jcren,

To change the mother of a ‘placement’ physical volume, you need to create a new placement volume in the new mother, and delete the old placement volume.

Regards,
John

Thank you, John.
I tried one method several days ago and I’m wondering if my method was the same as yours. First I got the logical volumes of those 5 physical volumes, and placed them in the new mother volume(i.e., volume X). Then I tried to delete those 5 old volumes in the world volume using the method:
RemoveDaughter(const G4VPhysicalVolume* p)

However, I found out that I can only delete half of those 5 volumes(for instance, volume 1 and 3 were deleted but both volume 2 and 4 were not).
Did I use wrong method? Can you give me more suggestions?
Thank you sincerely,
jcren.