Reading a sub-branch of array of TArrayD objects

Hello,

I am not able to read content of TArrayD objects, which are stored in an array . The related lines of code (created by using TTree::MakeClass) to the branch of that array look like these:


const Int_t kMaxfHits = 136;

TArrayD fHits_fSamples[kMaxfHits];

TBranch *b_fHits_fSamples; //!

fChain->SetBranchAddress(“fHits.fSamples”, fHits_fSamples, &b_fHits_fSamples);

The array fHits_fSamples contains variable number of hits of the type of TArrayD for different events. The hits themselves always have a constant length = 12.

When I try to access the content of hits, I am always getting these error messages:

Error in TArrayD::At: index 0 out of bounds (size: 0, this: 0x7fe82428d798)
Error in TArrayD::At: index 1 out of bounds (size: 0, this: 0x7fe82428d798)

Error in TArrayD::At: index 11 out of bounds (size: 0, this: 0x7fe82428d798)

I am sure that the TArrayD objects are not empty, I can see their content in TBrowser. Do you have an idea what could be a reason preventing me to access those objects?

I put the root file and the source files as well as a snapshot of TBrowser in my public:

/afs/cern.ch/user/k/khoriaul/public/TArrayD_issue

Thank you very much in advance.

Best regards,
Gia

Hi Gia,

The makeClass mode (which you seem to be using) does not support reading the content as object (like a TArrayD). To read this file, you can use the skeleton produced by MakeProxy or if you are using v6 by MakeSelector or by using TTreeReader.

Cheers,
Philippe.

Hi Philippe,

thank you for your reply. I am using root version 6.06/02. So, I tried both ways you suggested, MakeSelector and TTreeReader, but still without success. There is no problem to retrieve TTreeReaderValue but TTreeReaderArray is not working properly for me. If the array has a base type like Int_t, then the array members are accessible but they have random values. If the array type is TArrayD, then they can’t be accessed. I put the source code from MakeSelector and the input file in my public. There is also a macro ttreereader.C, which uses TTreeReader to access the content of the tree. It’s derived from the example code in here: root.cern.ch/doc/v606/classTTreeReader.html. In the file root_config.txt one can find some details of my root installation if that helps. All these files are located here:

/afs/cern.ch/user/k/khoriaul/public/TArrayD_issue

I would be very grateful if you could have a look at the stuff and let me know if there is some solution for my problem. I am still wondering what is the ‘magic’ that the TBrowser does to read the content of those branches with arrays.

Cheers, Gia