CbmRoot
Loading...
Searching...
No Matches
CbmRichRingFinderHough.cxx
Go to the documentation of this file.
1/* Copyright (C) 2006-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer] , Andrey Lebedev */
4
11
13
15//#include "CbmRichRingFinderHoughSimd.h"
16//#include "../../littrack/utils/CbmLitMemoryManagment.h"
17#include "CbmEvent.h"
18#include "CbmRichHit.h"
19#include "CbmRichRing.h"
20#include "TClonesArray.h"
21#include "TStopwatch.h"
22
23#include <Logger.h>
24
25#include <iostream>
26
27using std::cout;
28using std::endl;
29using std::vector;
30
32{
33#ifdef HOUGH_SERIAL
35#endif
36
37#ifdef HOUGH_SIMD
39#endif
40}
41
43{
44 fHTImpl->SetUseAnnSelect(fUseAnnSelect);
45 fHTImpl->Init();
46}
47
49
50Int_t CbmRichRingFinderHough::DoFind(CbmEvent* event, TClonesArray* rHitArray, TClonesArray* /*rProjArray*/,
51 TClonesArray* rRingArray)
52{
53 TStopwatch timer;
54 timer.Start();
55 fEventNum++;
56
59
60 if (rHitArray == nullptr) {
61 LOG(error) << "CbmRichRingFinderHough::DoFind(): Hit array is nullptr.";
62 return -1;
63 }
64
65 const Int_t nofRichHits = event ? event->GetNofData(ECbmDataType::kRichHit) : rHitArray->GetEntriesFast();
66 if (nofRichHits <= 0) {
67 LOG(debug) << "CbmRichRingFinderHough::DoFind(): No RICH hits in this event.";
68 return -1;
69 }
70
71 if (fUseSubdivide) {
72 UpH.reserve(nofRichHits / 2);
73 DownH.reserve(nofRichHits / 2);
74 }
75 else {
76 UpH.reserve(nofRichHits);
77 }
78
79 // convert CbmRichHit to CbmRichHoughHit and
80 // sort hits according to the photodetector (up or down)
81 for (Int_t iHit = 0; iHit < nofRichHits; iHit++) {
82 Int_t iHitIndex = event ? event->GetIndex(ECbmDataType::kRichHit, iHit) : iHit;
83 CbmRichHit* hit = static_cast<CbmRichHit*>(rHitArray->At(iHitIndex));
84 if (hit != nullptr && !hit->GetIsNoiseNN()) {
85 CbmRichHoughHit tempPoint;
86 tempPoint.fHit.fX = hit->GetX();
87 tempPoint.fHit.fY = hit->GetY();
88 tempPoint.fHit.fId = iHitIndex;
89 tempPoint.fX2plusY2 = hit->GetX() * hit->GetX() + hit->GetY() * hit->GetY();
90 tempPoint.fTime = hit->GetTime();
91 tempPoint.fIsUsed = false;
92 if (hit->GetY() >= 0 || !fUseSubdivide)
93 UpH.push_back(tempPoint);
94 else
95 DownH.push_back(tempPoint);
96 }
97 }
98
99 timer.Stop();
100 Double_t dt1 = timer.RealTime();
101
102 timer.Start();
103
104 fHTImpl->SetData(UpH);
105 fHTImpl->DoFind();
106 if (rRingArray != nullptr) AddRingsToOutputArray(event, rRingArray, rHitArray, fHTImpl->GetFoundRings());
107 //for_each(UpH.begin(), UpH.end(), DeleteObject());
108 UpH.clear();
109
110 timer.Stop();
111 Double_t dt2 = timer.RealTime();
112
113 timer.Start();
114 fHTImpl->SetData(DownH);
115 fHTImpl->DoFind();
116 if (rRingArray != nullptr) AddRingsToOutputArray(event, rRingArray, rHitArray, fHTImpl->GetFoundRings());
117 //for_each(DownH.begin(), DownH.end(), DeleteObject());
118 DownH.clear();
119 timer.Stop();
120 Double_t dt3 = timer.RealTime();
121
122 int nofFoundRings = event ? event->GetNofData(ECbmDataType::kRichRing) : rRingArray->GetEntriesFast();
123 LOG(debug) << "CbmRichRingFinderHough::DoFind(): Event:" << fEventNum << " hits:" << nofRichHits
124 << " rings:" << nofFoundRings << " ringsInTS:" << rRingArray->GetEntriesFast()
125 << " Time:" << dt1 + dt2 + dt3;
126
127 return 1;
128}
129
130void CbmRichRingFinderHough::AddRingsToOutputArray(CbmEvent* event, TClonesArray* rRingArray, TClonesArray* rHitArray,
132{
133
134 for (UInt_t iRing = 0; iRing < rings.size(); iRing++) {
135 if (rings[iRing]->GetRecFlag() == -1) continue;
136 CbmRichRing* r = new CbmRichRing();
137 double ringTime = 0.;
138 Int_t ringCounter = 0;
139
140 for (Int_t iHit = 0; iHit < rings[iRing]->GetNofHits(); iHit++) {
141 Int_t hitId = rings[iRing]->GetHitId(iHit);
142 r->AddHit(hitId);
143 CbmRichHit* hit = static_cast<CbmRichHit*>(rHitArray->At(hitId));
144 if (hit != nullptr) {
145 ringCounter++;
146 ringTime += hit->GetTime();
147 }
148 }
149 r->SetTime(ringTime / (double) ringCounter);
150 int nofRings = rRingArray->GetEntriesFast();
151 new ((*rRingArray)[nofRings]) CbmRichRing(*r);
152 if (event != nullptr) event->AddData(ECbmDataType::kRichRing, nofRings);
153 }
154}
TClonesArray * rings
Ring finder implementation based on Hough Transform method.
Main class for ring finder based on Hough Transform implementation.
int Int_t
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
double GetTime() const
Definition CbmHit.h:79
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
bool GetIsNoiseNN() const
Definition CbmRichHit.h:68
Implementation of RICH hit for ring finder algorithm.
Ring finder implementation based on Hough Transform method.
SIMDized ring finder based on Hough Transform method.
virtual void Init()
Inherited from CbmRichRingFinder.
CbmRichRingFinderHough()
Standard constructor.
virtual ~CbmRichRingFinderHough()
Destructor.
void AddRingsToOutputArray(CbmEvent *event, TClonesArray *rRingArray, TClonesArray *rHitArray, const vector< CbmRichRingLight * > &rings)
Add found rings to the output TClonesArray.
CbmRichRingFinderHoughImpl * fHTImpl
virtual Int_t DoFind(CbmEvent *event, TClonesArray *rHitArray, TClonesArray *rProjArray, TClonesArray *rRingArray)
Inherited from CbmRichRingFinder.
void AddHit(uint32_t pHit)
Definition CbmRichRing.h:31
void SetTime(double time)
Definition CbmRichRing.h:67