Belle II Software development
HoughPlane.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9//-----------------------------------------------------------------------------
10// Description : A class to represent a Hough parameter plane
11//-----------------------------------------------------------------------------
12
13#ifndef TRGCDCHoughPlane_FLAG_
14#define TRGCDCHoughPlane_FLAG_
15
16#include <string.h>
17#include "trg/cdc/HoughPlaneBase.h"
18
19#ifdef TRGCDC_SHORT_NAMES
20#define TCHPlane TRGCDCHoughPlane
21#endif
22
23namespace Belle2 {
31
32 public:
33
35 TRGCDCHoughPlane(const std::string& name,
37 unsigned nX,
38 float xMin,
39 float xMax,
40 unsigned nY,
41 float yMin,
42 float yMax);
43
45 virtual ~TRGCDCHoughPlane();
46
49
52
53 public:// Selectors
54
56 unsigned entry(unsigned id) const override;
57
59 unsigned entry(unsigned x, unsigned y) const override;
60
62 int maxEntry(void) const override;
63
65 virtual unsigned nActiveCellsInPattern(void) const;
66
67 public:// Modifiers
68
70 unsigned setEntry(unsigned serialId, unsigned n) override;
71
73 // cppcheck-suppress virtualCallInConstructor
74 void clear(void) override;
75
77 void clearCells(void);
78
80 void registerPattern(unsigned id) override;
81
83 virtual void voteByPattern(float xOffset, int weight = 1);
84
85 protected:
86
88 void add(unsigned cellId, int weight) override;
89
90 private:
91
93 int* const _cell;
94
96 unsigned* _patterns;
97
99 unsigned _nPatterns;
100
101 friend class TRGCDCHoughPlaneMulti;
102 };
103
104//-----------------------------------------------------------------------------
105
106 inline
107 unsigned
108 TRGCDCHoughPlane::setEntry(unsigned serialId, unsigned n)
109 {
110 return _cell[serialId] = n;
111 }
112
113 inline
114 void
116 {
117 memset(_cell, 0, nX() * nY() * sizeof(int));
119 }
120
121 inline
122 void
124 {
125 memset(_cell, 0, nX() * nY() * sizeof(int));
126 }
127
128 inline
129 unsigned
130 TRGCDCHoughPlane::entry(unsigned id) const
131 {
132 if (id < nX() * nY()) return _cell[id];
133 return 0;
134 }
135
136 inline
137 unsigned
138 TRGCDCHoughPlane::entry(unsigned x, unsigned y) const
139 {
140 if (x < nX())
141 if (y < nY())
142 return _cell[nY() * x + y];
143 return 0;
144 }
145
146 inline
147 int
149 {
150 int m = 0;
151 for (unsigned i = 0; i < nX() * nY(); i++)
152 if (_cell[i] > m)
153 m = _cell[i];
154 return m;
155 }
156
157 inline
158 unsigned
160 {
161 return _nPatterns;
162 }
163
164 inline
165 void
166 TRGCDCHoughPlane::add(unsigned a, int w)
167 {
168 _cell[a] += w;
169 if (_cell[a] < 0)
170 _cell[a] = 0;
171 }
172
174} // namespace Belle2
175
176#endif
A class to represent a Hough parameter plane.
A class to represent a Hough parameter plane.
A class to represent a Hough parameter plane.
Definition: HoughPlane.h:30
TRGCDCHoughPlane(TRGCDCHoughPlane &)=delete
Copy construtor, deleted.
unsigned * _patterns
Curve patterns.
Definition: HoughPlane.h:96
int *const _cell
Counters.
Definition: HoughPlane.h:93
unsigned _nPatterns
# of curve patterns.
Definition: HoughPlane.h:99
TRGCDCHoughPlane & operator=(TRGCDCHoughPlane &)=delete
Assignment operator, deleted.
An abstract class to represent a Hough transformation.
void registerPattern(unsigned id) override
Registers a pattern on a Hough plane with (r, phi=0).
Definition: HoughPlane.cc:202
virtual void clear(void)=0
Clears all entries.
float xMin(void) const
returns min. of x.
unsigned nY(void) const
return # of y bins.
void add(unsigned cellId, int weight) override
Add to a cell.
Definition: HoughPlane.h:166
float xMax(void) const
returns max. of x.
virtual unsigned nActiveCellsInPattern(void) const
returns # of active cells in the pattern.
Definition: HoughPlane.h:159
void id(unsigned serialId, unsigned &x, unsigned &y) const
returns x and y for serialID.
unsigned serialId(unsigned x, unsigned y) const
returns serial ID for position (x, y).
int maxEntry(void) const override
returns max. entry in a plane.
Definition: HoughPlane.h:148
float yMax(void) const
returns max. of y.
void clear(void) override
clear all entries.
Definition: HoughPlane.h:115
const TRGCDCHoughTransformation & transformation(void) const
returns Hough transformation object.
virtual void voteByPattern(float xOffset, int weight=1)
Votes using a pattern.
Definition: HoughPlane.cc:224
std::string name(void) const
returns name.
unsigned entry(unsigned id) const override
returns entry in a cell.
Definition: HoughPlane.h:130
unsigned nX(void) const
returns # of x bins.
void clearCells(void)
Clears entires only.
Definition: HoughPlane.h:123
float yMin(void) const
returns min. of y.
virtual ~TRGCDCHoughPlane()
Destructor.
Definition: HoughPlane.cc:40
unsigned setEntry(unsigned serialId, unsigned n) override
Sets entry.
Definition: HoughPlane.h:108
Abstract base class for different kinds of events.