How to get canvases from file, if they have the same name?


I have .root file with canvases.
All canvases have the same name “c”.
How to choose one of them?

  KEY: TCanvas	c;10	c
  KEY: TCanvas	c;9	c
  KEY: TCanvas	c;8	c
  KEY: TCanvas	c;7	c
  KEY: TCanvas	c;6	c
  KEY: TCanvas	c;5	c
  KEY: TCanvas	c;4	c
  KEY: TCanvas	c;3	c
  KEY: TCanvas	c;2	c
  KEY: TCanvas	c;1	c

This code works if I have one canvas only

    TFile file("path_to_file/file.root", "READ");
    TCanvas* canv = 0;
    file.GetObject("c", canv);
    TPad *pad_cd = (TPad*)canv->GetListOfPrimitives()->FindObject("c");

This do not work too

TPad *pad_cd = (TPad*)canv->GetListOfPrimitives()->FindObject("c;1");

I searched, but did not find the answer.
Could you help and show example of code?

Thank you in advance.
Best regards, Vladislav.

Try: TCanvas *c_1 = ((TCanvas *)(file.FindObjectAny("c;1"))); TCanvas *c_2 = ((TCanvas *)(file.FindObjectAny("c;2"))); // ... TCanvas *c_10 = ((TCanvas *)(file.FindObjectAny("c;10")));

Many thank!

This works too

file.GetObject("c;1", canv);

Sorry for troubling you.
I was inattentive.