Hello,
I can’t manage how to make TH1::kIsAverage work while merging two histograms with hadd.
My problem is that I would like to use hadd in order to average the contents of several histograms. So, according to the NOTE 1 in hadd.cxx, I set the bit TH1::kIsAverage for each histogram, but it makes no effect. Below is a simple script to reproduce the problem:
[code]{
TH1F *h1 = new TH1F(“h”, “”, 3, 0, 3);
h1->SetBit(TH1::kIsAverage);
h1->SetBinContent(1, 1);
TFile *f1 = new TFile(“f1.root”, “recreate”);
h1->Write();
f1->Close();
delete h1;
TH1F *h2 = new TH1F(“h”, “”, 3, 0, 3);
h2->SetBit(TH1::kIsAverage);
h2->SetBinContent(1, 2);
TFile *f2 = new TFile(“f2.root”, “recreate”);
h2->Write();
f2->Close();
delete h2;
gSystem->Exec(“hadd -f both.root f1.root f2.root”);
TFile *both = new TFile(“both.root”);
h->Draw(); // the first bin value is the sum (1+2=3) but not average ( (1+2)/2.0=1.5 ). WHY?
}
[/code]
My ROOT version is 5.27/04