Writing TNtuple or String into a Tree


I have to use the following tree:
Branch1:var1 (Int_t)
Branch2:var2 (Int_t)
Branch3:tuple (TNtupleD)

I get some errors reading the tree because of TNtupleD. I think I cannot just try to link using TTree::Branch(), and then fill. What would you advice in order to store this TNtupleD variables ? I heart about serialization at some point, when I was looking at some others threads, but no practical example.

I wanted also to deal with TString, but same thing. I wonder if it’s not because I have to specify the size in order to allocate the correct memory space for the tree?
I though about keeping in memory my TNtupleD and just store the name of the ntuple to then find the object. Nevertheless both trials didn’t work… Help ! :frowning:

Ok, after looking more in detail. The total size overtakes the size of the Basket. Could it be the reason of my problem ? Concerning the reading of my TTree afterwards ?

Collection name=‘TList’, class=‘TList’, size=1

*Tree :mytree : tree *
*Entries : 157 : Total = 9469961 bytes File Size = 0 *

  •    :          : Tree compression factor =   1.00                       *

*Br 0 :var1 : var1/I *
*Entries : 157 : Total Size= 1258 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *

*Br 1 :var2 : var2/I *
*Entries : 157 : Total Size= 1270 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *

*Br 2 :tuple : TNtupleD *
*Entries : 157 : Total Size= 9467280 bytes All baskets in memory *
*Baskets : 152 : Basket Size= 32000 bytes Compression= 1.00 *


what is your usecase? Why are you forced to save a TNtuple in a TTree?


Hi dpiparo !

I am runnnig over PROOF, so I sorted my initial tree.
Initial tree:
Branch1: var1 = run number
Branch2: var2 = spill number
Branch3: var3
Branch4: var4

I want one output per run per spill. So I tried to spread the PROOF execution per run per spill.
This is in order to do not mix (var3, var4) during the merging process if 2 worker are working on same number of spill and run. Do you know what I mean?
NB: I tried to implement a custom class and redo the merging.
But I get all the time segfault when I try to redefine : Long64_t MyClass::Merge(TCollection*); So I gave up…

Finally I just tried to prepare my tree before running PROOF.
This in order to have 1 worker = (1 spill, 1 run) and do not messup because I don’t want to merge my tree as usually. just adding entries to my tree.

I tried to be clear as possible, ask me if it’s not clear…
Anyway, is it possible to do what I want? Because then with this TTree+TNtuple, it looks fine, but PROOF seems to crash each time.
PS: I managed to store strings into my tree… But if TNtuple is working I would prefere that organisation


why don’t you organise your parallelism around the solution we found in this thread?


Haha, yes indeed. I tried and on the principle it’s fine.
But it’s super slow…

That’s why… I started to think about other possibilities and other problems… so far…