14#define TRGCDC_SHORT_NAMES
17#include "trg/cdc/HoughPlaneBoolean.h"
37 _cell(new unsigned[_n]),
70 for (
unsigned i = 0; i <
nX(); i++) {
71 const float x0 =
xSize() * float(i);
73 float charge = r.cross(center).z();
74 if (targetCharge != 0)
75 if (targetCharge *
charge > 0)
79 const float x1 =
xSize() * float(i + 1);
88 if ((y0 == 0) && (y1 == 0))
90 else if ((y0 >
yMax()) && (y1 >
yMax()))
92 else if ((y0 <
yMin()) && (y1 <
yMin()))
96 if ((y0 == 0) && (y1 != 0))
98 else if ((y0 != 0) && (y1 == 0))
128 for (
unsigned j = (
unsigned) iY0; j < (unsigned)(iY1 + 1); j++) {
129 const unsigned k = i *
nY() + j;
130 const unsigned b0 = k / 32;
131 const unsigned b1 = k % 32;
133 _cell[b0] |= (1 << b1);
135 _cell[b0] &= (~(1 << b1));
150 for (
unsigned i = 0; i <
nX(); i++) {
151 const float x0 =
xSize() * float(i);
153 float charge = r.cross(phi).z();
154 if (targetCharge != 0)
155 if (targetCharge *
charge > 0)
159 const float x1 =
xSize() * float(i + 1);
169 if (iY0 >= (
int)
nY())
continue;
172 if (iY1 >= (
int)
nY())
continue;
186 if (iY1 < 0)
continue;
187 if (iY0 >= (
int)
nY())
continue;
190 if (iY0 < 0) iY0 = 0;
191 if (iY0 >= (
int)
nY()) iY0 =
nY() - 1;
193 if (iY1 >= (
int)
nY()) iY1 =
nY() - 1;
196 for (
unsigned j = (
unsigned) iY0; j < (unsigned)(iY1 + 1); j++) {
197 const unsigned k = i *
nY() + j;
198 const unsigned b0 = k / 32;
199 const unsigned b1 = k % 32;
201 _cell[b0] |= (1 << b1);
203 _cell[b0] &= (~(1 << b1));
214 std::cout <<
"TRGCDCHoughPlaneBoolean::registerPattern !!! "
215 <<
"a pattern(id=" <<
id <<
") was already registered"
220 std::cout <<
"TRGCDCHoughPlaneBoolean::registerPattern !!! "
221 <<
"given id(" <<
id <<
") is over range(" <<
_nPatterns <<
")"
225 const unsigned n =
nX() *
nY();
228 unsigned nActive = 0;
229 for (
unsigned i = 0; i < n; i++) {
230 const unsigned j = i / 32;
231 const unsigned k = i % 32;
232 if ((
_cell[j] >> k) & 1) {
244 for (
unsigned i = 0; i < n; i++) {
245 const unsigned j = i / 32;
246 const unsigned k = i % 32;
247 if ((
_cell[j] >> k) & 1) {
258 std::cout <<
"TRGCDCHoughPlaneBoolean::preparePatterns !!! "
259 <<
"patterns were already allocated" << std::endl;
274 for (
unsigned i = 0; i < n; i++) {
A class to represent a Hough parameter plane.
unsigned ** _patterns
patterns
unsigned _nPatterns
number of patterns
unsigned *const _cell
cell
std::vector< unsigned > * _reverse
Pattern ID's for each cell.
unsigned * _nActive
number of active cells
void registerPattern(unsigned id) override
registers a pattern..
float ySize(void) const
returns size of y bin.
void voteUsedInTrasan(float rx, float ry, float charge, int weight=1)
Votes with charge decision.
unsigned nY(void) const
return # of y bins.
void add(unsigned cellId, int weight) override
Add to a cell.
void preparePatterns(unsigned nPatterns)
allocate memory for patterns.
void vote(float rx, float ry, int weight=1) override
Votes.
float charge(void) const
returns charge for this plane.
void id(unsigned serialId, unsigned &x, unsigned &y) const
returns x and y for serialID.
float yMax(void) const
returns max. of y.
TRGCDCHoughPlaneBoolean(const std::string &name, const TRGCDCHoughTransformation &transformation, unsigned nX, float xMin, float xMax, unsigned nY, float yMin, float yMax)
Contructor.
const std::vector< unsigned > & patternId(unsigned cellId) const
returns pattern ID which activates specified cell.
void clear(void) override
clear all entries.
const TRGCDCHoughTransformation & transformation(void) const
returns Hough transformation object.
float xSize(void) const
returns size of x bin.
unsigned nX(void) const
returns # of x bins.
float yMin(void) const
returns min. of y.
virtual ~TRGCDCHoughPlaneBoolean()
Destructor.
Abstract base class for different kinds of events.