TBranch - adding a vector of histograms to a tree

Hi,

I’ve created a tree and wish to add a vector of histograms. I have:

std::vector <TH1F *> hist;
tree->Branch(“hist”, &hist,“hist[i]/F” );

I keep getting the error:
TBranch::TBranch: Illegal leaf: ‘hist/hist[i]/F’

How can I solve this?

Thanks,

Lisa

Hi,

Humm tree->Branch("hist", &hist,"hist[i]/F" ); I am not sure what you meant by that … in ‘hist[i]/F’ the F mean that the array element are float and that the data is stored as a C style array starting at the address you indicates (and you are passing an array of pointes to something that is not even a float …).

Instead you should generated the dictionary for your vector<TH1F*> and simply do:[code] std::vector <TH1F *> *hist_p = new std::vector <TH1F *>;
tree->Branch(“hist”, &hist_p);[code]

Cheers,
Philippe