Hot to get graphs from pad, if they have the same names?


I have .root file with canvas.
I can get one of pads and find my graph:

    TFile file1("/home/darkside/Vlad_Programs/Physical_results/fft_15MHz_cut.root", "READ");
    TCanvas* canv1 = 0;
    file1.GetObject("c", canv1);

    TPad *pad_cd = (TPad*)canv1->GetListOfPrimitives()->FindObject("c_2");
    TGraph *gh_cd = (TGraph*)pad_cd->GetListOfPrimitives()->FindObject("Graph");

But I have two graphs with the same name “Graph”.

TPad fXlowNDC=0.343333 fYlowNDC=0.676667 fWNDC=0.313333 fHNDC=0.313333 Name= c_2 Title= c_2 Option=
 OBJ: TList	TList	Doubly linked list : 0
  TFrame  X1= 1402.475321 Y1=-39.202500 X2=4501.989744 Y2=7.597500
  OBJ: TGraph	Graph	original - baseline (Channel 1, SiPM) : 1 at: 0x3359e10
  OBJ: TGraph	Graph	Graph : 1 at: 0x335d350
  OBJ: TF1	tf1_baseline_cd2	[0] : 1 at: 0x336e480
  OBJ: TPaveText	TPave  	X1= 4114.550458 Y1=1.747500 X2=4889.429075 Y2=13.447500
  OBJ: TPaveText	title  	X1= 1596.194952 Y1=9.504613 X2=4308.270112 Y2=13.155001

How to get access to the both graphs?

Thank you in advance.
Best regards, Vladislav.
fft_15MHz_cut.root (113 KB)

GetListOfPrimitives returns a TLIst. Just iterate on this list and get the one you want (1st, or 2nd).

Could you show small example with code?

Tlist doc gives examples