Re: [ROOT] ROOT file creation

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Feb 22 2002 - 11:25:48 MET


Hi Marian,

Below, you will find an example of a script marian.C creating a 2-d table
of nx*ny cells and filling it with a function. Instead of the function,
you can read a data set and use the SetBinContent to fill the table.
To execute this script, run the ROOT executable module with:
  root
and execute
  .x marian.C

You can see many examples in $ROOTSYS/tutorials. See for example surfaces.C,
draw2dopt.C.
For more details, see the Users Guide at:
   http://root.cern.ch/root/RootDoc.html

You can also execute the tutorials documemted at:
   http://www-pat.fnal.gov/root/

//file marian.C
void marian() {
   gStyle->SetOptStat(0);
   gStyle->SetPalette(1);
   gStyle->SetCanvasColor(33);
   gStyle->SetFrameFillColor(18);
   TF2 *f2 = new TF2("f2","xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
   Double_t params[] = 
      {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3};
   f2->SetParameters(params);
   Int_t nx=80, ny=80;
   TH2F *h2= 
      new TH2F("h2","xygaus + xygaus(5) + xylandau(10)",nx,-4,4,ny,-4,4);
   h2->SetFillColor(46);
   for (Int_t i=1;i<=nx;i++) {
      for (Int_t j=1;j<=ny;j++) {
         Double_t x = h2->GetXaxis()->GetBinCenter(i);
         Double_t y = h2->GetYaxis()->GetBinCenter(j);
         Double_t f = f2->Eval(x,y);
         h2->SetBinContent(i,j,f);
      }
   }
   h2->Draw("colz");
}
         
Rene Brun


Marian M. Liliac wrote:
> 
>    Part 1.1       Type: Plain Text (text/plain)
>               Encoding: quoted-printable
Hi ROOTers,

I just discovered ROOT (thanks to Jonathan) and I wander how can I use it in my
code. 
The product of my code is always a big 2D array of data that need a color
mapping representation (fields of Temp. or Concentrations)
Can someone give me an input how can I format my data in a file to feed ROOT ? 
Thank you !

wish you a happy day,
Marian



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:42 MET