Small interface modification
[u/mrichter/AliRoot.git] / STAT / Macros / testInterpolator.C
CommitLineData
fe476dd1 1void testInterpolator()
2{
3 gStyle->SetOptStat(0);
4 gStyle->SetPalette(1);
5
6 Int_t npoints = 301;
7 Int_t bsize = 10;
8
9 Float_t *data0 = new Float_t[npoints*2];
10 Float_t *data[2];
11 data[0] = &data0[0];
12 data[1] = &data0[npoints];
13 for (Int_t i=0;i<npoints;i++) {
14 data[1][i]= gRandom->Gaus(.5, .1);
15 data[0][i]= gRandom->Gaus(.5, .1);
16 }
17 TKDInterpolator *in = new TKDInterpolator(npoints, 2, bsize, data);
18
19 TH2 *hS = new TH2F("hS", "", 10, .3, .7, 10, .3, .7);
20 TAxis *ax = hS->GetXaxis(), *ay = hS->GetYaxis();
21 Float_t p[2], eval;
22 for(int ix=1; ix<=ax->GetNbins(); ix++){
23 p[0] = ax->GetBinCenter(ix);
24 for(int iy=1; iy<=ay->GetNbins(); iy++){
25 p[1] = ay->GetBinCenter(iy);
26 eval = in->Eval(p);
27 //printf("x %f y %f eval %f [%d]\n", p[0], p[1], eval, TMath::IsNaN(eval));
28 if(!TMath::IsNaN(eval)) hS->SetBinContent(ix, iy, eval);
29 }
30 }
31 hS->Draw("lego2");
32}