CbmRoot
CbmRichRingFinderHough.cxx
Go to the documentation of this file.
1 
10 //#include "CbmRichRingFinderHoughSimd.h"
11 //#include "../../littrack/utils/CbmLitMemoryManagment.h"
12 #include "CbmRichHit.h"
13 #include "CbmRichRing.h"
14 
15 #include "FairLogger.h"
16 #include "TClonesArray.h"
17 #include "TStopwatch.h"
18 
19 #include <iostream>
20 
21 using std::cout;
22 using std::endl;
23 using std::vector;
24 
26  : fNEvent(0), fRingCount(0), fHTImpl(NULL), fUseAnnSelect(true) {
27 #ifdef HOUGH_SERIAL
29 #endif
30 
31 #ifdef HOUGH_SIMD
33 #endif
34 }
35 
38  fHTImpl->Init();
39 }
40 
42 
43 Int_t CbmRichRingFinderHough::DoFind(TClonesArray* rHitArray,
44  TClonesArray* /*rProjArray*/,
45  TClonesArray* rRingArray) {
46  TStopwatch timer;
47  timer.Start();
48  fNEvent++;
49  LOG(info) << "-I- CbmRichRingFinderHough Event/Timeslice no. " << fNEvent;
50 
51  vector<CbmRichHoughHit> UpH;
52  vector<CbmRichHoughHit> DownH;
53  fRingCount = 0;
54 
55  if (NULL == rHitArray) {
56  LOG(error) << "-E- CbmRichRingFinderHough::DoFind: Hit array missing!"
57  << rHitArray;
58  return -1;
59  }
60  const Int_t nhits = rHitArray->GetEntriesFast();
61  if (nhits <= 0) {
62  LOG(error) << "-E- CbmRichRingFinderHough::DoFind: No hits in this event!";
63  return -1;
64  }
65 
66  UpH.reserve(nhits / 2);
67  DownH.reserve(nhits / 2);
68 
69  // convert CbmRichHit to CbmRichHoughHit and
70  // sort hits according to the photodetector (up or down)
71  for (Int_t iHit = 0; iHit < nhits; iHit++) {
72  CbmRichHit* hit = static_cast<CbmRichHit*>(rHitArray->At(iHit));
73  if (hit) {
74  CbmRichHoughHit tempPoint;
75  tempPoint.fHit.fX = hit->GetX();
76  tempPoint.fHit.fY = hit->GetY();
77  tempPoint.fHit.fId = iHit;
78  tempPoint.fX2plusY2 =
79  hit->GetX() * hit->GetX() + hit->GetY() * hit->GetY();
80  tempPoint.fTime = hit->GetTime();
81  tempPoint.fIsUsed = false;
82  if (hit->GetY() >= 0)
83  UpH.push_back(tempPoint);
84  else
85  DownH.push_back(tempPoint);
86  }
87  }
88 
89  timer.Stop();
90  Double_t dt1 = timer.RealTime();
91 
92  timer.Start();
93  LOG(debug) << "-I- CbmRichRingFinderHough nofHits Up:" << UpH.size();
94 
95  fHTImpl->SetData(UpH);
96  fHTImpl->DoFind();
97  if (rRingArray != NULL)
98  AddRingsToOutputArray(rRingArray, rHitArray, fHTImpl->GetFoundRings());
99  //for_each(UpH.begin(), UpH.end(), DeleteObject());
100  UpH.clear();
101 
102  timer.Stop();
103  Double_t dt2 = timer.RealTime();
104 
105  timer.Start();
106  LOG(debug) << "-I- CbmRichRingFinderHough nofHits Down:" << DownH.size();
107  fHTImpl->SetData(DownH);
108  fHTImpl->DoFind();
109  if (rRingArray != NULL)
110  AddRingsToOutputArray(rRingArray, rHitArray, fHTImpl->GetFoundRings());
111  //for_each(DownH.begin(), DownH.end(), DeleteObject());
112  DownH.clear();
113  timer.Stop();
114  Double_t dt3 = timer.RealTime();
115 
116  LOG(info) << "CbmRichRingFinderHough. Number of found rings "
117  << rRingArray->GetEntriesFast();
118 
119  LOG(info) << "time1:" << dt1 << " time2:" << dt2 << " time3:" << dt3
120  << " total:" << dt1 + dt2 + dt3;
121 
122  return 1;
123 }
124 
126  TClonesArray* rRingArray,
127  TClonesArray* rHitArray,
128  const vector<CbmRichRingLight*>& rings) {
129  for (UInt_t iRing = 0; iRing < rings.size(); iRing++) {
130  if (rings[iRing]->GetRecFlag() == -1) continue;
131  CbmRichRing* r = new CbmRichRing();
132  double ringTime = 0.;
133  Int_t ringCounter = 0;
134 
135  for (Int_t iH = 0; iH < rings[iRing]->GetNofHits(); iH++) {
136  Int_t hitId = rings[iRing]->GetHitId(iH);
137  r->AddHit(hitId);
138  CbmRichHit* hit = static_cast<CbmRichHit*>(rHitArray->At(hitId));
139  if (hit != nullptr) {
140  ringCounter++;
141  ringTime += hit->GetTime();
142  }
143  }
144  r->SetTime(ringTime / (double) ringCounter);
145  new ((*rRingArray)[fRingCount]) CbmRichRing(*r);
146  fRingCount++;
147  }
148 }
CbmRichRingFinderHoughImpl.h
Ring finder implementation based on Hough Transform method.
CbmPixelHit::GetX
Double_t GetX() const
Definition: CbmPixelHit.h:83
CbmRichHitLight::fId
unsigned int fId
Definition: CbmRichRingLight.h:36
CbmPixelHit::GetY
Double_t GetY() const
Definition: CbmPixelHit.h:84
CbmRichHoughHit::fX2plusY2
float fX2plusY2
Definition: CbmRichRingFinderData.h:31
CbmRichHoughHit
Implementation of RICH hit for ring finder algorithm.
Definition: CbmRichRingFinderData.h:21
CbmRichRingFinderHoughImpl::Init
void Init()
Definition: CbmRichRingFinderHoughImpl.cxx:98
CbmRichRingFinderHough::DoFind
virtual Int_t DoFind(TClonesArray *rHitArray, TClonesArray *rProjArray, TClonesArray *rRingArray)
Inherited from CbmRichRingFinder.
Definition: CbmRichRingFinderHough.cxx:43
CbmRichRing
Definition: CbmRichRing.h:17
CbmRichHitLight::fX
float fX
Definition: CbmRichRingLight.h:34
CbmRichRing.h
CbmRichRingFinderHough::fNEvent
Int_t fNEvent
Definition: CbmRichRingFinderHough.h:36
CbmRichRingFinderHoughImpl::SetUseAnnSelect
void SetUseAnnSelect(bool use)
Definition: CbmRichRingFinderHoughImpl.h:207
CbmRichRingFinderHough.h
Main class for ring finder based on Hough Transform implementation.
CbmHit::GetTime
Double_t GetTime() const
Definition: CbmHit.h:75
CbmRichRingFinderHough::fUseAnnSelect
bool fUseAnnSelect
Definition: CbmRichRingFinderHough.h:74
CbmRichRingFinderHoughSimd
SIMDized ring finder based on Hough Transform method.
Definition: CbmRichRingFinderHoughSimd.h:34
CbmRichRingFinderHough::fRingCount
Int_t fRingCount
Definition: CbmRichRingFinderHough.h:37
CbmRichRingFinderHoughImpl::SetData
void SetData(const vector< CbmRichHoughHit > &data)
Set array of hits.
Definition: CbmRichRingFinderHoughImpl.h:197
CbmRichRingFinderHough::fHTImpl
CbmRichRingFinderHoughImpl * fHTImpl
Definition: CbmRichRingFinderHough.h:41
CbmRichRingFinderHoughImpl::DoFind
void DoFind()
Start point to run algorithm.
Definition: CbmRichRingFinderHoughImpl.cxx:112
CbmRichRingFinderHough::~CbmRichRingFinderHough
virtual ~CbmRichRingFinderHough()
Destructor.
Definition: CbmRichRingFinderHough.cxx:41
CbmRichRingFinderHough::CbmRichRingFinderHough
CbmRichRingFinderHough()
Standard constructor.
Definition: CbmRichRingFinderHough.cxx:25
CbmRichRingFinderHoughImpl
Ring finder implementation based on Hough Transform method.
Definition: CbmRichRingFinderHoughImpl.h:33
CbmRichHitLight::fY
float fY
Definition: CbmRichRingLight.h:35
CbmRichRing::AddHit
void AddHit(UInt_t pHit)
Definition: CbmRichRing.h:34
CbmRichHoughHit::fIsUsed
bool fIsUsed
Definition: CbmRichRingFinderData.h:33
CbmRichHoughHit::fTime
double fTime
Definition: CbmRichRingFinderData.h:32
CbmRichHit.h
CbmRichRingFinderHough::Init
virtual void Init()
Inherited from CbmRichRingFinder.
Definition: CbmRichRingFinderHough.cxx:36
CbmRichRing::SetTime
void SetTime(Double_t time)
Definition: CbmRichRing.h:70
CbmRichHoughHit::fHit
CbmRichHitLight fHit
Definition: CbmRichRingFinderData.h:30
CbmRichRingFinderHough::AddRingsToOutputArray
void AddRingsToOutputArray(TClonesArray *rRingArray, TClonesArray *rHitArray, const vector< CbmRichRingLight * > &rings)
Add found rings to the output TClonesArray.
Definition: CbmRichRingFinderHough.cxx:125
CbmRichHit
Definition: CbmRichHit.h:19
rings
TClonesArray * rings
Definition: Analyze_matching.h:21
CbmRichRingFinderHoughImpl::GetFoundRings
vector< CbmRichRingLight * > & GetFoundRings()
Return vector of found rings.
Definition: CbmRichRingFinderHoughImpl.h:205