Check on histogram existence

Sorry for the basic question but could you please tell me how, before creating a new histogram, namely:
functions[name] = TH2F(name, title, nbin, xmin, xmax, ny, ymin, ymax)
I can check if it has not been already created.

Thank you,
Ghita

In my opinion, the problem could be solved this way:
you create an array of strings: name[] where you write names you are gonna use for your histos, you can use a for cycle paired with the instruction sprintf.
When you use one of the names in your array, you simply substitute them with “used”, next you make an if check iterated on all the elements of the array…
You should be done with this :smiley:

name = "hname";
if (gDirectory->FindObject(name)) printf ("%s exist \n", name);
else  printf ("%s doesn't exist \n", name);

Thanks to both for your help. It solved my problem.
Ghita :smiley: