/
CbmRichRingFinderHoughImpl.h
233 lines (195 loc) · 5.92 KB
/
CbmRichRingFinderHoughImpl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/**
* \file CbmRichRingFinderHoughImpl.h
*
* \brief Ring finder implementation based on Hough Transform method.
*
* \author Semen Lebedev
* \date 2008
**/
#ifndef CBM_RICH_RING_FINDER_HOUGH_IMPL
#define CBM_RICH_RING_FINDER_HOUGH_IMPL
#include "CbmRichRingLight.h"
#include "CbmRichRingFinderData.h"
#include <vector>
#include <map>
using std::vector;
class CbmRichRingFitterCOP;
class CbmRichRingSelectAnn;
/**
* \class CbmRichRingFinderHoughImpl
*
* \brief Ring finder implementation based on Hough Transform method.
*
* \author Semen Lebedev
* \date 2008
**/
class CbmRichRingFinderHoughImpl
{
protected:
static const unsigned short MAX_NOF_HITS = 65000; // maximum number of hits in RICH detector
// parameters of the Hough Transform algorithm
unsigned short fNofParts; // number of groups of hits for HT
float fMaxDistance; // maximum distance between two hits
float fMinDistance; // minimum distance between two hits
float fMinDistanceSq; // = fMinDistance*fMinDistance
float fMaxDistanceSq; // = fMaxDistance*fMaxDistance
float fMinRadius; // minimum radius of the ring
float fMaxRadius; // maximum radius of the ring
float fDx; // x bin width of the ring center histogram
float fDy; // y bin width of the ring center histogram
float fDr; // width of the ring radius histogram
unsigned short fNofBinsX; // number of bins in X direction
unsigned short fNofBinsY; // number of bins in Y direction
unsigned short fNofBinsXY; // fNofBinsX*fNofBinsY
unsigned short fHTCut; // cut number of entries in maximum bin of XY histogram
unsigned short fNofBinsR;// number of bins in radius histogram
unsigned short fHTCutR; // cut number of entries in maximum bin of Radius histogram
unsigned short fMinNofHitsInArea; // minimum number of hits in the local area
float fRmsCoeffEl;
float fMaxCutEl;
float fRmsCoeffCOP;
float fMaxCutCOP;
float fAnnCut; //remove found hits only for good quality rings
float fUsedHitsAllCut; // percent of used hits
float fCurMinX; // current minimum X position of the local area
float fCurMinY; // current minimum Y position of the local area
vector<CbmRichHoughHit> fData; // Rich hits
vector<unsigned short> fHist; // XY histogram
vector<unsigned short> fHistR; // Radius histogram
vector< vector<unsigned short> > fHitInd; // store hit indexes for different group of hits
vector<CbmRichRingLight*> fFoundRings; // collect found rings
CbmRichRingFitterCOP* fFitCOP; // COP ring fitter
CbmRichRingSelectAnn* fANNSelect; // ANN selection criteria
public:
/**
* \brief Standard constructor.
*/
CbmRichRingFinderHoughImpl ();
/**
* \brief Distructor.
*/
virtual ~CbmRichRingFinderHoughImpl();
/**
* \brief Set parameters of the algorithm.
*/
void SetParameters();
/**
* \brief Calculate circle center and radius.
* \param[in] x[] Array of 3 X coordinates.
* @param[in] y[] Array of 3 Y coordinates.
* @param[out] xc X coordinate of the ring center.
* @param[out] yc Y coordinate of the ring center.
* @param[out] r Ring radius.
*/
void CalculateRingParameters(
float x[],
float y[],
float *xc,
float *yc,
float *r);
/**
* \brief Run HT for each hit.
*/
virtual void HoughTransformReconstruction();
/**
* \brief Find hits in a local area.
* \param[in] x0 X coordinate of the local area center.
* \param[in] y0 Y coordinate of the local area center.
* \param[out] indmin Minimum index of the hit in local area.
* \param[out] indmax Maximum index of the hit in local area.
*/
virtual void DefineLocalAreaAndHits(
float x0,
float y0,
int *indmin,
int *indmax);
/**
* \brief Run HoughTransformGroup for each group of hits.
* \param[in] indmin Minimum index of the hit in local area.
* \param[in] indmax Maximum index of the hit in local area.
*/
virtual void HoughTransform(
unsigned short indmin,
unsigned short indmax);
/**
* \brief Main procedure for Hough Transform.
* \param[in] indmin Minimum index of the hit in local area.
* \param[in] indmax Maximum index of the hit in local area.
* \param[in] iPart Index of the hit group.
*/
virtual void HoughTransformGroup(
unsigned short indmin,
unsigned short indmax,
int iPart);
/**
* \brief Find peak in the HT histograms.
* \param[in] indmin Minimum index of the hit in local area.
* \param[in] indmax Maximum index of the hit in local area.
*/
void FindPeak(
int indmin,
int indmax);
/**
* \brief Ring selection procedure.
*/
void RingSelection();
/**
* \brief Reassign shared hits from two rings to only one of the rings.
* \param[in,out] ringInd1 Index of the first ring.
* \param[in,out] ringInd2 Index of the second ring.
*/
void ReAssignSharedHits(
int ringInd1,
int ringInd2);
/**
* \brief Return hit indez in the internal Array.
* \param[in] hitInd Index in TClonesArray.
*/
int GetHitIndex(
unsigned short hitInd);
/**
* \brief Set fIsUsed flag to true for hits attached to the ring.
* \param[in] indmin Minimum index of the hit in local area.
* \param[in] indmax Maximum index of the hit in local area.
* \param[in] ring Found ring.
*/
void RemoveHitsAroundRing(
int indmin,
int indmax,
CbmRichRingLight* ring);
/**
* Initialize algorithm parameters.
*/
void Init();
/**
* \brief Start point to run algorithm.
*/
void DoFind();
/**
* \brief Set array of hits.
* \param[in] data Array of hits.
*/
void SetData(
const vector<CbmRichHoughHit>& data)
{
fData.clear();
fData = data;
}
/**
* \brief Return vector of found rings.
*/
vector<CbmRichRingLight*>& GetFoundRings()
{
return fFoundRings;
}
private:
/**
* \brief Copy constructor.
*/
CbmRichRingFinderHoughImpl(const CbmRichRingFinderHoughImpl&);
/**
* \brief Assignment operator.
*/
CbmRichRingFinderHoughImpl& operator=(const CbmRichRingFinderHoughImpl&);
};
#endif