Reading Histogram, Histogram drawing Empty

[quote]O.K. That’s a good point. If he used “SetBinContent” then “Sumw2()” might have been lethal.
[/quote]
Yes, if you don’t call also SetBinError

There is no TH1::Sumw(),

Lorenzo

Well, I’d like to propose that the description of how the “empty bins” are treated in the fit is changed.

For example, in http://root.cern.ch/root/html/TH1.html#TH1:Fit@1 I find:

[quote]The likelihood method has the advantage of treating correctly the empty bins and use them in the fit procedure.
In the chi2 method the empty bins are skipped and not considered in the fit.[/quote]

Well, according to the discussion here, that’s wrong.
Actually it should talk about bins with zero errors, as even if the bin is “empty” but it has a non-zero error, it will be considered in the fit. Moreover, if the bin is non-empty but it’s error is zero, it will be skipped and not considered in the fit.
That concerns the “chi2 method”. The “likelihood method” doesn’t seem to care whether the bin errors are zero or non-zero (it considers all available bins in the fit).
I don’t think I have ever found these informations anywhere in ROOT’s docs.
Of course, if “Sumw2()” has not been called, errors are sqrt(N) and so empty bins automatically have zero errors. However, if “Sumw2()” has been called, then the bin contents and bin errors are “unrelated”.

P.S. I know TH1::Sumw() doesn’t exist. I hoped you could have any idea what he meant by “Sumw()”.

Seeing the fSumw above lead me to comment out my Sumw2(), which lead to the source of the error.

Michael, could you please say how you fill your histogram? Do you use “Histo->Fill(x, w);” or do you use “Histo->SetBinContent(i, w);”? Also, what’s the “Sumw()” that you mention in your bug report reply (not to be confused with “Sumw2()”, which you mention, too)?

I use Histo->SetBinContent(i, w)

What I had done was when I declared the histogram, I initially declared it as follows

  TH1D *B_smear = new TH1D("B_smear","Beam Smear",nbins,q_min,q_max);
  B_smear->SetTitle("Beam smear in c.m."); ///HepData/7694/d47x1y1
  B_smear->GetXaxis()->SetTitle("c.m. [GeV]"); 
  B_smear->GetYaxis()->SetTitle("Profile"); 
  B_smear->Sumw2();
  
  TH1D *Blab_smear = new TH1D("Blab_smear","Beam Smear lab",nbins,ebeam_min,ebeam_max);
  Blab_smear->SetTitle("Beam smear in lab"); ///HepData/7694/d47x1y1
  Blab_smear->GetXaxis()->SetTitle("E_beam [GeV]"); 
 Blab_smear->GetYaxis()->SetTitle("Profile");
  Blab_smear->Sumw2();

Which was when created did not allow me to operate on the produced histograms.

I changed it to

  TH1D *B_smear = new TH1D("B_smear","Beam Smear",nbins,q_min,q_max);
  B_smear->SetTitle("Beam smear in c.m."); ///HepData/7694/d47x1y1
  B_smear->GetXaxis()->SetTitle("c.m. [GeV]"); 
	B_smear->GetYaxis()->SetTitle("Profile"); 
  //B_smear->Sumw2();
  
  TH1D *Blab_smear = new TH1D("Blab_smear","Beam Smear lab",nbins,ebeam_min,ebeam_max);
  Blab_smear->SetTitle("Beam smear in lab"); ///HepData/7694/d47x1y1
  Blab_smear->GetXaxis()->SetTitle("E_beam [GeV]"); 
	Blab_smear->GetYaxis()->SetTitle("Profile");
  //Blab_smear->Sumw2();

Notice I commented out the “Sumw2();”. This enabled me to operate on the histograms that were saved in a ROOT file.

I got the idea that the Sumw2() was the cause of the problem because when Phillipe replied with

I noticed the fSumw was there, and I know the file was created with Sumw2(). That is what I meant by Sumw.

Michael