How to judge a TObject is TH1 or the others?

Since lots of classes are inherite from TObject, if I’ve read the TObject from a root file, but I forget it is TH1 or TH2, how to judge it?

see in $ROOTSYS/tutorials/io/loopdir.C

Jan