]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STAT/Macros/ioInterpolator.C
Response of the 4 towers for the 2 neutron calorimeters since,
[u/mrichter/AliRoot.git] / STAT / Macros / ioInterpolator.C
1 const int ndim = 2;
2
3 //___________________________________________________________
4 void writeInterpolator()
5 {
6         if(!gSystem->FindFile(".", "6Ddb.root")) build(6, 1000000);
7         TFile::Open("6Ddb.root");
8         TKDInterpolator in(db, "x0:x1", "", 400, 100000);
9         in.SetIntInterpolation();
10         in.SetSetStore();
11
12         Float_t c[ndim], val, v_err;
13         Double_t p[ndim], res, r_err;
14         TGraph2DErrors *g= new TGraph2DErrors(in.GetNTerminalNodes());g->SetMarkerStyle(7);
15         for(int inode=0; inode<in.GetNTerminalNodes(); inode++){
16                 in.GetCOGPoint(inode, c, val, v_err);
17                 for(int idim=0; idim<ndim; idim++){
18                         p[idim] = (Double_t)c[idim];
19                         //printf("%f ", p[idim]);
20                 }
21                 //printf("\n");
22                 in.Eval(p, res, r_err);
23                 g->SetPoint(inode, p[0], p[1], res);
24                 g->SetPointError(inode, 0., 0., r_err);
25         }
26         g->Draw("ap");
27
28         TFile *fi = TFile::Open(Form("%dD_interpolator.root", ndim), "RECREATE");
29         in.Write(Form("%dDgauss", ndim));
30         fi->Close();
31         delete fi;
32 }
33
34 //___________________________________________________________
35 void readInterpolator()
36 {
37         TFile::Open(Form("%dD_interpolator.root", ndim));
38         TKDInterpolator *in = (TKDInterpolator*)gFile->Get(Form("%dDgauss", ndim));
39         in->Dump();
40         //in->GetStatus();
41 }
42
43 //___________________________________________________________
44 void build(const int ndim, const int npoints)
45 {
46         printf("building db ...\n");
47         Float_t data[ndim];
48         TFile *f = new TFile(Form("%dDdb.root", ndim), "RECREATE");
49         TTree *t = new TTree("db", Form("%dD data base for kD statistics", ndim));
50         for(int idim=0; idim<ndim; idim++) t->Branch(Form("x%d", idim), &data[idim], Form("x%d/F", idim));
51
52         for (Int_t ip=0; ip<npoints; ip++){
53                 for (Int_t id=0; id<ndim; id++) data[id]= gRandom->Gaus();
54                 t->Fill();
55         }
56
57         t->Write();
58         f->Close();
59         delete f;
60 }