Hi,
I cannot seem to read an array of bools from a TTree.
I have attached some macros to illustrate the problem, but basically, if I write an object like this
class Data : public TObject
{
public:
int nBool;
bool bArray[_NBOOL_];
int iArray[_NBOOL_];
ClassDef(Data,1);
};
to a TTree and then try and read the arrays, a C macro:
[code]
Data *d = new Data();
t->SetBranchAddress(“data”,&d);
t->GetEvent(0);
for(int i=0; inBool; i++)
cout<<“iArray[”<<i<<"] = “<iArray[i]<<”\tbArray["<<i<<"] = “<bArray[i]<<”\n";[/code]
works:
iArray[6] = 6 bArray[6] = 0
iArray[7] = 7 bArray[7] = 1
iArray[8] = 8 bArray[8] = 1
iArray[9] = 9 bArray[9] = 0
etc
but a python macro:
for i in xrange(d.nBool):
print "iArray[%d] = %d\tbArray[%d] = %d" % (i,d.iArray[i],i,d.bArray[i])
doesn’t:
RuntimeWarning: creating converter for unknown type "bool*"
attr = _root.LookupRootEntity( name )
Traceback (most recent call last):
File "./readBoolArray.py", line 17, in ?
print "iArray[%d] = %d\tbArray[%d] = %d" % (i,d.iArray[i],i,d.bArray[i])
TypeError: unsubscriptable object
N.B. the array of ints reads without issue.
I can’t find any reference to this type of error in the forum already…
(using root v5r28p00fn00, python 2.4.3)
Thanks in advance
Jon
readBoolArray.py (378 Bytes)
readBoolArray.C (510 Bytes)
boolArray.C (923 Bytes)