Bug in TTree::Project() ?

Dmitry Onoprienko (onoprien@SLAC.stanford.edu)
Tue, 02 Feb 1999 15:20:38 -0800


When I use TTree::Project() function to fill a TH2F histogram, some data
members
(fTsumwy, fTsumwy2, fTsumwxy) are not calculated. As a result, some public
functions (GetRMS(), GetCorrelationFactor(), ...) produce incorrect results.
Using Draw() instead of Project() allows to avoid the problem.

I'm running ROOT under Windows. Here is a test macro :

{
#include <iostream.h>

c1 = new TCanvas("c1","Ntuple projection test",500,500);

TFile *f = new TFile("test.root", "RECREATE");

TNtuple *nt = new TNtuple("nt","test","x:y");
TH2F *h = new TH2F("h","htitle",100,-4.,4.,100,-4.,4.);

Float_t x,y;
Int_t event = 500;
TRandom rn = new TRandom();
while (event-->0) {
nt->Fill(rn.Gaus(),rn.Gaus());
}
f->Write();

nt->Project("h","x:y");
h->Draw();
c1->Update();
cerr << "Now check statistics for the displayed histogram\n";
cerr << "Mean and RMS along Y are zero, also\n";
cerr << "h->GetCorrelationFactor() gives " << h->GetCorrelationFactor()
<<endl;

}