Re: 3D Histograms and Graphs

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jan 22 1999 - 11:03:40 MET


S.P. Wakely wrote:
> 
> Hi ROOTers.
> 
> I have noticed that you cannot dump to a 3D histogram using the TTree.Draw()
> function:
> 
> Root> f = TFile("hsimple.root");
> Root> ntuple->Draw("pz>>h1");
> Root> ntuple->Draw("pz:py>>h2");
> Root> ntuple->Draw("pz:py:px>>h3");
> 
> The first two work, but the last does not produce histogram h3.

Hi Scott,
Right, this is not yet implemented. I will code this addition.

> 
> --
> Also, I have a question about the preferred technique for graphing functions
> of two variables.
> 
> As far as I know, the only way to graph a function such as x+y=z right now
> would be to loop over the value of z to fill a 2-d histogram:
> 
> TH2S *h2 = new TH2S("h2","2D Histo",10,0,10,10,0,10);
> for(int x=0;x<10;x++){
>   for(int y=0;y<10;y++){
>     for(int z=0;z<=(x+y);z++){
>       h2->Fill(x,y);
>     }
>   }
> }
> 
> h2->Draw("lego2");
> 
> This works OK, as long as the z values are non-negative
> But is there a better way to do this?

You can create a 2-d function, example
  TF2 f2("f2","x+y",0,10,0,10);
  f2.Draw("surf1");

Rene Brun



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