sending trigger decisions (true and false) for every event
[u/mrichter/AliRoot.git] / STAT / TKDInterpolator.cxx
CommitLineData
f2040a8f 1#include "TKDInterpolator.h"
a3408ed3 2#include "TKDNodeInfo.h"
f2040a8f 3
a3408ed3 4#include "TClonesArray.h"
f2040a8f 5
f2040a8f 6ClassImp(TKDInterpolator)
7
f2040a8f 8
5f38a39d 9
117c62ab 10//_________________________________________________________________
a3408ed3 11TKDInterpolator::TKDInterpolator() :
12 TKDInterpolatorBase()
f2040a8f 13{
df84bc73 14// Default constructor. To be used with care since in this case building
15// of data structure is completly left to the user responsability.
f2040a8f 16}
17
18//_________________________________________________________________
a3408ed3 19TKDInterpolator::TKDInterpolator(Int_t ndim, Int_t npoints) :
20 TKDInterpolatorBase(ndim)
f2040a8f 21{
117c62ab 22// Wrapper constructor for the TKDTree.
23
a3408ed3 24 if(npoints) TKDInterpolatorBase::Build(npoints);
f2040a8f 25}
26
27
f2040a8f 28//_________________________________________________________________
29TKDInterpolator::~TKDInterpolator()
30{
f2040a8f 31}
32
33//_________________________________________________________________
a3408ed3 34void TKDInterpolator::AddNode(const TKDNodeInfo &node)
f2040a8f 35{
a3408ed3 36 if(!fTNodes){
37 printf("W - TKDInterpolator::SetNode() : Node array not defined.\n");
38 return;
f2040a8f 39 }
316a7f5a 40
a3408ed3 41 new((*fTNodes)[fNTNodes++]) TKDNodeInfo(node);
f2040a8f 42}
43
f2040a8f 44//_________________________________________________________________
a3408ed3 45void TKDInterpolator::Build(Int_t npoints, Int_t ndim)
f2040a8f 46{
a3408ed3 47 fNSize = ndim;
48 TKDInterpolatorBase::Build(npoints);
f2040a8f 49}
50
51//_________________________________________________________________
a3408ed3 52Int_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;
f2040a8f 63 }
a3408ed3 64 return -1;
316a7f5a 65}
66
67
68//_________________________________________________________________
1a439134 69Bool_t TKDInterpolator::SetNode(Int_t inode, const TKDNodeInfo &ref)
316a7f5a 70{
a3408ed3 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;
1a439134 81 return kTRUE;
316a7f5a 82}
83