Re: PyROOT: Getting boolean array (branch) out of tree

From: Christopher Jones <c_jones_at_MIT.EDU>
Date: Tue, 25 Nov 2008 10:03:45 -0500


Okay, so it's a long int in your tree, and you can only iterate over a sequence; I'm guessing your other branches contain lists, tuples, etc and that's why you can use loops. As a matter of fact, the long int is just tree.pmfDataMD. Why can't you just type:

[...all your previous code...]

  nb = tree.GetEntry( jentry )
    if nb <= 0:

        continue

   if tree.pmfDataMD >= 1:

        print tree.pmfDataMD

On Nov 25, 2008, at 9:44 AM, Dennis Petschull wrote:

> Thanks for your response,
>
> The error is the following for pmfDataMD:
>
> Traceback (most recent call last):
> File "layer_eff_rt.py", line 18, in ?
> for nEvent in tree.pmfDataMD:
> TypeError: iteration over non-sequence
>
>
> If I insert print type(tree.pmfDataMD) right after the
>
> tree = gDirectory.Get( 'correl_tree' )
> entries = tree.GetEntriesFast()
>
> statements, I get the following printed out:
> <type 'long'>
> Traceback (most recent call last):
> File "layer_eff_rt.py", line 19, in ?
> for nEvent in tree.pmfDataMD:
> TypeError: iteration over non-sequence
>
>
> Cheers,
> Dennis
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Christopher Jones [mailto:c_jones_at_MIT.EDU]
> Gesendet: Di 25.11.2008 15:16
> An: Dennis Petschull
> Cc: roottalk_at_lxbuild091.cern.ch
> Betreff: Re: [ROOT] PyROOT: Getting boolean array (branch) out of tree
>
> Hi,
>
> What does the error look like when you try this? Also, in your loop,
>
>>
>> for nEvent in tree.pmfDataMD:
>> if nEvent >= 1:
>> print nEvent
>
>
> could you find out the type of the iterable "nEvent" (with say
> type(nEvent) )? Maybe you have to do a little more to tease out the
> value you want (like indexing), depending on your error message or
> bug.
>
> Chris Jones
> c_jones_at_mit.edu
>
>
>
>
>
>

Chris Jones
c_jones_at_mit.edu Received on Tue Nov 25 2008 - 16:03:54 CET

This archive was generated by hypermail 2.2.0 : Tue Nov 25 2008 - 17:50:01 CET