Opening a subdirectory from a ROOT file

Dear all,
I have a .root file containing a number of subdirectories. Each subdirectory contains a number of histograms.

I open the file in this way:

TFile *infile = TFile::Open("sample.root");

Then, how can I open each subdirectory in order to draw and fit the histrograms?
Thank you in advance,
Marco.

I’ve solved in this way:

TFile *infile = TFile::Open("sample.root"); infile->cd("SUBDIR"); TH1F *input_histo; gDirectory->GetObject("h_example;1",input_histo);