Superimpose histogram

Hello Rooters,
I am trying to superimpose two histogram. Following is the part of code.

Double_t error1,error2,error3,error4,error5;
     TAxis *axis1 = h3fold->GetXaxis();
     int bmin1 = axis1->FindBin(0.3);
     int bmax1 = axis1->FindBin(0.5);
     double norm3tot = h3fold->IntegralAndError(bmin1,bmax1,error1,"");
     TAxis *axis2 = h3->GetXaxis();
     int bmin2 = axis2->FindBin(0.3);
     int bmax2 = axis2->FindBin(0.5);
     double norm3bck = h3->IntegralAndError(bmin2,bmax2,error2,"");
     TH1F h3norm=  (norm3tot/norm3bck)*(*h3);

     TCanvas *caneffiicency3=new TCanvas();
     caneffiicency3->cd(1);
     h3fold->Draw();
     h3norm.Draw("sames");

I cannot get display “h3norm” on my computer display.

But I copied and pasted these command in the root command line window. That displays the both plots properly.
I am using root v6-12-04. This doesn’t work even in 6.20 versions too.

What could be the reason, this works in Command line(inside root) but not in running as a code?

Any help would be greatly appreciated.
Thanks


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


TH1F *h3norm = (TH1F*)h3->Clone("h3norm");
if (! h3norm->GetSumw2N()) h3norm->Sumw2(kTRUE); 
h3norm->Scale(norm3tot / norm3bck);

Thank you. It worked.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.