Project a TNtuple into an TH1F

Pascal Girard (girard@jlab.org)
Sat, 30 Jan 1999 23:49:23 -0500 (EST)


Hi all,

I'm trying to project a TNtuple in to a pre-define
TH1F from a c++ code.
I Have seen on roottalk some references to this issue,
but It seems it doesn't work for me :

I define a TH1F* RES :

TH1F* RES;
RES = new TH1F("DEDT",title,120,-0.1,0.6);

...

I read a TNtuple from file :

TNtuple *FromFile;
FromFile = (TNtuple*) TF->Get("Neutral_Events");
FromFile->Project("DEDT","MSMass",cut,"goff");

...

when I visualize DEDT , it's empty.

I tryed the Draw solution :

> TH1F *h1 = new TH1F(..
>
> The TTree::Draw function (in the form "m>>+h1") fills an histogram
> with the name "h1". In your case h1 is the name of the pointer,
> not the name of the histogram ("blat").
> It is a good practice to have the pointer_name = histogram_name.
> Your program will work with:
> TH1F *h1 = new TH1F("blat", "quat", 20, 4.5, 6);
> ntuple->Draw("m>>+blat", "(4.5<m)&&(m<6.0)");
> h1->Draw();
> or
> TH1F *blat = new TH1F("blat", "quat", 20, 4.5, 6);
> ntuple->Draw("m>>+blat", "(4.5<m)&&(m<6.0)");
> blat->Draw();
>
> Rene Brun

But It doesn't recognise the "goff" option and try to open a canvas from a
batch job. And the final result is an empty histogram.

In interactive root (on HP), Project(...) doesn't seems to work,
however
the Draw solution does.

Any suggestions ?

thanks

Pascal