TTreaderArray indexed by unsigned int?

Dear all,

I am slowly changing my old habits from accessing my TTrees through TTree::SetBranchAddress/… to using this nice TTreeReader object introduced in recent ROOT versions.
However, some of the trees I am using nowadays contain array-type leaves indexed by an unsigned int: e.g.

unsigned int index_branch;
float value_branch[10]; // whatever...
tree->Branch( "index_branch", &index_branch, "index_branch/i" );
tree->Branch( "value_branch", value_branch, "value_branch[index_branch]/F" );

Unfortunately, it seems I cannot access them using a TTreeReaderArray (which I believe expects the index to be a signed int):

[quote]Error in TTreeReaderValueBase::CreateProxy(): The branch value_branch contains data of type unsigned int. It cannot be accessed by a TTreeReaderValue
[/quote]

I was wondering whether it was possible to somehow specify the index type, or if this feature is still to be implemented/if I need to revert to the old accessing method for this specific set of trees/if I need to reproduce all my trees using signed-int indexed branches?

Many thanks in advance!

Hi,

great to hear you are migrating your various analysis and data processing setups to TTreeReader!
As you noticed, TTreeReader imposes correctness of types read: if you store in a branch an integer, you will be forced to read it with a TTreeReaderValue templated with “int”. This is by design: we want to avoid ambiguities (and bad segfaults) when reading a tree.
For what concerns reading arrays or collections an opportunity would be also to leverage the TTreeReaderArray class (root.cern.ch/doc/v606/classTTre … Array.html).

Cheers,
D

In ROOT 5, the “variable size of the array” MUST be a 32 bit “signed integer” leaf (an “Int_t”).
Probably the same holds in ROOT 6 (I guess Philippe would need to comment on this issue).

Hi,

I do not think this (and previous) comment is related to the original post but the situation is analogous in ROOT6: the size of a variable size array is expressed by an integer.

Cheers,
Danilo

Hi,

Yes.

(But actually, silently, we accept unsigned sizes. I have an unmerged branch on my disk that’s trying to fix that for the TTreeReader. All that’s missing is a test and time…)

I have created sft.its.cern.ch/jira/browse/ROOT-8363 so we can track my progress over there!

Cheers, Axel.