How to add TLegend to a canvas

Hi,
I have a few histograms superimposed which are saved as a canvas in a root file. Now I would like to add a Legend to this canvas. My question is how I can find out the histogram pointers in this canvas, which I should add as an arguments to a function
legend-> addEntry(h,“text”,“p”);
Thanks for any help

How did you add these histograms to the canvas?
Anyhow, you can retrieve a pointer to a histogram in a pad if you know its name
TH1 h = (TH1)pad->GetPrimitive(“histo name”);

Rene

Dear Rene,
That was my problem to find the names of the histograms as I didn’t know them. I found only “graphical” way to get the histogram name by clicking on the depicted point with right mouse button. I thought there is a method something like c1->DumpAnObjectList(). But for now I have found all histogram names and can use them in TLegend. Thanks.
Pavel