GDML coordinate transformation


I am hoping to get some help with applying a global coordinate transformation to a gdml file.

For context, my MC and reconstruction software have differing coordinate systems. The gdml file is produced in the MC coordinate system (via G4GDMLParser), when it needs to be in the other coordinate system.

I wish to apply the transformation (x,y,z)->(-z,y,x) and preferably save the output as another gdml file.

Is there any means to do this via ROOT? Can this be done via TGeoManager? If so, is there any insight as to how to do this?

Appreciate any help,

Kind regards,

ROOT Version: 6.22
Platform: Ubuntu 20.04
Compiler: cmake 3.16.3

Hi @Chuggles ,
welcome to the ROOT forum and sorry for the late reply, @agheata might be able to help.


Hi, you can try something like:

  TGeoRotation world_rot("rot", 90, -90, -90);
  auto top = gGeoManager->GetTopVolume();
  TIter next1(top->GetNodes());
  TGeoNodeMatrix *node;
  while ((node = (TGeoNodeMatrix*)next1())) {
    auto m = new TGeoHMatrix(world_rot); 

Not sure I got the Euler angles right. Note that this will not rotate the top volume, but just the content at the first level.

1 Like

Thank you and @eguiraud very much for getting back to me.

This is exactly what I needed, thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.