Data Structures that can hold TH1F object


It’s that I have been storing different histograms objects in a vector and an array but I always end up getting a seg faults when I try to pass a property of the histogram object to any ROOT function. Is there a useful data structure I can use for this? If not is there any method I can do to get around this?



Hi Juan,

what are you actually doing? Can you post the code to reproduce a problem?


Sorry I am not authorized to post the exact code but the situation is the following:

TH1F hist[] = {

new TH1F("hist", "", 1, 2, 3)


Or if I do:

vector<TH1F> hist = {

new TH1F("hist", "", 1, 2, 3)


And for example I call:


This would cause a seg fault and it is the same for every function I call from the class TH1F.

I’ve also tried to initialize the objects outside of the array and vector and then place the pointer object inside them but it brings up the same situation.

TH1F *hist[]
vector<TH1F*> hist

And how would you delete the memory?

Loop over the container and call delete on the elements.