# After cloning, how can I calculate the mean and errors of new histogram?

Hi,
I used two histogram to plot ratio.Now i want to calculate the statistics of new histogram but after cloning,it gives me previous statistics.

So,after cloning how can I calculate mean and error of new histogram?

A clone is identical to the original histogram. So it is normal you get the same statistic. May be you can post some script showing what you are doing.

Also note this class: https://root.cern/doc/master/classTRatioPlot.html

Here is the script I’m struggling with.
Thank you.

``````TCanvas *f1 = new TCanvas("f1", "Charge ratio vs Muon energy",200,10,700,500);
f1->cd(1);

TH1F *hratio = (TH1F*)hemuevp->Clone("R vs E[GeV]");

hratio->SetLineColor(kBlack);
hratio->SetLineStyle(2);
hratio->Sumw2();
//hratio->SetStats(0);      // No statistics on lower plot
hratio->Divide(hemuevm);
hratio->SetMarkerColor(kRed);
hratio->SetMarkerStyle(20);
hratio->SetMarkerSize(1);
hratio->SetTitle("Charge Ratio Distribution");
hratio->GetYaxis()->SetTitle("Charge Ratio R=#mu^{+}/#mu^{-}");
hratio->GetYaxis()->SetTitleSize(20);
hratio->GetYaxis()->SetTitleFont(43);
hratio->GetYaxis()->SetTitleColor(kRed);
hratio->GetYaxis()->SetLabelColor(kRed);
hratio->GetXaxis()->SetTitleSize(20);
hratio->GetXaxis()->SetTitleFont(43);
hratio->GetXaxis()->SetTitleColor(kRed);
hratio->GetXaxis()->SetLabelColor(kRed);
hratio->Draw();
``````

Hi,

The statistics is re-computed (by calling TH1::ResetStats internally) after calling TH1::Divide.
You should not get the same statistics values in the hratio histogram.

If this is the case, please post a full running script (including the histograms)

Lorenzo

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