Size of a "simple" leaflist data structure of a tr

Hi!
I have several different ROOT-file with simple data types stored in trees, that is to say i.e. one branch “data” and a leaflist like “x/D:y/F:z/I:names[30]/C”.
Now just want to read out the data, serialize the data, send it as byte stream over a socket communication (not ROOT) and store the data in another ROOT-file with the same branch structure. My problem is that I don’t know how much memory I have to allocate for the read out and I don’t know the corresponding size of the byte stream because there are severall different data structures used.
(for the example above the size would be: 8+4+4+30 byte)

Does there exist a simple way to get the size of the leaflist-data structure without analyzing the leaflist string ?

Hi,

The best way would be for you to migrate from using a leaf list to using an Object (every single of the steps you need to take will be simpler).

Nonetheless is the answer:TLead *leaf = (TLeaf*)mytree->GetBranch(mybranchname)->GetListOfLeaves()->Last(); Long_t size = leaf->GetOffset() + leaf->GetLenType()*leaf->GetLen();

Cheers,
Philippe.

Thank you very much for the fast answer. It was exactly what I was looking for :smiley:.

Normaly I would also prefer to use an Object, but it would make other things much more complicate. The mentioned ROOT-files are used for setup description and characterisation, somehow like a database: several motors are moved in random fashion in a turbulence experiment. The tree, I am using for characterising the random movement of the motors. Therefor additional information like histograms and power spectra are also stored in these ROOT-files. Another tree contains all position values that are nescessary for control. In the moment it is not clear what are the right parameters for characterisation. Via datasocket connections a measurement program gets this and additional describing information from other programs like for the control of a traversing system or a weather station.
The problem is that the all these programs including that for motion control are written in CVI, that is to say in C instead of C++, requiering DLLs with wrapper functions for the usage of ROOT functionality. (Today I would probably use Qt and ROOT for that purpose but two and a half year ago it seemed much to complicate for me.)
Another reason is, that up to now, nobody else in my working group is using ROOT and therefor I want to keep to the standard classes of ROOT.