Several lines in a loop

Hi, I’m trying to draw several lines in a histogram with a loop:

    for (Int_t i = 0; i<npsis ; i++){
         TLine top1(-180,(TMath::ATan(tt[i]))*180/Pi,180,(TMath::ATan(tt[i]))*180/Pi);
         top1->SetLineColor(kRed);
         top1.Draw();
    }

This code only draws the last line.
I tried to delete the object every time, but it doesn’t work.
Is there any way to erase the line, so I still have the draw in the histogram and I also can use that name for another line to draw?

Cheers.

Hi,

Replace TLine top1(-180,(TMath::ATan(tt[i]))*180/Pi,180,(TMath::ATan(tt[i]))*180/Pi);withTLine *top1 = new TLine(-180,(TMath::ATan(tt[i]))*180/Pi,180,(TMath::ATan(tt[i]))*180/Pi);

Cheers,
Philippe.