Hi Wolfgang,
In a batch program, the histogram "htemp" created by default is reachable
from the current pad. do:
nt->Draw("x","cuts");;
TH1F *htemp = (TH1F*)gPad->GetPrimitive("htemp");
htemp->GetEntries();
If you pipe the result into an histogram, the histogram is also available
in the current directory. You can do:
nt->Draw("x>>hnew","cuts");
TH1F *hnew = (TH1F*)gDirectory->Get("hnew");
or
TH1F *hnew = (TH1F*)gPad->GetPrimitive("hnew");
Rene Brun
Wolfgang Korsch wrote:
>
> Dear ROOTers,
> I have an object TTree (nt) which contains a variable x. Now I want to draw
> and pipe x into a 1d histgram after some cuts. Within ROOT I do:
>
> root> nt->Draw("x","cuts");
>
> As far as I understand this automatically creates a temporary hist htemp.
> So, if I type
>
> root> htemp->GetEntries();
>
> I get the number of events after applying the above cut. This works
> fine within ROOT.
>
> Now I have a compiled version of my code. Inside the code I have
> nt->Draw("x","cuts") which works as expected, i.e. it draws the
> histogram in my canvas. But now "htemp->GetEntries" returns always
> "0". Even explicit piping (nt->Draw("x>>somehist","cuts")) doesn't
> work.
>
> Does anybody have an idea how I can access the number of events after
> the cuts?
>
> Thanks.
>
> Wolfgang
>
> P.S. I use ROOT 3.01/06 on RH 7.1
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET