14#include "../../littrack/std/utils/CbmLitMemoryManagment.h"
70 , fUsedHitsAllCut(0.f)
175 for (
unsigned int iHit = 0; iHit <
size; iHit++) {
176 if (
fData[iHit].fIsUsed ==
true)
continue;
191 vector<CbmRichHoughHit>::iterator itmin, itmax;
196 return m1.fHit.fX < m2.fHit.fX;
200 itmax = std::lower_bound(
fData.begin(),
fData.end(), mpnt,
204 *indmin = itmin -
fData.begin();
205 *indmax = itmax -
fData.begin();
207 int arSize = *indmax - *indmin + 1;
210 for (
unsigned short i = 0; i <
fNofParts; i++) {
215 for (
int i = *indmin; i <= *indmax; i++) {
216 if (
fData[i].fIsUsed ==
true)
continue;
217 float ry = y0 -
fData[i].fHit.fY;
219 float rx = x0 -
fData[i].fHit.fX;
220 float d = rx * rx + ry * ry;
227 for (
unsigned short j = 0; j <
fNofBinsXY; j++) {
231 for (
unsigned short k = 0; k <
fNofBinsR; k++) {
238 for (
int iPart = 0; iPart <
fNofParts; iPart++) {
245 unsigned int nofHits =
fHitInd[iPart].size();
247 float dx = 1.0f /
fDx, dy = 1.0f /
fDy, dr = 1.0f /
fDr;
249 vector<CbmRichHoughHit> data;
250 data.resize(nofHits);
251 for (
unsigned int i = 0; i < nofHits; i++) {
255 typedef vector<CbmRichHoughHit>::iterator iH;
257 for (iH iHit1 = data.begin(); iHit1 != data.end(); iHit1++) {
258 float iH1X = iHit1->fHit.fX;
259 float iH1Y = iHit1->fHit.fY;
260 double time1 = iHit1->fTime;
262 for (iH iHit2 = iHit1 + 1; iHit2 != data.end(); iHit2++) {
263 float iH2X = iHit2->fHit.fX;
264 float iH2Y = iHit2->fHit.fY;
265 double time2 = iHit2->fTime;
266 if (std::fabs(time1 - time2) >
fTimeCut)
continue;
268 float rx0 = iH1X - iH2X;
269 float ry0 = iH1Y - iH2Y;
270 float r12 = rx0 * rx0 + ry0 * ry0;
274 float t10 = iHit1->fX2plusY2 - iHit2->fX2plusY2;
275 for (iH iHit3 = iHit2 + 1; iHit3 != data.end(); iHit3++) {
276 float iH3X = iHit3->fHit.fX;
277 float iH3Y = iHit3->fHit.fY;
278 double time3 = iHit3->fTime;
280 if (std::fabs(time1 - time3) >
fTimeCut)
continue;
281 if (std::fabs(time2 - time3) >
fTimeCut)
continue;
283 float rx1 = iH1X - iH3X;
284 float ry1 = iH1Y - iH3Y;
285 float r13 = rx1 * rx1 + ry1 * ry1;
288 float rx2 = iH2X - iH3X;
289 float ry2 = iH2Y - iH3Y;
290 float r23 = rx2 * rx2 + ry2 * ry2;
293 float det = rx2 * ry0 - rx0 * ry2;
294 if (det == 0.0f)
continue;
295 float t19 = 0.5f / det;
296 float t5 = iHit2->fX2plusY2 - iHit3->fX2plusY2;
298 float xc = (t5 * ry0 - t10 * ry2) * t19;
300 int intX = int(xcs * dx);
301 if (intX < 0 || intX >=
fNofBinsX)
continue;
303 float yc = (t10 * rx2 - t5 * rx0) * t19;
305 int intY = int(ycs * dy);
306 if (intY < 0 || intY >=
fNofBinsY)
continue;
309 float t6 = iH1X - xc;
310 float t7 = iH1Y - yc;
312 float r =
sqrt(t6 * t6 + t7 * t7);
314 int intR = int(r * dr);
315 if (intR < 0 || intR >=
fNofBinsR)
continue;
328 int maxBinR = -1, maxR = -1;
330 for (
unsigned int k = 0; k <
size; k++) {
331 if (
fHistR[k] > maxBinR) {
340 int maxBinXY = -1, maxXY = -1;
342 for (
unsigned int k = 0; k <
size; k++) {
343 if (
fHist[k] > maxBinXY) {
349 if (maxBinXY <
fHTCut)
return;
358 r = (maxR + 0.5f) *
fDr;
359 for (
int j = indmin; j < indmax + 1; j++) {
361 rx =
fData[j].fHit.fX - xc;
362 ry =
fData[j].fHit.fY - yc;
364 dr = fabs(
sqrt(rx * rx + ry * ry) - r);
365 if (dr > 0.9f)
continue;
385 for (
int j = indmin; j < indmax + 1; j++) {
388 rx =
fData[j].fHit.fX - xc;
389 ry =
fData[j].fHit.fY - yc;
392 dr = fabs(
sqrt(rx * rx + ry * ry) - r);
393 if (dr > drCOPCut)
continue;
427 for (
int j = indmin; j < indmax + 1; j++) {
432 float dr = fabs(
sqrt(rx * rx + ry * ry) - ring->
GetRadius());
434 fData[j].fIsUsed =
true;
443 return ring1->GetSelectionNN() > ring2->GetSelectionNN();
445 set<unsigned int> usedHitsAll;
446 vector<unsigned int> goodRingIndex;
447 goodRingIndex.reserve(nofRings);
450 for (
int iRing = 0; iRing < nofRings; iRing++) {
454 bool isGoodRingAll =
true;
455 int nofUsedHitsAll = 0;
456 for (
int iHit = 0; iHit < nofHits; iHit++) {
457 set<unsigned int>::iterator it = usedHitsAll.find(ring->
GetHitId(iHit));
458 if (it != usedHitsAll.end()) {
463 isGoodRingAll =
false;
468 for (
unsigned int iRSet = 0; iRSet < goodRingIndex.size(); iRSet++) {
471 goodRingIndex.push_back(iRing);
472 for (
int iHit = 0; iHit < nofHits; iHit++) {
473 usedHitsAll.insert(ring->
GetHitId(iHit));
480 goodRingIndex.clear();
490 for (
int iHit1 = 0; iHit1 < nofHits1; iHit1++) {
491 unsigned int hitId1 = ring1->
GetHitId(iHit1);
492 for (
int iHit2 = 0; iHit2 < nofHits2; iHit2++) {
493 unsigned int hitId2 = ring2->
GetHitId(iHit2);
494 if (hitId1 != hitId2)
continue;
496 float hitX =
fData[hitIndData].fHit.fX;
497 float hitY =
fData[hitIndData].fHit.fY;
500 float dr1 = fabs(
sqrt(rx1 * rx1 + ry1 * ry1) - ring1->
GetRadius());
504 float dr2 = fabs(
sqrt(rx2 * rx2 + ry2 * ry2) - ring2->
GetRadius());
519 for (
unsigned int i = 0; i <
size; i++) {
520 if (
fData[i].fHit.fId == hitId)
return i;
527 float t1, t2, t3, t4, t5, t6, t8, t9, t10, t11, t14, t16, t19, t21, t41;
533 t5 = t1 - t2 + t3 - t4;
537 t10 = t8 - t1 + t9 - t3;
541 t19 = 1.0f / (t14 * t6 - t16 * t11);
543 *xc = 0.5e0 * (t5 * t6 - t10 * t11) * t19;
544 *yc = 0.5e0 * (t10 * t14 - t5 * t16) * t19;
546 t21 = (
x[0] - *xc) * (
x[0] - *xc);
547 t41 = (
y[0] - *yc) * (
y[0] - *yc);
548 *r =
sqrt(t21 + t41);
Ring finder implementation based on Hough Transform method.
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
Implementation for concrete RICH ring selection algorithm: reject rings using a trained neural net (i...
friend fvec sqrt(const fvec &a)
static constexpr size_t size()
Implementation of RICH hit for ring finder algorithm.
void RemoveHitsAroundRing(int indmin, int indmax, CbmRichRingLight *ring)
Set fIsUsed flag to true for hits attached to the ring.
int GetHitIndexById(unsigned int hitId)
Return hit indez in the internal Array.
vector< vector< unsigned int > > fHitInd
void CalculateRingParameters(float x[], float y[], float *xc, float *yc, float *r)
Calculate circle center and radius.
void SetParameters()
Set parameters of the algorithm.
vector< unsigned short > fHistR
CbmRichRingSelectAnn * fANNSelect
virtual void HoughTransformGroup(unsigned int indmin, unsigned int indmax, int iPart)
void DoFind()
Start point to run algorithm.
void RingSelection()
Ring selection procedure.
vector< CbmRichRingLight * > fFoundRings
unsigned short fNofBinsXY
void FindPeak(int indmin, int indmax)
CbmRichRingFinderHoughImpl()
Standard constructor.
virtual void HoughTransform(unsigned int indmin, unsigned int indmax)
Run HoughTransformGroup for each group of hits.
vector< CbmRichHoughHit > fData
virtual void HoughTransformReconstruction()
Run HT for each hit.
CbmRichRingFitterCOP * fFitCOP
virtual void DefineLocalAreaAndHits(float x0, float y0, int *indmin, int *indmax)
Find hits in a local area.
void ReAssignSharedHits(int ringInd1, int ringInd2)
Reassign shared hits from two rings to only one of the rings.
virtual ~CbmRichRingFinderHoughImpl()
Distructor.
unsigned short fMinNofHitsInArea
vector< unsigned short > fHist
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
virtual void DoFit(CbmRichRingLight *ring)
Inherited from CbmRichRingFitterBase.
float GetSelectionNN() const
int GetNofHits() const
Return number of hits in ring.
unsigned int GetHitId(int ind)
Return hit index in TClonesArray.
bool RemoveHit(int hitId)
Remove hit from the ring.
void AddHit(CbmRichHitLight hit)
Add new hit to the ring.
Implementation for concrete RICH ring selection algorithm: reject rings using a trained neural net (i...
void DoSelect(CbmRichRingLight *ring)
virtual void Init()
Initialize ANN.