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