How should I model a rotating objects with inserts using G4RotationMatrix

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version: 11.2.2
Operating System: Ubuntu 24.04.4 LTS
Compiler/Version: GCC 13.3.0
CMake Version: 3.28.3

Title: How should I model a rotating phantom with inserts using G4RotationMatrix?

I have a PMMA cylindrical phantom that is placed in the world. Inside the phantom I have an aluminium cylinder and an iron cylinder acting as inserts.

Currently, I simulate phantom rotation by keeping the PMMA phantom fixed and manually changing the positions of the Al and Fe cylinders. For each projection angle, I calculate their coordinates as

x = x_center + r*cos(theta);
y = y_center + r*sin(theta);

This approach produces the desired geometry, but I am wondering whether this is the recommended way to model a rotating phantom in Geant4.

I have also experimented with G4RotationMatrix, but I am confused about how rotations are defined. My phantom has already been rotated (e.g. by 90° to make its cylindrical axis vertical), so its local coordinate system is no longer aligned with the world coordinate system.

My questions are:

  1. Are the position and rotation supplied to G4PVPlacement always interpreted in the mother volume’s local coordinate system, or are rotations defined with respect to the world axes?

  2. If I want the Al and Fe cylinders to rotate around the centre of the PMMA phantom while remaining daughters of the phantom, should I update both their positions and their rotation matrices?

  3. Instead of moving the inserts manually, is it possible (and preferable) to rotate the entire PMMA phantom using a G4RotationMatrix so that all daughter volumes rotate automatically with

    construction.cc (13.2 KB)

    it?

  4. What is the recommended Geant4 approach for modelling a rotating phantom with internal inserts for projection simulations?

I would appreciate any guidance on the best practice for this type of geometry.


The short answer is that you make your inserts daughters of the larger enclosing PMMA mother volume. If the boundary of the inserts overlap with the boundary of the mother (i.e. holes for the insert) you can make the inserts “too long” then use G4SubtractionSolid to carve out a matched hole and then place the daughter inside. Rotating the mother PMMA volume will rotate the daughters with it for free. You can verify this using the UI mode.

If you define this mother rotation in BeginOfRunAction, then you can just grab the DetectorConstruction, something like:

auto det= static_cast<const DetectorConstruction*>(G4RunManager::GetRunManager()->GetUserDetectorConstruction());

Call the mother rotation function defined in your (detector)construction.cc file and then update the geometry:

G4GeometryManager::GetInstance()->GeometryHasChanged();

This will allow you to batch the runs together, just updating the angle with macro commands for different runs.

Thank you, that makes sense. My phantom has already been rotated by 90° so that its cylindrical axis is vertical. If I then want to rotate the phantom through different projection angles, should I combine the initial rotation with the projection rotation in a single G4RotationMatrix, or should I apply successive rotateX(), rotateY(), or rotateZ() calls? I’m unsure of the correct way to combine these rotations.

Thank you it is working.