TLonesArray, TTree

Hello Rooters,

I have a class inherited from TConesArray, and I would like to store them in TTree, than read them back and use them …

So I try to store them:

Array1 = new TMyArray(“CBTParticle”, 50);
Array2 = new TMyArray(“CBTParticle”, 50);
Array3 = new TMyArray(“CBTParticle”, 50);
Array3 = new TMyArray(“CBTParticle”, 50);

tree = new TTree(“tree”, “Data buffer tree”);

tree->Branch( “Array1”, “TMyArray”, &Array1, 64000, 2);
tree->Branch( “Array2”, “TMyArray”, &Array2, 64000, 2);
tree->Branch( “Array3”, “TMyArray”, &Array3, 64000, 2);
tree->Branch( “Array4”, “TMyArray”, &Array4, 64000, 2);

It seems to be OK but when I try to read it back (using the code given by the MakeClass) after some entries it chrashes.

TMyArray *Array1;
TMyArray *Array2;
TMyArray *Array3;
TMyArray *Array4;

// List of branches
TBranch *b_Array1_TClonesArray; //!
TBranch *b_Array2_TClonesArray; //!
TBranch *b_Array3_TClonesArray; //!
TBranch *b_Array4_TClonesArray; //!

Array1 = 0;
Array2 = 0;
Array3 = 0;
Array4 = 0;
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(0);

fChain->SetBranchAddress(“Array1”, &Array1, &b_Array1_TClonesArray);
fChain->SetBranchAddress(“Array2”, &Array2, &b_Array2_TClonesArray);
fChain->SetBranchAddress(“Array3”, &Array3, &b_Array3_TClonesArray);
fChain->SetBranchAddress(“Array4”, &Array4, &b_Array4_TClonesArray);

I can see the content of the tree because when I store it I dump the content of the TMyArray to the screen (after the tree->Fill()) and the common seems to be in the events which crashes the reading is that the Array4 has more then 16 entries:
[printout from the storing code]

Array1: 0; Array2: 3; Array3: 1; Array4: 4
----- Array1 time -----

Array1: 11; Array2: 3; Array3: 2; Array4: 11
----- Array1 time -----

0; time = 266.025
1; time = -105.077
2; time = -548.421
3; time = -68.7861
4; time = 275.719
5; time = 352.087
6; time = 256.14
7; time = -581.412
8; time = -207.875
9; time = -369.517
10; time = -528.262

Array1: 4; Array2: 3; Array3: 1; Array4: 18
----- Array1 time -----

0; time = 142.042
1; time = -503.692
2; time = -113.954
3; time = 200.555

[the same given by the read-back]
6 - Array1 -

7 - Array1 time -
0 - 266.025
1 - -105.077
2 - -548.421
3 - -68.7861
4 - 275.719
5 - 352.087
6 - 256.14
7 - -581.412
8 - -207.875
9 - -369.517
10 - -528.262

Using host libthread_db library “/lib/libthread_db.so.1”.
Attaching to program: /proc/22740/exe, process 22740
Error while mapping shared library sections:
BoundOmega_ppi.so: Success.
[Thread debugging using libthread_db enabled]
[New Thread 47171458248320 (LWP 22740)]
0x00002ae6f53ca715 in waitpid () from /lib/libc.so.6
#1 0x00002ae6f5373721 in strtold_l () from /lib/libc.so.6
#2 0x00002ae6f0bd194a in TUnixSystem::StackTrace ()
from /dsk/tr16/software/builds3rdParty/64bit/root_v5.18_geant4.9.1/lib/root/l
ibCore.so.5.18
#3 0x00002ae6f0bd0be3 in TUnixSystem::DispatchSignals ()
from /dsk/tr16/software/builds3rdParty/64bit/root_v5.18_geant4.9.1/lib/root/l
ibCore.so.5.18

if I change the fChain->SetMakeClass(0) to fChain->SetMakeClass(1) all the arrays will have 0 entries …

Can somebody help me to find the problem?

Thanx,
k.

Additional info:
It seems the error occures when any of the stored arrays has more element than 16.

What is this limit of the array-size?

k.

sorry, what I forgot:
Linux, root 5.18

Nobody?
I would really need some feedback/help …

k

Hi,

It’s not clear to me what you’re trying to do, nor am I’m not sure why you use a TClonesArray as a base class.

  1. Consider using (but not deriving from) std::vector’s.

  2. Post a short-but-complete piece (or two pieces - one for writing a tree and one for reading it) that shows the problem.

    Good luck,
    Charles

[quote]if I change the fChain->SetMakeClass(0) to fChain->SetMakeClass(1) all the arrays will have 0 entries …[/quote]Making this change request to NOT use objects when retrieving the information (in general you do not want to use this unless you have created a skeleton class using fChain->MakeClass).

Cheers,
Philippe.

[quote]I have a class inherited from TClonesArray[/quote]TClonesArray is not designed to be derived from … For what purpose are you trying to inheriting from TClonesArray? You might be better off using composition.

Cheers,
Philippe.

[quote=“cplager”]Hi,

It’s not clear to me what you’re trying to do, nor am I’m not sure why you use a TClonesArray as a base class.
[/quote]

This is not really my fault :-{
My framework is using it like this …

Yes, I am working on it …
I can write the tree successfuly, I generate the reading routine with MakeClass, I try tu run the code generated by MakeClass, and I get the error:
Error in TTree::SetBranchAddress: The class requested (vector<CBTParticle*>) for the branch “BeamPhotons” refer to an stl collection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector<CBTParticle*>)
I think I can solve this, but certainly this is the situation now,

I can, but while it depends on the framwork it wont be run alone …
I will prepare this …

Thanx for your reply,
k.