// #include // #include "TMatrixD.h" // #include "TRandom.h" // #include "TGraph.h" // #include "TStopwatch.h" // Int_t Mem() { // size in 1000 bytes static struct mallinfo memdebug; memdebug = mallinfo(); return memdebug.uordblks/1000; } void testindexes(Int_t nloop, Int_t npoints); void testkdtreeIF(Int_t npoints=1000, Int_t nloop=1000, Int_t mode = 1, Int_t bsize=9); void TestSizeIF(Int_t npoints=1000, Int_t nrows = 150, Int_t nsec=18, Int_t mode = 1, Int_t bsize=9); void testindexes(Int_t nloop, Int_t npoints){ // // test indexing // TKDTree *kdtree = new TKDTree(0,0,0,0); Int_t row =0; Int_t collumn =0; TStopwatch timer; timer.Start(); row = 10; for (Int_t iloop=0;iloop=(32<=(2<::GetCoord(index,row,collumn); // //Int_t index2=kdtree->GetIndex(row,collumn); //printf("%d\t%d\t%d\t%d\n",index,index2,row,collumn); if (kdtree->GetIndex(row,collumn)!=index || collumn<0) { printf("Problem\n"); } } timer.Stop(); timer.Print(); } void TestBuild(Int_t npoints, Int_t bsize){ Float_t *data0 = new Float_t[npoints*2]; Float_t *data[2]; data[0] = &data0[0]; data[1] = &data0[npoints]; for (Int_t i=0;iRndm(); data[0][i]= gRandom->Rndm(); //data[1][i]= 0; //data[0][i]= -i; } Float_t dataf[2]; TKDTreeIF *kdtree = new TKDTreeIF(npoints, 2, bsize, data); //kdtree->Build(); for (Int_t i=0; ifIndPoints[i]; //printf("%d\t%d\t%f\n",i,index,data[0][index]); } for (Int_t i=0; ifNnodes;i++){ //printf("%d\t%f\n",i,kdtree->fNodes[i].fValue); } Float_t sumiter = 0; for (Int_t i=0;iFindPoint(dataf,index, iter); if (i!=index){ printf("%d\t%d\t%f\t%f\n",i,index,dataf[0],data[0][index]); } sumiter+=iter; } printf("Mean iter = %f\n",float(sumiter)/float(npoints)); } void TestSizeIF(Int_t npoints, Int_t nrows, Int_t nsec, Int_t mode, Int_t bsize) { // // test size to build kdtree // Int_t before =Mem(); for (Int_t isec=0; isecUniform(-rangey, rangey); data[1][i] = gRandom->Uniform(-rangez, rangez); // data[i+npoints] = TMath::Nint(gRandom->Uniform(-rangez, rangez)/10.)*10.; //printf("%d %f %f\n", i, data[i], data[i+npoints]); } TStopwatch timerbuild; TKDTree *kdtree = new TKDTree(npoints,2,bsize,data); kdtree->Build(); timerbuild.Stop(); timerbuild.Print(); TStopwatch timer; Float_t countern=0; Float_t counteriter = 0; Float_t counterfound = 0; if (mode ==2){ if (nloop) timer.Start(); Int_t res[npoints]; Int_t nfound = 0; for (Int_t kloop = 0;kloopFindBNode(point,delta, bnode); //continue; kdtree->FindInRangeA(point,delta,res,nfound,iter,bnode); if (kloop==0){ //Bool_t isOK = kTRUE; Bool_t isOK = kFALSE; for (Int_t ipoint=0;ipoint