Re: SMOOTHING IN 2 DIMENSIONS

From: Olivier Couet <couet_at_mail.cern.ch>
Date: Wed, 15 Jun 2005 17:33:36 +0200 (CEST)

On Wed, 15 Jun 2005, Ester Aliu Fusté wrote:

> Dear All,
>
> Is there anybody who knows if it is possible to SMOOTH a 2-dimensional
> histogram with ROOT? Looking around I have seen that this is possible with
> 1-dim histogram, but I haven't found the possibility of doing such a thing in
> 2-dim.
> With smoothing, what I mean is to change the value of that point and not to
> interpolate between the points.
>
> Thanks in advance,
>
> Ester

Hi,

 One possible is to use TGraph2D:

void h2smooth()
{
  c1 = new TCanvas("c1","h2smooth",200,10,700,500);   c1->Divide(2,1);
  h2 = new TH2F("h2","py vs px",40,-4,4,40,-4,4);                                                                                 

  gRandom->SetSeed();
  Float_t px, py, pz;
  for (Int_t i = 0; i < 25000; i++) {

     gRandom->Rannor(px,py);
     h2->Fill(px,py);

  }
  gStyle->SetPalette(1);
  c1->cd(1); h2->Draw("surf1");                                                                                 

  TGraph2D *g2 = new TGraph2D(h2);
  c1->cd(2); g2->Draw("surf1");
}

May be there is other solutions.

Cheers, Olivier

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Wed Jun 15 2005 - 17:33:42 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET