Home | News | Documentation | Download

Double arrays in TTreeReaderArray

tree

#1

Hi rooters,

The problem is - one of my ttree branches has the variable which was define like

Float_t TrackPara[m][n];  //m and n are fixed

And when I try to process it via TTreeReaderArray like this

TTreeReaderArray<Float_t*> fTrackPara = {fReader, "TrackPara"};

it doesn’t work and returns

Error in <TTreeReaderValueBase::GetBranchDataType()>: Must use TTreeReaderArray to read branch TrackPara: it contains an array or a collection.
Error in <TTreeReaderArrayBase::CreateProxy()>: The template argument type T of T accessing branch TrackPara (which contains data of type (null)) is not known to ROOT. You will need to create a dictionary for it.

How can I process such branch?

upd.
I guess, that one of solution is just rewrite my ttree and save this branch like RVec, but just for interest - could I avoid it?

Thanks!

Boris


#2

Solution could be:

root [] int a[2][5] = {{1,2,3,4,5}, {6,7,8,9,10}};
root [] a[0][3]
(int) 4
root [] int* c = &a[0][0];
root [] c[3]
(int) 4
root [] a[1][4]
(int) 10
root [] c[1*5+4]
(int) 10
root [12] 

Obviously so that get the element nxm I should just use index (n*max_n)+m

upd.

No that’s not true. Unfortunately I’ve got such problem:

root [0] TFile fin("result.root");
root [1] TTree* tr = nullptr;
root [2] fin.GetObject("events",tr);
root [3] Float_t TrackPara[177][17]{};
root [4] tr->SetBranchAddress("TrackPara", TrackPara);
root [5] tr->GetEvent(0)
(int) 12184
root [6] TrackPara[0][11]
(float) 0.272732f
root [7] TrackPara[1][11]
(float) -0.507968f

but if I will do the next:

root [0] TFile fin("result.root");
root [1] TTree* tr = nullptr;
root [2] fin.GetObject("events", tr);
root [3] auto mtr = new TTreeReader(tr);
root [4] auto tp = new TTreeReaderArray<Float_t>(*mtr, "TrackPara");
root [5] mtr->Next()
root [6] tp[0][11]
(float) 0.272732f
root [7] tp[1][11]
 *** Break *** segmentation violation

As you can see, TTreeReaderArray read only first row of my double array.

How can I fix it?

upd2

How I can understand this is the same problem that described in this ticket for DataFrame:
https://sft.its.cern.ch/jira/browse/ROOT-9509
So now we have try to avoid using such arrays.

Boris


#3

Hi,
indeed TTreeReader does not support multi-dimensional arrays at the moment, also see the discussion here: How to read second rank array using TTreeReader

Cheers,
Enrico