Coding conventions, removing compilation warnings, consistent usage of const
[u/mrichter/AliRoot.git] / STAT / TKDInterpolator.cxx
1 #include "TKDInterpolator.h"
2 #include "TKDNodeInfo.h"
3
4 #include "TClonesArray.h"
5
6 ClassImp(TKDInterpolator)
7
8
9
10 //_________________________________________________________________
11 TKDInterpolator::TKDInterpolator() :
12         TKDInterpolatorBase()
13 {
14 // Default constructor. To be used with care since in this case building
15 // of data structure is completly left to the user responsability.
16 }
17
18 //_________________________________________________________________
19 TKDInterpolator::TKDInterpolator(Int_t ndim, Int_t npoints) :
20         TKDInterpolatorBase(ndim)
21 {
22 // Wrapper constructor for the TKDTree.
23
24         if(npoints) TKDInterpolatorBase::Build(npoints);
25 }
26
27
28 //_________________________________________________________________
29 TKDInterpolator::~TKDInterpolator()
30 {
31 }
32
33 //_________________________________________________________________
34 void TKDInterpolator::AddNode(const TKDNodeInfo &node)
35 {
36         if(!fTNodes){
37                 printf("W - TKDInterpolator::SetNode() : Node array not defined.\n");
38                 return;
39         }
40
41         new((*fTNodes)[fNTNodes++]) TKDNodeInfo(node);
42 }
43
44 //_________________________________________________________________
45 void TKDInterpolator::Build(Int_t npoints, Int_t ndim)
46 {
47         fNSize = ndim;
48         TKDInterpolatorBase::Build(npoints);
49 }
50
51 //_________________________________________________________________
52 Int_t TKDInterpolator::GetNodeIndex(const Float_t *p)
53 {
54 /*      printf("TKDInterpolator::GetNodeIndex() ...\n");
55         printf("Looking for p[");
56         for(int i=0; i<fNSize; i++) printf("%f ", p[i]);
57         printf("] ...\n");*/
58         TKDNodeInfo *node;
59         for(int inode=0; inode<fNTNodes; inode++){
60                 node = (TKDNodeInfo*)(*fTNodes)[inode];
61                 //node->Print();
62                 if(node->Has(p)) return inode;
63         }
64         return -1;
65 }
66
67
68 //_________________________________________________________________
69 Bool_t TKDInterpolator::SetNode(Int_t inode, const TKDNodeInfo &ref)
70 {
71         if(!fTNodes){
72                 printf("W - TKDInterpolator::SetNode() : Node array not defined.\n");
73                 return kFALSE;
74         }
75         if(inode >= fNTNodes){
76                 printf("W - TKDInterpolator::SetNode() : Node array defined up to %d.\n", fNTNodes);
77                 return kFALSE;
78         }
79         TKDNodeInfo *node = (TKDNodeInfo*)(*fTNodes)[inode];
80         (*node) = ref;
81         return kTRUE;
82 }
83