Home | News | Documentation | Download

Struggling with TGeoRCExtension


#1

Hi there,

I am using ROOT to generate geometries. I need to link some properties to the volumes. The way I chose to do this is to make the geometry nodes carry the properties.
So I am trying to add a python dict to a TGeoRCExtension and then store it in a TGeoNodeMatrix. I think i’m having some scope issue. I can access to the dict inside the method which created it, but not outside.

Here is a simple example showing my issue:

from ROOT import TGeoVolume,TGeoTube,TGeoRCExtension

def apply_property_to_node(node,prop):
    tprop=TGeoRCExtension()
    tprop.data=prop
    node.SetUserExtension(tprop)
    print 'tprop in : ', tprop
    print 'data in : ',tprop.data
    return tprop

radius=5.
height=10.
cyl_1=TGeoVolume("cyl_1",TGeoTube("cyl_1_shape",   0., radius, height/2))
cyl_2=TGeoVolume("cyl_2",TGeoTube("cyl_2_shape",   0., radius/2, height/2))
index=0
cyl_1.AddNode(cyl_2,index)

node_2=cyl_1.GetNode("cyl_2_0")

prop={"test":12}

apply_property_to_node(node_2, prop)

tprop=node_2.GetUserExtension()

print 'tprop out : ',tprop
print 'data out : ',tprop.data

Can anyone help me?

Thanks !


#2

What error message do you see?


#3

The output is :

Info in TGeoManager::TGeoManager: Geometry Geometry, default geometry created
tprop in : <ROOT.TGeoRCExtension object (“TGeoRCExtension”) at 0x1bdd410>
data in : {‘test’: 12}
tprop out : <ROOT.TGeoRCExtension object (“TGeoRCExtension”) at 0x1bdd410>
data out :
Traceback (most recent call last):
File “/home/***/test_tgeorcextension.py”, line 27, in
print 'data out : ',tprop.data
AttributeError: ‘TGeoRCExtension’ object has no attribute ‘data’