Hi, I want to draw a series of histograms in a loop. When I run one example, I can get the histogram like the figure shows.
But when I use loop to generate 10 histograms, the result is as shown. There is no lines here.
Here is the structure of my code.
TH1D h1("","Bi-214",1000,2500,3500);
TH1D h2("","Tl-208",1000,2500,3500);
TH1D h3("","Signal",1000,2500,3500);
c1 = TCanvas("","",900,900);
c1.Divide(3,4);
for (int loop = 1; loop<=10;loop++){
double sgm = 2.996*loop/2.355;
h3.DrawCopy();
h2.DrawCopy("same");
h1.DrawCopy("same");
auto L1 = TLine(2996-sgm,0,2996-sgm,1);
auto L2 = TLine(2996+sgm,0,2996+sgm,1);
L1.Draw("same");
L2.Draw("same");
gPad->BuildLegend(0.6,0.7,0.9,0.94,"","l");
c1.Update();
}
Could anyone can help me? Thanks