Hi Zhou,
When you use the form:
n1->Draw("Y:X>>ha2"
the histogram ha2 is assumed to be accessible in the current directory.
In your case, simply do:
TFile f1("tmp_proton.root");
TNtuple *n1=(TNtuple*)f1.Get("h9");
TH2F *ha2 =new TH2F("ha2","ADC",200,-100.,100.,200,-100.,100.);
n1->Draw("Y:X>>ha2","","scat");
Note that you can also use the form:
n1->Draw("Y:X>>ha2(200,-100,100,200,-100,100);
see documentation of TTree::Draw
Rene Brun
Zhou SuiJian wrote:
>
> Dear All,
> Can anybody help me to solve the problem?
> I want to project two of the variables in a
> Ntuple into a TH2F, which has a predefined
> range for both X and Y axises. When I do
> the following:
>
> TH2F *ha2 =new TH2F("ha2","ADC",200,-100.,100.,200,-100.,100.);
> TFile f1("tmp_proton.root");
> TNtuple *n1=(TNtuple*)f1.Get("h9");
> n1->Draw("Y:X>>ha2","","scat");
>
> The scatter plot is drawn but it does not fit the
> ranges I predifined(-100. to 100.).
>
> And when I do:
> ha2->Draw("scat");
> It shows 0 entries and of course draw nothing!
> May be I missed something?
>
> Thanks!
> zhou
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET