Access to Pad stored in ROOT file

Hello.
I have many canvases stored in my HD as .root files.
Now I want pickup these canvases and manipulated that.
To give the idea, that’s what I do for single-pad canvases:

//[1] define and book some stuff
TH1F* MyHisto.. etc etc..
TGraph* MyGraph... etcetc..
....
// ...assume this stuff is well defined 

//[2] pick up existing file
TFile* MyFile new TFile("filename.root","READ");
MyFile->cd();

//[3] pick up canvas in file
TCanvas* MyCanvas= (TCanvas*)file->Get("MyCanvasName")
MyCanvas->cd();

//[4] draw the canvas
MyCanvas->Draw();

//[5] draw my "stuff" superimposed to the previous plots of the canvas
MyHisto->Draw("same");
MyGraph->Draw("l");
..etc...

In this case it works.
Now, assume MyCanvas is “multi-padded”, (i.e. when I generated it, I made sub-divisions my means of TPad objects).
So, before drawing my new stuff over the existing plots, I need to accede to those pads.
I need to do something between step [4] and step[5]; something like:

// [4.5] accede to the pad
TPad* MyPad= (TPad*)MyCanvas->GetPad("PadName");
MyPad->cd();

but this syntax is incorrect; GetPad takes an integer as argument (the subpad number).
In my understanding, the user-defined TPads are not numbered…
So… how to do?

You can loop on the list of primitives in the canvases and retrieve the pad by name.
You can get ideas looking at the GetPad code.

Ok…
I think the simple method TCanvas:::GetPad( int pad_num) does not work because my pads have no number defined.
I guess I could have assigned a number to my pads, when generating them, throu TPad::SetNumber( int number).
Is that correct?

Yes you could have. But I thought you did not. So you have to retrieve the Pad by name now.
Look at the code of GetPad (The URL I sent you). It loops over the list of primitives in the TCanvas and look for the pads only. You should do something similar (the same loop) but instead of checking the number you look at the pad name.

I see, thank you!
Can I even retrieve non-named object? I mean TGraph, TLegend, TLine…

All object inheriting from TNamed are named.
TGraphs are. If you do not set the name yourself a TGraph is automatically named (the name of the class). Therefore, if you do not name them, all the graphs will have the same name. You can retrieve them using the code I pointed to your attention. Simply use the order in the TList.