TProfile errors after SetBinContent in TH2


ROOT Version: 6.10.04-x86_64-slc6-gcc62-opt
Platform: lxplus
Compiler: Not Provided


Hi!

I have a TH2F histogram, that I am scaling per “line” in y along the x axis. I already know this sounds confusing, so I will just add here the function that does that for me:

void ScaleLineX(TH2F* hist,int bin_x_max, int bin_y_max){

  double integral_line=0;
  for(int x=0; x<=bin_x_max; x++){
    integral_line = hist->Integral(x, x, 0, bin_y_max);
    if(integral_line>0){
      for(int y=1; y<=bin_y_max; y++){
        hist->SetBinContent(x, y, hist->GetBinContent(x,y)/integral_line);
      }
    }
  }
}

that I call with

ScaleLineX(hist, hist->GetNbinsX()+1, hist->GetNbinsY()+1);

if I have scaled the histogram like this, the errors on a ProfileX (called without options) on that histogram seem to be now the RMS instead of the RMS/sqrt(n).

I am not sure I understand the behaviour, would be happy if somebody has an explanation!

Thanks a lot,
Alex

PS: I have put for testing the rootfile I use on lxplus (/afs/cern.ch/user/a/aleopold/public/rootforum/output.root, the th2f called “hist_nhits_over_eta”)

Hi,

When you are scaling an histogram you should also scale the errors, otherwise they will just be the sqrt(content) and probably not correct in your case.
For scaling with just a constant value, can use the TH1::Scale function which does it automatically, if you call TH1::Sumw2() before.

Lorenzo