Modifying volumes in a existing geometry

Hello,
Is it possible to delete or modify volumes in an existing geometry, with the new ROOT geometry classes? I would not expect deletion to be possible, but it would be nice to have, for example, the possibility of rotating volumes. I was not able to find a way of doing this from the documentation.
Further, even deleting the geometry manager and trying to rebuild it from scratch caused a crash in the interpreter. I have yet to try this in a compiled class. Surely, it should be possible to rebuild the geometry? I am using v3.10.02 on a Redhat 8.0 Linux x86 computer.

Regards,
Gora

Hi Gora,

Changing a geometry once closed is a quite useful feature - imagine you want to apply some alignment constants to a detector. Unfortunatelly at this stage the feature in not quite implemented, therefore not documented.
Indeed, you cannot remove volumes, but you can however change matrices even after closing the geometry if taking some cautions:

gGeoManager->CloseGeometry();
...
gGeoManager->cd("path/to/some/positioned/volume");
TGeoNode *current = gGeoManager->GetCurrentNode();
current->GetMatrix()->RotateZ(some_angle);
// you might change the matrix in other ways...
current->GetMotherVolume()->Voxelize();
// the last line forces the container volume of the rotated object update itself

In future things like this will be much better supported, automated and of course documented.

Regards, Andrei

Thanks for your quick response. Indeed, my problem is to align detector elements in between events.
A couple of followup questions on this:

  1. I do not see any way to change translations for a volume that is to be modified as per your suggestions. Those, or simply something like gGeoManager->GetCurrentNode()->SetMatrix(), followed, of course, by a revoxelization, would be useful.
  2. While playing around, I also noticed that it is possible to modify the shape associated with an existing volume by creating a new shape, deleting the current one, and using TGeoVolume::SetShape(), again followed by a revoxelization. While the new shape seems to be drawn correctly, are there any problems with this approach?

Regards,
Gora

Hi Gora,

That was exactly what I mant with “not yet implemented” - you should have a TGeoNode::SetMatrix() and the voxelization automatically done after this. Some way out until I will implement this feature (very early in January) you will have to define the transformations that you intend to change after CloseGeometry() keeping their pointers, e.g.

TGeoTranslation *t1 = new TGeoTranslation(x,y,z);
someVolume->AddNode(otherVolume, copy_no, t1);
...
gGeoManager->CloseGeometry();
...
t1->SetTranslation(otherX, otherY,  otherZ);
someVolume->Voxelize("");

Not so nice, but it should do the job… As long as for shapes, you should be careful only when deleting them since they are also deleted by the manager class - you should clean them also from the corresponding container; Otherwise, the same scheme works for shape in the same way as for the matrices.