Re: Project a TNtuple into an TH1F

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Feb 01 1999 - 13:15:52 MET


Pascal,
I cannot reproduce this problem. I assume you are using 2.20 or higher.

Always use TTree::Draw. Project is an interface to Draw.

I tested your example interactively and in batch mode without
problems.

Rene Brun

Pascal Girard wrote:
> 
> 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
> 
> 
>



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:28 MET