Determining the dimensionality of a histogram

I would like to know how, givein a pointer to a histogram, I can determine if it is a 1d or 2d histogram (so that I can decide to turn on lego or box)

->ClassName ()

You can use

h->GetDimension(); // =1 for any TH1, =2 for any TH2, =3 for TH3 or if (h->InheritsFrom("TH2")) {..} //can be any TH2 or TH3 if (h-IsA() == TH2F::Class() {..} //test if h is a TH2F