Variable len TString array in TTree

Hi all,
I am trying to put a variable len TString array into a TTree, but with no luck…

I have done the following:

unsigned int N; // event by event len of array
TString *workernames= new TString [ MY_MAX_LEN ]; 

tree->Branch("N",&N,"N/i",BUFFER_SIZE)

tree->Branch( "workername[N]", "TString", workernames , BUFFER_SIZE)

the program seems to run fine but root crashes when I try to do

tree->Scan("workername")

on the produced file.

I suppose to have done something “strange” in the Branch call :blush: : do you have any suggestion?
Thanks!!
Luigi

PS: I’m using 5.22/00 on Linux

[quote]I suppose to have done something “strange” in the Branch call : do you have any suggestion? [/quote]Yes. You can not mix the leaflist and object branch creation method. In your case you need to either use a std::vector or create a class like:class MyStrings { int N; TString workernames[N]; };(and generate the dictionary and compile and link the result).

Cheers,
Philippe

Hi,
thank you for the reply. I was actually trying not to use any dictionary/custom class in order to build a TTree as simple as possible for some newbies/students…

I guess this is not possible without a custom class

regards
Luigi