Rotate a physical volume around global axes

Hi, I want to do a model for a CT, so that some phys. volumes must be rotated globally around the X-axis after each run. The problem is that the volumes have an initial rotation when placed, and all further rotations occur around the local axes which do not coincide with the global axes. So, if I write:
G4RotationMatrix* rotM = physVol->GetRotation();
rotM->rotateX(30*deg);

the rotation doesn’t occur around the global X-axis in general.

You’ll just have to figure it out but I recommend using G4Transform3D and its specialties. G4PVPlacement has a constructor that takes one.

On second thoughts, not so easy. Physical volumes can be placed more than once, even with the same copy number (if its mother’s placed more than once). There is no unique solution. But if you are sure your PV is the only placement, you would have to work your way up the placement tree until you hit the work volume.

Sorry, that should read “world volume”.

I’m going to bow out here. It looks like it’s not possible to get the global transformation from the physical volume - because of the ambiguities. I know how to get it - or more than one - starting from the world volume, simply by traversing the geometry hierarchy from the world volume down, and checking the placements one by one. This is just how Geant4 works.

If anyone else has anything to add on this, please do.

Hi, thanks for the advices. I worked it out by rotating only the volumes which are placed in the world volume and not into another volumes. The daughter volumes of such in-world volumes are then rotated as well. Luckily, I also needed all of the related daughter volumes to be rotated.

There was a mistake in my question: I thought that the rotation axes of a volume change after each rotation (like with Euler angles), but instead they stay fixed, and the initial rotation doesn’t matter. What matters is that a volume can be placed inside another volume, then it is rotated with respect to this volume and not the world volume. I think you interpreted my question this way. Sadly, I cannot edit my original question to clarify it.

OK. Good. I am glad you have solved your problem.

@evsikman A simpler way to describe it: volume placements are always local to the mother volume. When a volume is placed, all of its daughters are automatically rotated along with itself.

If you need to know the full “global transform” for a placement volume, that’s what G4VTouchable is for.