Creating trees or branches from histograms


I am performing analysis over a dataset and it usually entails creating a load of histograms (atleast 30-40). I wish to be able to group/bunch these histograms into branches like we do in trees->braches->leafs structure so as to have a one branch for each category of histograms.

Could you suggest any suitable approach if such a thing is possible. A pseudo code will help in case there is a solution for this query.

thanks in advance.

_ROOT Version:6.28/06
_Platform: macOS
_Compiler: cling 0.9

Welcome to the ROOT forum

I guess @pcanal can help you.

Unless you have multiple version of these histograms, TTree would not be beneficial. In this case, you would be better serve organizing the TFile in sub-directories (see TFile::mkdir) for each categories.

Alternative you could also store the raw data of the histograms in branches.

Also you can simply store the histogram in unsplit branches:

tree->Branch(branchname, &histptr, 32000, 0 /* splitlevel */);

Hi @pcanal,
Could you please provide a sample code or an example how to put histograms as branches of a tree ? Sorry, I am pretty new to root here.

The best is not put the histogram but the raw data in the TTree. See for example ROOT: Tree tutorials

You can also read Trees - ROOT and Dataframes - ROOT