Re: [Gaudi-talk] PyRoot, Reflex, STL iterators and __deref__()

From: Brett Viren <bv_at_bnl.gov>
Date: Wed, 10 Dec 2008 23:06:58 -0500


Hi Wim,

Thanks for your test code. I reproduce your results but going just a little further I fall down again:

WLavrijsen_at_lbl.gov writes:

[...snip...]

> PyCintex.loadDict( "libbrett" )
> m = PyCintex.gbl.std.map( 'short', 'DayaBay::SimHitCollection*' )()
> print m.begin().__deref__
>
>
> I do get a warning about no dictionary being available for class
> DayaBay::SimHitCollection, but that's a non-issue.

[And, adding this class to the selection.xml quells the warning.]

Now, I can get the Python wrapped pair by calling __deref__() but how do I access the first/second members of the pair? There are no such members on the Python side. I took a guess and tried treating the pair as an 2 element array with the following failure:

In [1]: import PyCintex
In [2]: PyCintex.loadDict("libbrett")
In [3]: m = PyCintex.gbl.std.map('short','DayaBay::SimHitCollection*')()
In [4]: b = m.begin()
In [5]: d = b.__deref__()
In [6]: d
Out[6]: <ROOT.pair<const short,DayaBay::SimHitCollection*> object at 0x88a38d4>
In [7]: d.<TAB>
d.__class__         d.__ge__            d.__init__          d.__new__           d.__setattr__
d.__delattr__       d.__getattribute__  d.__le__            d.__nonzero__       d.__str__
d.__dict__          d.__getitem__       d.__lt__            d.__reduce__        d.__weakref__
d.__doc__           d.__gt__            d.__module__        d.__reduce_ex__     
d.__eq__            d.__hash__          d.__ne__            d.__repr__          
In [13]: d[0]
AttributeError                            Traceback (most recent call last)

/home/bviren/work/dayabay/offline/nuwa-git/debug/ExDictionary/wim/<ipython console> in <module>()

AttributeError: 'pair<const short,DayaBay::SimHitCollection*>' object has no attribute 'first'

In [14]: d[1]


AttributeError                            Traceback (most recent call last)

/home/bviren/work/dayabay/offline/nuwa-git/debug/ExDictionary/wim/<ipython console> in <module>()

AttributeError: 'pair<const short,DayaBay::SimHitCollection*>' object has no attribute 'second'

Thanks for the help!
-Brett. Received on Thu Dec 11 2008 - 05:07:03 CET

This archive was generated by hypermail 2.2.0 : Thu Dec 11 2008 - 11:50:01 CET