Belle II Software  release-08-01-10
HoughPlaneMulti2.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 multi Hough parameter planes (version 2)
11 //-----------------------------------------------------------------------------
12 
13 #ifndef TRGCDCHoughPlaneMulti2_FLAG_
14 #define TRGCDCHoughPlaneMulti2_FLAG_
15 
16 #include "trg/cdc/HoughPlane.h"
17 #include "trg/cdc/HoughPlaneBoolean.h"
18 
19 #ifdef TRGCDC_SHORT_NAMES
20 #define TCHPlaneMulti2 TRGCDCHoughPlaneMulti2
21 #endif
22 
24 #define N_LAYERS 6
25 
26 namespace Belle2 {
34 
35  public:
36 
38  TRGCDCHoughPlaneMulti2(const std::string& name,
40  unsigned nX,
41  float xMin,
42  float xMax,
43  unsigned nY,
44  float yMin,
45  float yMax,
46  unsigned nLayers);
47 
49  virtual ~TRGCDCHoughPlaneMulti2();
50 
51  public:// Selectors
52 
54  unsigned nLayers(void) const;
55 
57  const std::vector<unsigned>& patternId(unsigned cellId) const;
58 
60  const std::vector<unsigned>& patternId(unsigned layer,
61  unsigned cellId) const;
63  void dump(unsigned layerId) const;
64 
66  void dump(const std::string& message = std::string(""),
67  const std::string& prefix = std::string("")) const override;
68 
69  public:// Modifiers
70 
72  void clear(void) override;
73 
75  void clear(unsigned layerId);
76 
78  void clearCells(void);
79 
81  using TRGCDCHoughPlaneBase::vote; // to be checked
83  void vote(float rx,
84  float ry,
85  int charge,
86  unsigned layerId,
87  int weight = 1);
88 
90  // using TRGCDCHoughPlaneBase::vote; // to be checked
92  void vote(unsigned layerId, unsigned localId, int weight = 1);
93 
95  // using TRGCDCHoughPlaneBase::vote; // to be checked
97  void vote(float rx,
98  float ry,
99  unsigned layerId,
100  int weight = 1);
101 
103  using TRGCDCHoughPlane::setEntry; // to be checked
105  unsigned setEntry(unsigned serialId, unsigned layerId, unsigned n);
106 
108  void merge(void);
109 
111  void mergeOuters(void);
112 
114  void preparePatterns(unsigned layerId, unsigned nPatterns);
115 
117  using TRGCDCHoughPlane::registerPattern; // to be checked
119  void registerPattern(unsigned layerId, unsigned id);
120 
122  void finalizePatterns(void);
123 
124  private:
125 
127  unsigned _nLayers;
128 
131 
134 
136  std::vector<unsigned>* _reverse;
137  };
138 
139 //-----------------------------------------------------------------------------
140 
141  inline
142  void
144  {
145  for (unsigned i = 0; i < N_LAYERS; i++)
146  if (_usage[i]) {
147  _layers[i]->clear();
148  _usage[i] = false;
149  }
151  }
152 
153  inline
154  void
156  {
157  for (unsigned i = 0; i < N_LAYERS; i++)
158  if (_usage[i]) {
159  _layers[i]->clear();
160  _usage[i] = false;
161  }
163  }
164 
165  inline
166  void
168  {
169  _layers[a]->clear();
170  _usage[a] = false;
171  }
172 
173  inline
174  void
176  float ry,
177  int charge,
178  unsigned layerId,
179  int weight)
180  {
181  _usage[layerId] = true;
182  _layers[layerId]->vote(rx, ry, charge, weight);
183  }
184 
185  inline
186  void
188  float ry,
189  unsigned layerId,
190  int weight)
191  {
192  _usage[layerId] = true;
193  _layers[layerId]->vote(rx, ry, weight);
194  }
195 
196  inline
197  void
199  {
200  _layers[a]->dump();
201  }
202 
203  inline
204  void
205  TRGCDCHoughPlaneMulti2::vote(unsigned a, unsigned b, int c)
206  {
207  _usage[a] = true;
208  _layers[a]->vote(b, c);
209  }
210 
211  inline
212  void
213  TRGCDCHoughPlaneMulti2::dump(const std::string& a, const std::string& b) const
214  {
215  if (a == "merged") {
217  } else if (a == "region") {
219  } else {
220  for (unsigned i = 0; i < _nLayers; i++) {
221  std::cout << b << name() << " : layer " << i << std::endl;
222  _layers[i]->dump();
223  }
224  std::cout << b << name() << " : merged plane " << std::endl;
226  }
227  }
228 
229  inline
230  void
231  TRGCDCHoughPlaneMulti2::registerPattern(unsigned layerId, unsigned id)
232  {
233  _layers[layerId]->registerPattern(id);
234  }
235 
236  inline
237  const std::vector<unsigned>&
239  unsigned cellId) const
240  {
241  return _layers[layer]->patternId(cellId);
242  }
243 
244  inline
245  void
246  TRGCDCHoughPlaneMulti2::preparePatterns(unsigned layerId, unsigned nPatterns)
247  {
248  _layers[layerId]->preparePatterns(nPatterns);
249  }
250 
251  inline
252  unsigned
254  {
255  return _nLayers;
256  }
257 
258  inline
259  unsigned
261  unsigned layerId,
262  unsigned n)
263  {
264  _usage[layerId] = true;
265  _layers[layerId]->setEntry(serialId, n);
266  return n;
267  }
268 
270 } // namespace Belle2
271 
272 #endif
A class to represent a Hough parameter plane.
A class to represent a Hough parameter plane.
void registerPattern(unsigned id) override
registers a pattern..
Definition: HoughPlane.cc:202
virtual void vote(float rx, float ry, int weight=1)
Voting.
const std::vector< unsigned > & patternId(unsigned cellId) const
returns pattern ID which activates specified cell.
std::vector< unsigned > * _reverse
Pattern ID's for each cell.
TRGCDCHoughPlaneBoolean * _layers[N_LAYERS]
Hough plane for each layer.
void finalizePatterns(void)
finalize patterns.
bool _usage[N_LAYERS]
Used or not.
unsigned setEntry(unsigned serialId, unsigned n) override
Sets entry.
Definition: HoughPlane.h:108
A class to represent a Hough parameter plane.
Definition: HoughPlane.h:30
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 vote(float rx, float ry, int weight=1)
Voring.
void preparePatterns(unsigned layerId, unsigned nPatterns)
allocate memory for patterns.
float xMin(void) const
returns min. of x.
virtual ~TRGCDCHoughPlaneMulti2()
Destructor.
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
unsigned nY(void) const
return # of y bins.
void mergeOuters(void)
Merge outer layers into one.
TRGCDCHoughPlaneMulti2(const std::string &name, const TRGCDCHoughTransformation &transformation, unsigned nX, float xMin, float xMax, unsigned nY, float yMin, float yMax, unsigned nLayers)
Contructor.
float xMax(void) const
returns max. of x.
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 dump(unsigned layerId) const
Dumps debug information.
unsigned serialId(unsigned x, unsigned y) const
returns serial ID for position (x, y).
#define N_LAYERS
number of layers
void merge(void)
Merge layers into one.
float yMax(void) const
returns max. of y.
unsigned nLayers(void) const
returns # of Hough Boolean layers.
const std::vector< unsigned > & patternId(unsigned cellId) const
returns pattern ID which activates specified cell.
void clear(void) override
Clears all entries and regions.
const TRGCDCHoughTransformation & transformation(void) const
returns Hough transformation object.
std::string name(void) const
returns name.
unsigned nX(void) const
returns # of x bins.
void clearCells(void)
Clears entires only.
float yMin(void) const
returns min. of y.
unsigned setEntry(unsigned serialId, unsigned n) override
Sets entry.
Definition: HoughPlane.h:108
Abstract base class for different kinds of events.