// -------------------------------------------------------------------------------------- // ----- CbmRichRingFinderHough source file ----- // ----- Algorithm idea: G.A. Ososkov (ososkov@jinr.ru) and Simeon Lebedev (salebedev@jinr.ru) ----- // ----- Implementation: Simeon Lebedev (salebedev@jinr.ru) and Andrei Lebedev (alebedev@jinr.ru)----- /* This program performs the procedure of the ring recognition from data obtained from the CBM RICH detector. the main program calls sequentially the following procedures: 1) init() initialization: input data, find max and min values of X and Y to define the histogramming range. 2) find_clusters(): coarse histogramming of source data, cluster them by the nearest neighbour algoritm; then make a decimation of points in every area taking each second point to speed up calculations. 3)Hough transform (HT) consists in calculating centers and radii of circles drawn through every possible triplet of points and then 2D histogramming these centers. Each time we test distances between points and obtained radii of a triplet to be within prescribed limits. Eliminate From 2D histogram all bins with the number of points less than given limit are eliminated Then all separated areas are clustered. In each of found areas centers and radii are approximated according to the following rules: a. Initiate by marking all bins as non-searched; b. Look for bins with maximum values x_max, y_max. c. If values in all bins adjacent to x_max, y_max are not exceeding them, calculate the center as the center of gravity (see item 9 below) and mark these bins as searched. d. Go on until exhausting all non-marked bins. */ #include #include #include "CbmRichRingFinderHough.h" #include "CbmRichHit.h" #include "CbmRichLightSpot.h" #include "CbmRichRing.h" #include "CbmTrackParam.h" //-------------------------------------------------------------------------- // ----- Default constructor ------------------------------------------- CbmRichRingFinderHough::CbmRichRingFinderHough() { fVerbose = 1; fh_dist = new TH1F("h1","distance",50,0,5); } // ----- Standard constructor ------------------------------------------ CbmRichRingFinderHough::CbmRichRingFinderHough ( Int_t verbose ) { fVerbose = verbose; fh_dist = new TH1F("h1","distance",50,0,5); } // ----- Destructor ---------------------------------------------------- CbmRichRingFinderHough::~CbmRichRingFinderHough() { } void CbmRichRingFinderHough::Init() { cout << "CbmRichRingFinderHough::init() "< UpH; std::vector DownH; if ( !rHitArray) { cout << "-E- CbmRichRingFinderTrack::DoFind: Hit array missing! " << rHitArray << endl; return -1; } const Int_t nhits = rHitArray->GetEntriesFast(); if(!nhits) { cout << "No hits in this event." << endl; return -1; } for(Int_t iHit = 0; iHit < nhits; iHit++) { CbmRichHit * hit = (CbmRichHit*)rHitArray->At(iHit); if(hit){ CbmRichMyPoint tempPoint; if (hit->Y() >= 0) kYMIN = 80; else kYMIN = -250; tempPoint.fX = hit->X() - kXMIN; tempPoint.fY = hit->Y() - kYMIN; tempPoint.fId = iHit; tempPoint.fRefIndex = hit->GetRefIndex(); if (hit->Y() >= 0) UpH.push_back(tempPoint); else DownH.push_back(tempPoint); } } cout << "fData.size() = "<< fData.size()<GetEntriesFast(); if(!npoints) { cout << "No projections in this event." << endl; return -1; } for(Int_t iPoint = 0; iPoint < npoints; iPoint++) { CbmTrackParam * point = (CbmTrackParam*)rProjArray->At(iPoint); if(point) { CbmRichMyPoint tempPoint; tempPoint.fX = point->GetX(); tempPoint.fY = point->GetY(); tempPoint.fId = iPoint; fGuidance.push_back(tempPoint); //cout<<"X="<GetEntriesFast() << endl; cout << "Number of output rings: " << rRingArray->GetEntriesFast() << endl; } void CbmRichRingFinderHough::Finish() { c2 = new TCanvas("c2","c2",800,1000); fh_dist->Draw(); } void CbmRichRingFinderHough::SetParameters(int NIterations, int NBinsX[], int NBinsY[], int HTNBinsX[], int HTNBinsY[], int HTCut[], int HitCut[], double MaxDistance[], double MinDistance[], double MaxRadius[], double MinRadius[], int NParts[], int SqLen) { cout <<"SetParameters begin"<< endl; fNIterations = NIterations; fNBinsX.push_back(NBinsX[0]);//first iteration axis X fNBinsY.push_back(NBinsY[0]);//first iteration axis Y fNBinsX.push_back(NBinsX[1]);//second iteration axis X fNBinsY.push_back(NBinsY[1]);//second iteration axis Y fNBinsX.push_back(NBinsX[2]);//third iteration axis X fNBinsY.push_back(NBinsY[2]);//third iteration axis Y fHTNBinsX.push_back(HTNBinsX[0]);//first iteration axis X fHTNBinsY.push_back(HTNBinsY[0]);//first iteration axis Y fHTNBinsX.push_back(HTNBinsX[1]);//second iteration axis X fHTNBinsY.push_back(HTNBinsY[1]);//second iteration axis Y fHTNBinsX.push_back(HTNBinsX[2]);//third iteration axis X fHTNBinsY.push_back(HTNBinsY[2]);//third iteration axis Y fHTCut.push_back(HTCut[0]);//first iteration fHTCut.push_back(HTCut[1]);//second iteration fHTCut.push_back(HTCut[2]);//third iteration fHitCut.push_back(HitCut[0]);//first iteration fHitCut.push_back(HitCut[1]);//second iteration fHitCut.push_back(HitCut[2]);//third iteration fMaxDistance.push_back(MaxDistance[0]);//first iteration fMinDistance.push_back(MinDistance[0]);//first iteration fMaxDistance.push_back(MaxDistance[1]);//second iteration fMinDistance.push_back(MinDistance[1]);//second iteration fMaxDistance.push_back(MaxDistance[2]);//third iteration fMinDistance.push_back(MinDistance[2]);//third iteration fMinRadius.push_back(MinRadius[0]);//first iteration fMaxRadius.push_back(MaxRadius[0]);//first iteration fMinRadius.push_back(MinRadius[1]);//secod iteration fMaxRadius.push_back(MaxRadius[1]);//second iteration fMinRadius.push_back(MinRadius[2]);//third iteration fMaxRadius.push_back(MaxRadius[2]);//third iteration fNParts.push_back(NParts[0]);//first iteration fNParts.push_back(NParts[1]);//second iteration fNParts.push_back(NParts[2]);//third iteration fSqLen = SqLen; cout <<"SetParameters end"<< endl; } void CbmRichRingFinderHough::InitArray() { int i ,j; cout<<"InitArray begin" << endl; fFoundRings.resize(2); for (i=0; i<2;i++) fFoundRings[i].resize(fNIterations); fTempHist.resize(kNBINSX); for(i=0;i 0 && iy < nbinsy && iy > 0) fHist[(int)ix][(int)iy].push_back(ii); } //init fTempHist vector for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++) if (fHist[i][j].size() > 0) fTempHist[i][j] = 1; else fTempHist[i][j] = 0; for (i = fSqLen; i < nbinsx - fSqLen; i++) for (j = fSqLen; j< nbinsy - fSqLen; j++){ if (fHist[i][j].size() > 0 && fTempHist[i][j] == 1){ for (int x1 = i - fSqLen; x1 < i + fSqLen ; x1++) for (int y1 = j - fSqLen; y1 < j + fSqLen ; y1++) if (fHist[x1][y1].size() == 0) fHist[x1][y1].resize(1); } } cout<<"InitHist end"<< endl; } void CbmRichRingFinderHough::FindClusters(double nbinsx, double nbinsy) { int i,j; cout << "FindCluster begin" << endl; fNClusters = 0; //init ar1[][] and ar2[][] for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++){ fAr1[i][j] = fHist[i][j].size(); fAr2[i][j] = fHistClusterNumber[i][j]; } for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++){ if (fAr1[i][j] > 0 && fAr2[i][j] == -1){ Wave(i,j, nbinsx, nbinsy); fNClusters++; } } for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++){ fHistClusterNumber[i][j] = fAr2[i][j]; } cout<<"FindCluster end"< 0 && fAr1[x-1][y] > 0 && fAr2[x-1][y] == -1 ) Wave(x-1,y,nbinsx,nbinsy); if (y+1 < nbinsy && fAr1[x][y+1] > 0 && fAr2[x][y+1] == -1 ) Wave(x,y+1,nbinsx,nbinsy); if ( x+1 < nbinsx && fAr1[x+1][y] > 0 && fAr2[x+1][y] == -1) Wave(x+1,y,nbinsx,nbinsy); if (y-1 > 0 && fAr1[x][y-1] > 0 && fAr2[x][y-1] == -1 ) Wave(x,y-1,nbinsx,nbinsy); ////////////////////////////////////////////////////////////// if (x-1 > 0 && y-1 > 0 && fAr1[x-1][y-1] > 0 && fAr2[x-1][y-1] == -1 ) Wave(x-1,y-1,nbinsx,nbinsy); if (x+1 < nbinsx && y-1 > 0 && fAr1[x+1][y-1] > 0 && fAr2[x+1][y-1] == -1) Wave(x+1,y-1,nbinsx,nbinsy); if (x-1 > 0 && y+1 < nbinsy && fAr1[x-1][y+1] > 0 && fAr2[x-1][y+1] == -1 ) Wave(x-1,y+1,nbinsx,nbinsy); if (x+1 < nbinsx && y+1 < nbinsy && fAr1[x+1][y+1] > 0 && fAr2[x+1][y+1] == -1) Wave(x+1,y+1,nbinsx,nbinsy); } void CbmRichRingFinderHough::InitClusters(double nbinsx, double nbinsy) { int i, j; unsigned int k; cout << "InitClusters begin" << endl; //if bin doesn't consist hits we clear it to make size()==0 for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++) if (fTempHist[i][j] == 0) fHist[i][j].clear(); int tempAr[kMAX_CLUSTERS]; for (i = 0; i < kMAX_CLUSTERS;i++) tempAr[i] = 0; for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++) if (fHist[i][j].size() > 0){ for(k = 0; k < fHist[i][j].size(); k++){ tempAr[fHistClusterNumber[i][j]]++; if (tempAr[fHistClusterNumber[i][j]]%fNParts[fCurIteration]==0) fCluster[fHistClusterNumber[i][j]][0].push_back(fHist[i][j][k]); if (tempAr[fHistClusterNumber[i][j]]%fNParts[fCurIteration]==1) fCluster[fHistClusterNumber[i][j]][1].push_back(fHist[i][j][k]); if (tempAr[fHistClusterNumber[i][j]]%fNParts[fCurIteration]==2) fCluster[fHistClusterNumber[i][j]][2].push_back(fHist[i][j][k]); } } cout << "InitClusters end" << endl; } void CbmRichRingFinderHough::CalculateRingParameters(double x[], double y[], double *xc, double *yc, double *r) { register double t1, t2, t3, t4, t5, t6, t8, t9, t10, t11, t14, t16, t19, t21, t41; t1 = x[1] * x[1]; t2 = x[2] * x[2]; t3 = y[1] * y[1]; t4 = y[2] * y[2]; t5 = t1 - t2 + t3 - t4; t6 = y[0] - y[1]; t8 = x[0] * x[0]; t9 = y[0] * y[0]; t10 = t8 - t1 + t9 - t3; t11 = y[1] - y[2]; t14 = x[1] - x[2]; t16 = x[0] - x[1]; t19 = 0.10e1 / (t14 * t6 - t16 * t11); *xc = 0.5e0 * (t5 * t6 - t10 * t11) * t19; *yc = 0.5e0 * (t10 * t14 - t5 * t16) * t19; t21 = pow(x[0] - *xc, 0.2e1); t41 = pow(y[0] - *yc, 0.2e1); *r = pow(t21 + t41, 0.5e0); } void CbmRichRingFinderHough::HoughTransform(int htcut, double nbinsx, double nbinsy) { int i,j; unsigned int i1,i2,i3; double ix, iy, dx, dy; double x[3],y[3]; double xc, yc,r; int check[kNBINSXHT][kNBINSYHT]; cout << "HoughTransform begin" << endl; //calculate HT bin size dx = (kXMAX - kXMIN) / nbinsx; dy = (kYMAX - kYMIN) / nbinsy; cout << "init begin" << endl; //init arrays for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++){ fHTHist[i][j] = 0; fHTRadius[i][j] = 0; check[i][j] = 0; } cout << "init end" << endl; double minDistance2 = fMinDistance[fCurIteration]*fMinDistance[fCurIteration]; double maxDistance2 = fMaxDistance[fCurIteration]*fMaxDistance[fCurIteration]; for (i = 0; i < fNClusters; i++) for (int iPart = 0; iPart < fNParts[fCurIteration]; iPart++) for ( i1 = 0; i1 < fCluster[i][iPart].size(); i1++){ CbmRichMyPoint mpnt; std::vector::iterator itmin; std::vector::iterator itmax; //find all hits which are in the corridor mpnt.fX = fData[fCluster[i][iPart][i1]].fX - fMaxDistance[fCurIteration]; itmin = std::lower_bound(fData.begin(), fData.end(), mpnt, CbmRichMyPoint::CmpUp); mpnt.fX = fData[fCluster[i][iPart][i1]].fX + fMaxDistance[fCurIteration]; itmax = std::lower_bound(fData.begin(), fData.end(), mpnt, CbmRichMyPoint::CmpUp)- 1 ; //first index of the hit in the corridor int indmin = itmin - fData.begin(); int indmax = itmax - fData.begin(); for (i2 = i1 + 1; i2 < fCluster[i][iPart].size(); i2++) if ((unsigned int)fCluster[i][iPart][i1] <=indmax && fCluster[i][iPart][i1] >= indmin && (unsigned int)fCluster[i][iPart][i2] <= indmax && fCluster[i][iPart][i2] >= indmin && fData[fCluster[i][iPart][i1]].fY - fMaxDistance[fCurIteration] <= fData[fCluster[i][iPart][i2]].fY && fData[fCluster[i][iPart][i1]].fY + fMaxDistance[fCurIteration] >= fData[fCluster[i][iPart][i2]].fY){ for (i3 = i2 + 1; i3 < fCluster[i][iPart].size(); i3++) if((unsigned int)fCluster[i][iPart][i3] <=indmax && fCluster[i][iPart][i3] >= indmin&& fData[fCluster[i][iPart][i1]].fY - fMaxDistance[fCurIteration] <= fData[fCluster[i][iPart][i3]].fY && fData[fCluster[i][iPart][i1]].fY + fMaxDistance[fCurIteration] >= fData[fCluster[i][iPart][i3]].fY){ /*double r12 = (fData[fCluster[i][iPart][i1]].fX - fData[fCluster[i][iPart][i2]].fX)* (fData[fCluster[i][iPart][i1]].fX - fData[fCluster[i][iPart][i2]].fX )+ (fData[fCluster[i][iPart][i1]].fY - fData[fCluster[i][iPart][i2]].fY)* (fData[fCluster[i][iPart][i1]].fY - fData[fCluster[i][iPart][i2]].fY); double r13 = (fData[fCluster[i][iPart][i1]].fX - fData[fCluster[i][iPart][i3]].fX)* (fData[fCluster[i][iPart][i1]].fX - fData[fCluster[i][iPart][i3]].fX)+ (fData[fCluster[i][iPart][i1]].fY - fData[fCluster[i][iPart][i3]].fY)* (fData[fCluster[i][iPart][i1]].fY - fData[fCluster[i][iPart][i3]].fY); double r23 = (fData[fCluster[i][iPart][i2]].fX - fData[fCluster[i][iPart][i3]].fX)* (fData[fCluster[i][iPart][i2]].fX - fData[fCluster[i][iPart][i3]].fX)+ (fData[fCluster[i][iPart][i2]].fY - fData[fCluster[i][iPart][i3]].fY)* (fData[fCluster[i][iPart][i2]].fY - fData[fCluster[i][iPart][i3]].fY); if (r13 > minDistance2 && r13 < maxDistance2 && r23 > minDistance2 && r23 < maxDistance2 && r12 > minDistance2 && r12 < maxDistance2){*/ x[0] = fData[fCluster[i][iPart][i1]].fX; x[1] = fData[fCluster[i][iPart][i2]].fX; x[2] = fData[fCluster[i][iPart][i3]].fX; y[0] = fData[fCluster[i][iPart][i1]].fY; y[1] = fData[fCluster[i][iPart][i2]].fY; y[2] = fData[fCluster[i][iPart][i3]].fY; CalculateRingParameters(x, y, &xc, &yc, &r); if (xc >0 && xc < (kXMAX - kXMIN) && yc > 0 && yc < (kYMAX - kYMIN) && r > fMinRadius[fCurIteration] && r < fMaxRadius[fCurIteration]) { modf(xc / dx, &ix); modf(yc / dy, &iy); if (ix < nbinsx && ix > 0 && iy < nbinsy && iy > 0 ){ fHTHist[(int)ix][(int)iy]++; fHTRadius[(int)ix][(int)iy] += r; int xx =(int)ix; int yy =(int)iy; if (check[xx][yy] == 0){ for (unsigned int kkk = 0; kkk < fData.size(); kkk++) fRingHits[xx][yy][kkk] = 0; check[xx][yy] = 1; } //what Hits fRingHits[(int)ix][(int)iy][fCluster[i][iPart][i1]]++; fRingHits[(int)ix][(int)iy][fCluster[i][iPart][i2]]++; fRingHits[(int)ix][(int)iy][fCluster[i][iPart][i3]]++; } } //} } //} } } //init HThist3 for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++) fHTHist3[i][j] = fHTHist[i][j]; for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++) if (fHTHist[i][j] < htcut) fHTHist[i][j] = 0; cout << "HoughTransform end" << endl; } void CbmRichRingFinderHough::FindHTClusters(double nbinsx, double nbinsy,int hitcut,int UpOrDown) { int i,j; cout << "FindHTClusters begin" << endl; fNClusters = 0; //init ar1[][] and ar2[][] for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++){ fAr1[i][j] = fHTHist[i][j]; fHTHistClusterNumber[i][j] = -1; fAr2[i][j] = fHTHistClusterNumber[i][j]; } for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++){ if (fAr1[i][j] > 0 && fAr2[i][j] == -1){ Wave(i,j, nbinsx, nbinsy); fNClusters++; } } for (int iCluster = 0; iCluster < kMAX_CLUSTERS; iCluster++) fHTCluster[iCluster].clear(); for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++){ fHTHist[i][j] = fAr1[i][j]; fHTHistClusterNumber[i][j] = fAr2[i][j]; if (fHTHistClusterNumber[i][j] != -1 && fHTHistClusterNumber[i][j] < kMAX_CLUSTERS){ CbmRichHTCluster tempHTCluster; tempHTCluster.fHist = fHTHist3[i][j]; tempHTCluster.fX = i; tempHTCluster.fY = j; fHTCluster[ fHTHistClusterNumber[i][j] ].push_back(tempHTCluster); } } //sort array for (i= 0; i < fNClusters; i++) sort(fHTCluster[i].begin(), fHTCluster[i].end(), CmpSortHTCluster()); double dx = (kXMAX - kXMIN) / nbinsx; double dy = (kYMAX - kYMIN) / nbinsy; for (i = 0; i < nbinsx; i++) for (j = 0; j < nbinsy; j++) fHTCheck[i][j] = 0; int kk,k; CbmRichHit* crh = new CbmRichHit; for (j = 0; j < fNClusters; j++){ for (kk = fHTCluster[j].size() - 1; kk >= 0; kk--){ if ( fHTCluster[j][kk].fX >= 0 && fHTCluster[j][kk].fX < kNBINSXHT && fHTCluster[j][kk].fY >= 0 && fHTCluster[j][k].fY < kNBINSYHT && fHTCheck[ fHTCluster[j][kk].fX ][ fHTCluster[j][kk].fY ] == 0 ){ k = kk; if (fHTCluster[j][k].fX - 1 > 0 && fHTCluster[j][k].fX + 1 < kNBINSXHT && fHTCluster[j][k].fY - 1 > 0 && fHTCluster[j][k].fY + 1 < kNBINSYHT) if (fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY ] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] && fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY ] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] && fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY - 1] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] && fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY + 1] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] && fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY - 1] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] && fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY + 1] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] && fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY - 1] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] && fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY + 1] < fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] ){ int sum; double xcenter, ycenter; sum = fHTHist3[ fHTCluster[j][k].fX - 1] [ fHTCluster[j][k].fY ] + fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY ] + fHTHist3[ fHTCluster[j][k].fX ] [ fHTCluster[j][k].fY - 1] + fHTHist3[ fHTCluster[j][k].fX ] [ fHTCluster[j][k].fY + 1] + fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY - 1] + fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY + 1] + fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY - 1] + fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY + 1] + fHTHist3[ fHTCluster[j][k].fX] [ fHTCluster[j][k].fY]; xcenter = dx * ( (fHTCluster[j][k].fX - 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY ] + (fHTCluster[j][k].fX + 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY ] + (fHTCluster[j][k].fX + 0.5) * fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY - 1] + (fHTCluster[j][k].fX + 0.5) * fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY + 1] + (fHTCluster[j][k].fX - 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY - 1] + (fHTCluster[j][k].fX - 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY + 1] + (fHTCluster[j][k].fX + 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY - 1] + (fHTCluster[j][k].fX + 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY + 1] + (fHTCluster[j][k].fX + 0.5) * fHTHist3[ fHTCluster[j][k].fX][ fHTCluster[j][k].fY] ) / sum; ycenter = dy * ( (fHTCluster[j][k].fY - 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY ] + (fHTCluster[j][k].fY + 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY ] + (fHTCluster[j][k].fY + 0.5) * fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY - 1] + (fHTCluster[j][k].fY + 0.5) * fHTHist3[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY + 1] + (fHTCluster[j][k].fY - 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY - 1] + (fHTCluster[j][k].fY - 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY + 1] + (fHTCluster[j][k].fY + 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY - 1] + (fHTCluster[j][k].fY + 1 + 0.5) * fHTHist3[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY + 1] + (fHTCluster[j][k].fY + 0.5) * fHTHist3[ fHTCluster[j][k].fX][ fHTCluster[j][k].fY] ) / sum; CbmRichRing tempRing; tempRing.SetCenterX(xcenter); tempRing.SetCenterY(ycenter); tempRing.SetRadius(fHTRadius[ fHTCluster[j][k].fX ][fHTCluster[j][k].fY] / fHTHist[fHTCluster[j][k].fX][fHTCluster[j][k].fY]); int hist[20]; for(int oH = 0 ; oH <20 ; oH++) hist[oH] = 0; //double ir; int ii; for (unsigned int ih=0; ih < fData.size(); ih++){ int summ = fRingHits[fHTCluster[j][k].fX][fHTCluster[j][k].fY][ih];/* + fRingHits[fHTCluster[j][k].fX - 1][fHTCluster[j][k].fY][ih] + fRingHits[fHTCluster[j][k].fX + 1][fHTCluster[j][k].fY][ih] + fRingHits[fHTCluster[j][k].fX ][fHTCluster[j][k].fY - 1][ih] + fRingHits[fHTCluster[j][k].fX ][fHTCluster[j][k].fY + 1][ih] + fRingHits[fHTCluster[j][k].fX - 1][fHTCluster[j][k].fY + 1][ih] + fRingHits[fHTCluster[j][k].fX - 1][fHTCluster[j][k].fY - 1][ih] + fRingHits[fHTCluster[j][k].fX + 1][fHTCluster[j][k].fY + 1][ih] + fRingHits[fHTCluster[j][k].fX + 1][fHTCluster[j][k].fY - 1][ih];*/ if(UpOrDown == 0) kYMIN = 80; else kYMIN = -250; if (summ >=hitcut){ CbmRichHit* crh = new CbmRichHit; crh->SetXYZ(fData[ih].fX + kXMIN, fData[ih].fY + kYMIN, fData[ih].fId); crh->SetRefIndex(fData[ih].fRefIndex); tempRing.AddHit(crh); } /* double r = pow((fData[ih].fX - xcenter)*(fData[ih].fX - xcenter) + (fData[ih].fY - ycenter)*(fData[ih].fY - ycenter), 0.5); if (r > 3.5 && r < 6.5) { double ir ; modf(r / (6.5 / 20.0), &ir); if (ir < 20 && ir > 0 ) hist[ (int) ir ]++; } }*/ /*if (fRingHits[fHTCluster[j][k].fX][fHTCluster[j][k].fY][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX - 1][fHTCluster[j][k].fY][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX + 1][fHTCluster[j][k].fY][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX ][fHTCluster[j][k].fY - 1][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX ][fHTCluster[j][k].fY + 1][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX - 1][fHTCluster[j][k].fY + 1][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX - 1][fHTCluster[j][k].fY - 1][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX + 1][fHTCluster[j][k].fY + 1][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX + 1][fHTCluster[j][k].fY - 1][ih] >= hitcut) tempRing.AddHitIndex(fData[ih].fId); if (fRingHits[fHTCluster[j][k].fX - 1][fHTCluster[j][k].fY][ih + 1] >= hitcut) tempRing.AddHitIndex(fData[ih].fId);*/ } /*int max = 0; for (i = 0; i < 20; i++) if (hist[i] > max) { max = hist[i]; ii = i; } unsigned int maxsum = hist[ii]; if (maxsum >=4){ if (ii+1 < 20) maxsum += hist[ii+1]; if (ii-1 > 0) maxsum += hist[ii-1]; } if (maxsum >= 10)*/ fFoundRings[UpOrDown][fCurIteration].push_back(tempRing); fHTCheck[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY ] = 1; fHTCheck[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY ] = 1; fHTCheck[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY - 1] = 1; fHTCheck[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY + 1] = 1; fHTCheck[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY - 1] = 1; fHTCheck[ fHTCluster[j][k].fX - 1][ fHTCluster[j][k].fY + 1] = 1 ; fHTCheck[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY - 1] = 1; fHTCheck[ fHTCluster[j][k].fX + 1][ fHTCluster[j][k].fY + 1] = 1; fHTCheck[ fHTCluster[j][k].fX ][ fHTCluster[j][k].fY ] = 1; } } } } cout<<"FindHTClusters end"<