Belle II Software  release-05-01-25
HoughPlane.h
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : HoughPlane.h
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to represent a Hough parameter plane
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #ifndef TRGCDCHoughPlane_FLAG_
15 #define TRGCDCHoughPlane_FLAG_
16 
17 #include <string.h>
18 #include "trg/cdc/HoughPlaneBase.h"
19 
20 #ifdef TRGCDC_SHORT_NAMES
21 #define TCHPlane TRGCDCHoughPlane
22 #endif
23 
24 namespace Belle2 {
30  class TRGCDCHoughPlane : public TRGCDCHoughPlaneBase {
32 
33  public:
34 
36  TRGCDCHoughPlane(const std::string& name,
37  const TRGCDCHoughTransformation& transformation,
38  unsigned nX,
39  float xMin,
40  float xMax,
41  unsigned nY,
42  float yMin,
43  float yMax);
44 
46  virtual ~TRGCDCHoughPlane();
47 
48  public:// Selectors
49 
51  unsigned entry(unsigned id) const override;
52 
54  unsigned entry(unsigned x, unsigned y) const override;
55 
57  int maxEntry(void) const override;
58 
60  virtual unsigned nActiveCellsInPattern(void) const;
61 
62  public:// Modifiers
63 
65  unsigned setEntry(unsigned serialId, unsigned n) override;
66 
68  void clear(void) override;
69 
71  void clearCells(void);
72 
74  void registerPattern(unsigned id) override;
75 
77  virtual void voteByPattern(float xOffset, int weight = 1);
78 
79  protected:
80 
82  void add(unsigned cellId, int weight) override;
83 
84  private:
85 
87  int* const _cell;
88 
90  unsigned* _patterns;
91 
93  unsigned _nPatterns;
94 
95  friend class TRGCDCHoughPlaneMulti;
96  };
97 
98 //-----------------------------------------------------------------------------
99 
100  inline
101  unsigned
102  TRGCDCHoughPlane::setEntry(unsigned serialId, unsigned n)
103  {
104  return _cell[serialId] = n;
105  }
106 
107  inline
108  void
110  {
111  memset(_cell, 0, nX() * nY() * sizeof(int));
113  }
114 
115  inline
116  void
118  {
119  memset(_cell, 0, nX() * nY() * sizeof(int));
120  }
121 
122  inline
123  unsigned
124  TRGCDCHoughPlane::entry(unsigned id) const
125  {
126  if (id < nX() * nY()) return _cell[id];
127  return 0;
128  }
129 
130  inline
131  unsigned
132  TRGCDCHoughPlane::entry(unsigned x, unsigned y) const
133  {
134  if (x < nX())
135  if (y < nY())
136  return _cell[nY() * x + y];
137  return 0;
138  }
139 
140  inline
141  int
143  {
144  int m = 0;
145  for (unsigned i = 0; i < nX() * nY(); i++)
146  if (_cell[i] > m)
147  m = _cell[i];
148  return m;
149  }
150 
151  inline
152  unsigned
154  {
155  return _nPatterns;
156  }
157 
158  inline
159  void
160  TRGCDCHoughPlane::add(unsigned a, int w)
161  {
162  _cell[a] += w;
163  if (_cell[a] < 0)
164  _cell[a] = 0;
165  }
166 
168 } // namespace Belle2
169 
170 #endif
Belle2::TRGCDCHoughPlane::_patterns
unsigned * _patterns
Curve patterns.
Definition: HoughPlane.h:90
Belle2::TRGCDCHoughPlaneMulti
A class to represent a Hough parameter plane.
Definition: HoughPlaneMulti.h:34
Belle2::TRGCDCHoughPlane::clear
void clear(void) override
clear all entries.
Definition: HoughPlane.h:109
Belle2::TRGCDCHoughPlane::voteByPattern
virtual void voteByPattern(float xOffset, int weight=1)
Votes using a pattern.
Definition: HoughPlane.cc:225
Belle2::TRGCDCHoughPlane::maxEntry
int maxEntry(void) const override
returns max. entry in a plane.
Definition: HoughPlane.h:142
Belle2::TRGCDCHoughPlane::~TRGCDCHoughPlane
virtual ~TRGCDCHoughPlane()
Destructor.
Definition: HoughPlane.cc:41
Belle2::TRGCDCHoughPlaneBase::yMax
float yMax(void) const
returns max. of y.
Definition: HoughPlaneBase.h:320
Belle2::TRGCDCHoughPlaneBase::serialId
unsigned serialId(unsigned x, unsigned y) const
returns serial ID for position (x, y).
Definition: HoughPlaneBase.h:343
Belle2::TRGCDCHoughPlaneBase::name
std::string name(void) const
returns name.
Definition: HoughPlaneBase.h:244
Belle2::TRGCDCHoughPlaneBase::id
void id(unsigned serialId, unsigned &x, unsigned &y) const
returns x and y for serialID.
Definition: HoughPlaneBase.h:484
Belle2::TRGCDCHoughPlane::setEntry
unsigned setEntry(unsigned serialId, unsigned n) override
Sets entry.
Definition: HoughPlane.h:102
Belle2::TRGCDCHoughPlane::TRGCDCHoughPlane
TRGCDCHoughPlane(const std::string &name, const TRGCDCHoughTransformation &transformation, unsigned nX, float xMin, float xMax, unsigned nY, float yMin, float yMax)
Contructor.
Definition: HoughPlane.cc:24
Belle2::TRGCDCHoughPlane::add
void add(unsigned cellId, int weight) override
Add to a cell.
Definition: HoughPlane.h:160
Belle2::TRGCDCHoughPlaneBase::nY
unsigned nY(void) const
return # of y bins.
Definition: HoughPlaneBase.h:297
Belle2::TRGCDCHoughPlaneBase::clear
virtual void clear(void)=0
Clears all entries.
Definition: HoughPlaneBase.h:500
Belle2::TRGCDCHoughPlane::entry
unsigned entry(unsigned id) const override
returns entry in a cell.
Definition: HoughPlane.h:124
Belle2::TRGCDCHoughPlane::_nPatterns
unsigned _nPatterns
# of curve patterns.
Definition: HoughPlane.h:93
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGCDCHoughPlane::registerPattern
void registerPattern(unsigned id) override
Registers a pattern on a Hough plane with (r, phi=0).
Definition: HoughPlane.cc:203
Belle2::TRGCDCHoughPlaneBase::transformation
const TRGCDCHoughTransformation & transformation(void) const
returns Hough transformation object.
Definition: HoughPlaneBase.h:523
Belle2::TRGCDCHoughPlane::nActiveCellsInPattern
virtual unsigned nActiveCellsInPattern(void) const
returns # of active cells in the pattern.
Definition: HoughPlane.h:153
Belle2::TRGCDCHoughPlaneBase::xMin
float xMin(void) const
returns min. of x.
Definition: HoughPlaneBase.h:258
Belle2::TRGCDCHoughPlaneBase::xMax
float xMax(void) const
returns max. of x.
Definition: HoughPlaneBase.h:274
Belle2::TRGCDCHoughPlane::clearCells
void clearCells(void)
Clears entires only.
Definition: HoughPlane.h:117
Belle2::TRGCDCHoughPlaneBase::nX
unsigned nX(void) const
returns # of x bins.
Definition: HoughPlaneBase.h:251
Belle2::TRGCDCHoughPlaneBase::yMin
float yMin(void) const
returns min. of y.
Definition: HoughPlaneBase.h:304
Belle2::TRGCDCHoughPlane::_cell
int *const _cell
Counters.
Definition: HoughPlane.h:87