Geometry rotation


I want to simulate something similar to CT. I made geometry of phantom and now I want to rotate it for a certain angle after each run. I can do it manually by changing angle after each run in geometry construction. This is quite inconvenient, therefore is there some way to make it automatically with some for loop or something. Is there some example where I can find something about this kind of rotation.

Thank you for advice!

Kind regards,

Hi, I also had the same question and this is what I found.

I followed the basic example B5; in DetectorConstruction there is a function setArmAngle which moves a solid. Also there is a command armAngleCmd which executes the function setArmAngle. You need to do everything analogously. If there are multiple solids to be moved, you can put them in an array arr; declare it in DetectorConstruction and define the shapes as usual in Construct(), just write ‘arr[i] = new…’ instead of just ‘new…’. After that, you should be able to move solids by executing commands in Geant4 command line.

To perform a loop, you make a loop.mac file, analagous to what is adviced in this discussion by Kapis. You execute loop.mac file either in GUI by writing ‘/control/execute loop.mac’ or with the start of your program by ‘./my_program loop.mac’. This is my solution.

There can be an alternative solution. In the book ‘Book For Application Developers’ for Geant4 on p. 69 there is a section ‘Changing the Detector Geometry’, where a method is described, how you do it in BeginOfRunAction. I tried to change solids by firstly loading them with a method G4RunManager::GetRunManager()->GetUserDetectorConstruction(), but it returns a const and nothing can be changed for the solid. Trying to get a solid by G4PhysicalVolumeStore worked, but I still couldn’t change the solid.