Looking for better Eve examples using TGeoNode

I’m looking for some more complex examples of TGeoNode usage within an Eve application, and the ROOT tutorials don’t seem to provide very much in this area.

All I find in tutorials/eve from ROOT 6.18 is the following:

$ grep TGeoNode *
geom_alice_its.C:#include "TGeoNode.h"
geom_alice_its.C:   TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("ITSV_1");
geom_alice_its.C:TEveGeoNode* descend_extract(TGeoNode* node)
geom_default.C:   TGeoNode* node1 = gGeoManager->GetTopVolume()->FindNode("ITSV_1");
geom_default.C:   TGeoNode* node2 = gGeoManager->GetTopVolume()->FindNode("TPC_M_1");

This is not really sufficient for what I want to do…

How can I pick a set of arbitrary TGeoNode objects from the geo manager, group them into an element list, and then have Eve display them under a single element in the tree, preserving their global positions in the scene?

The psuedo-code of what I want to do would be something like the following:

TEveElementList* detector = new TEveElementList("My Detector");
TEveElementList* subdet = new TEveElementList("subdetector");
subdet->AddElement(node1); // add a TEveGeoNode
subdet->AddElement(node2); // add another TEveGeoNode

This doesn’t seem to work, as nothing shows in the viewer. I can see that the Event tree is populated properly. The GL viewer just shows all black, even after I call the redraw function on the Eve manager.

The entire geometry DOES show up okay when I use TEveGeoTopNode, but I want to select only certain volumes to include in my scene, as the geometry is from a fairly messy GDML file with some dead material that I do not want included at all.

How can I go about doing this? Do I just need to adjust some visualization settings?

I think @matevz may help you.

I’m actually just helping somebody do something similar :slight_smile: look at the test2.C in this post:


Thank you for the example.

From what I can tell, what I’m trying to do is slightly different. I don’t want to set a top node that points at the actual geometry and then filter sub-volume visibility. In other words, I do not want to make use of the TEveGeoTopNode class to point into my full geometry or parts of it.

I want to create a list of nodes that I select myself, wrap them with TEveGeoNode, and then put them in a TEveElementList, and then I want the viewer display them with their global positions and rotations. I can get these lists and their elements to show up perfectly fine in the tree view on the left, but I just can’t get them to show up in the viewer. I’ve tried toggling various visibility settings but none of them seemed to have any effect - the canvas is black/blank.

Are there some specific visibility settings I should play with in order to get this working, either in Eve or the TGeoNode objects I’m trying to use?

Or do you think setting TEveGeoTopNode to point to my world volume and then turning off the nodes I don’t want to see is a better approach?

The problems is that parts of the detector are not grouped according to how I want them in the tree view, e.g. the tracker modules don’t have an envelope volume but I’d like to put them all in a “Tracker” group within Eve.

Oh, maybe you looked at the wrong example, the last one, test2.C from me earlier today copies out GeoShapes from given geo path and sets trnsformation matrices accordingly.

You could of course also set TEveGeoTopNode to anywhere in the tgeo hierarchy … but then you are limited with what TGeoPainter can do with the state in TGeoAtt of nodes and volumes.

I did look at the test2.C example. I’m not sure what you mean by “copies out GeoShapes” but I do see there is filtering of the Eve elements which seems to happen here:


I’m going to try this approach with TEveGeoTopNode just to get something going, so I can turn off various dead material volumes, etc.

Is there a certain approach you could suggest with adding elements in the original way I had wanted, e.g. lists of arbitrary TGeoNode objects which may not actually be within the same volume in the TGeoManager? (Am I missing something like this in the example you sent?)

I had found some code in another project which essentially had a structure like:

- detector (list)
  - subdetector (list)
    - Eve shape 

But they had actually directly added TEveGeoShape objects to the lists rather than nodes from the geometry. When I do this instead with TEveGeoNode objects I don’t get the same result (geometry doesn’t show up in the viewer).

Maybe I can put some code on github as it might be easier to understand what I’m trying to accomplish here.

There’s another test2.C :slight_smile:

test2.C (4.0 KB)

See FillScene().

Oh THAT test2.C :grinning:

Thank you - this looks more like what I want to do. Let me see if I can get it working in my app and I’ll get back to you. (Appreciate the help.)

I’m still struggling with the best way to do this, as this seems heavily redundant to copy out all the information from a TGeoNode into an Eve object like you’ve done in the example, since I just want to use existing geometry nodes with all their attributes/matrices/shapes as is.

Here’s the GDML file I’m working with:

detector.gdml.txt (821.8 KB)

Sorry, it is a bit of a mess. :nauseated_face:

Let’s say I want to pick out all the volumes that start with “module_L” and put them in an Eve element (list?) called “Tracker”.

Geometry should be something like:

- world 
  - tracking volume
    -base volume
      - module_L1 
      - [etc.]

What’s the best way to do this once the geometry is loaded into TGeoManager?


Sorry, I haven’t got the notification for your previous post … but did get it for the deleted one :slight_smile:

So, do you still need me to look into something?


Hi @matevz

I have something that seems to work okay, and I’m curious to hear what you think of the solution.

eve_test.C (2.0 KB)

detector.gdml.txt (821.8 KB)

(Just move the geometry file to detector.gdml to run the script.)

I followed your advice of copying out node information from the geometry manager into Eve shapes, which seems to work well.

Maybe this makes a nice example for others trying to do something similar, as I didn’t find anything like this in the tutorials.

If you have any suggestions/tips, please let me know!

Yup, nice, thanks :slight_smile:

Do you want to make a PR to add it to tutorials/eve? I can put the gdml file to my CERN account www dir where I hold files for other EVE tutorials .

Oh, it seems TGeo has trouble loading from http, eg, “http://mtadel.home.cern.ch/mtadel/root/detector.gdml”. We could store it as root file or copy it first.


That’s an interesting idea.

Let me get back to you after checking whether this works okay with a ROOT file containing the geometry…

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