Hello ROOTers,
I found odd behevior of histogram with respect to stat box.
I attached sample macro with this e-mail(histtest.cpp).
After running the macro, please look entries of two histograms in stat box.
Two hisograms must have the same entries since one histogram is clone of
the other one, I think.
But, the entries of the clone histogram is added only by number of bin.
(<entries of clone> = <entries of original> + <number of bin of histogram>).
Is this valid feature ?
I use ROOT v 3.05/05 (CVS update (May 9, 2003)) on IRIX65 with gcc 2.95.2.
void histtest() {
const Int_t nbin = 30;
Double_t Emin = 10, Emax = 100e3;
Double_t lmin = TMath::Log10(Emin);
Double_t lmax = TMath::Log10(Emax);
Double_t diff = (lmax - lmin)/nbin;
Double_t index, ebins[nbin+1];
for ( Int_t i = 0; i <= nbin; i++ ) {
index = lmin + diff*Double_t(i);
ebins[i] = TMath::Power(10, index);
}
TCanvas *c = new TCanvas("c", "", 10, 10, 500, 700);
c->Divide(1, 2);
TH1F *h = new TH1F("h", "", nbin, ebins);
Double_t E;
for ( Int_t i = 0; i < 1000; i++ ) {
index = lmin + (lmax-lmin)*(gRandom->Rndm(0));
E = TMath::Power(10, index);
cout << E << endl;
h->Fill(E);
}
c->cd(1);
h->Draw("ehist");
gPad->SetLogx(); gPad->SetLogy();
gPad->Modified(); gPad->Update();
c->cd(2);
TH1F *h2 = (TH1F*)h->Clone("h2");
Double_t N, Nerr, dE;
for ( Int_t i = 0; i <= nbin; i++ ) {
N = h2->GetBinContent(i+1);
Nerr = h2->GetBinError(i+1);
dE = h2->GetBinWidth(i+1);
N /= dE; Nerr /= dE;
h2->SetBinContent(i+1, N); h2->SetBinError(i+1, Nerr);
}
h2->Draw("ehist");
gPad->SetLogx(); gPad->SetLogy();
gPad->Modified(); gPad->Update();
}
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET