TArrayI and AddFriend

Hi,
I have defined two classes, one of them, say ItemData, contain a *TArrayI parameter. Then I have create two TFile, each one with a TTree; one of the TTree is filled with ItemData objects. The strange situation is the following:

  1. if I read the files separarately i can read them both
  2. if I open the two files and I make the two TTree friends I cannot even make a GetEntry(#), but doing some changes to the IdemData class (*TArrayI change to TArray) I can again read them both.

I have attached a test script which should show the situation; commenting out the defined line you can test one situation or another.

Thanks
TArrayTest.c (3.7 KB)

Hi,

The problem is that you default constructor do not intialize the data member (this is essential!):

In addition to NOT use

from within a function. This should only be used on the command line or in an unnamed macro (i.e. no function).

Cheers,
Philippe.

sorry but It does not work anyway… please don’t blame at me but have you verified your solution rigth on the code i submitted to you? i did and the result was the usual…

thanks

Indeed I did!
Note that since you did not mention the version of ROOT nor the platform, I assume the latest version. So first try with ROOT v4.02/00.

Also you should actuall compile your macro (which means you need to add ClassDef to your classes).

Cheers,
Philippe

Well… you was rigth it was another mistakes of mine.

Thanks for your patience :slight_smile: