TTree::Draw()

Hi rooters,
I need some help: how can I make a 3D graph with “surf” option? The only method that I found is creating a tree and draw it into a TH3F, but the only option that works is “iso”: all the others return a scatter-plot. These are some lines of my code:

c1=new TCanvas(“c1”, “flussi in piano z0”, 200,10,600,400);
c1->cd();
gPad->SetGridx();
gPad->SetGridy();
TH3F*hist=new TH3F(“hist”,“piano 0”,31,-15,15,5,0,5,155,3.2e9,4.3e9);
Int_t nentries=(Int_t) t1->GetEntries();
for (Int_t i=0; i<nentries; i++) {
t1->GetEntry(i);
hist->Fill(px,py,pz);
hist->SetFillColor(kBlue);
t1->Draw(“pz:py:px>>hist”,"",“iso”);
}

I have also triede to re-draw the histogram:

hist->Draw(“surf”);

but it gives me back the scatter plot.
Could anyone help me?
Thank you very much.

Silva Bortolussi.

Hi Silva,

It was probably a typo in your code, but you should not have the t1->Draw statement inside the loop! In fact you do not need a loop at all if you use TTree::Draw.
This function is able to make the loop itself.
You should certainly read the documentation of TTree::Draw.
To answer your question, you should simply do (outside the loop)
t1->Draw(“px:py>>hist”,“pz”,“surf1”);

Rene