Belle II Software  release-05-02-19
HoughPlaneMulti2.h
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : HoughPlaneMulti2.h
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to represent multi Hough parameter planes (version 2)
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #ifndef TRGCDCHoughPlaneMulti2_FLAG_
15 #define TRGCDCHoughPlaneMulti2_FLAG_
16 
17 #include "trg/cdc/HoughPlane.h"
18 #include "trg/cdc/HoughPlaneBoolean.h"
19 
20 #ifdef TRGCDC_SHORT_NAMES
21 #define TCHPlaneMulti2 TRGCDCHoughPlaneMulti2
22 #endif
23 
25 #define N_LAYERS 6
26 
27 namespace Belle2 {
33  class TRGCDCHoughPlaneMulti2 : public TRGCDCHoughPlane {
35 
36  public:
37 
39  TRGCDCHoughPlaneMulti2(const std::string& name,
40  const TRGCDCHoughTransformation& transformation,
41  unsigned nX,
42  float xMin,
43  float xMax,
44  unsigned nY,
45  float yMin,
46  float yMax,
47  unsigned nLayers);
48 
50  virtual ~TRGCDCHoughPlaneMulti2();
51 
52  public:// Selectors
53 
55  unsigned nLayers(void) const;
56 
58  const std::vector<unsigned>& patternId(unsigned cellId) const;
59 
61  const std::vector<unsigned>& patternId(unsigned layer,
62  unsigned cellId) const;
64  void dump(unsigned layerId) const;
65 
67  void dump(const std::string& message = std::string(""),
68  const std::string& prefix = std::string("")) const override;
69 
70  public:// Modifiers
71 
73  void clear(void) override;
74 
76  void clear(unsigned layerId);
77 
79  void clearCells(void);
80 
82  using TRGCDCHoughPlaneBase::vote; // to be checked
84  void vote(float rx,
85  float ry,
86  int charge,
87  unsigned layerId,
88  int weight = 1);
89 
91  // using TRGCDCHoughPlaneBase::vote; // to be checked
93  void vote(unsigned layerId, unsigned localId, int weight = 1);
94 
96  // using TRGCDCHoughPlaneBase::vote; // to be checked
98  void vote(float rx,
99  float ry,
100  unsigned layerId,
101  int weight = 1);
102 
104  using TRGCDCHoughPlane::setEntry; // to be checked
106  unsigned setEntry(unsigned serialId, unsigned layerId, unsigned n);
107 
109  void merge(void);
110 
112  void mergeOuters(void);
113 
115  void preparePatterns(unsigned layerId, unsigned nPatterns);
116 
118  using TRGCDCHoughPlane::registerPattern; // to be checked
120  void registerPattern(unsigned layerId, unsigned id);
121 
123  void finalizePatterns(void);
124 
125  private:
126 
128  unsigned _nLayers;
129 
132 
135 
137  std::vector<unsigned>* _reverse;
138  };
139 
140 //-----------------------------------------------------------------------------
141 
142  inline
143  void
145  {
146  for (unsigned i = 0; i < N_LAYERS; i++)
147  if (_usage[i]) {
148  _layers[i]->clear();
149  _usage[i] = false;
150  }
152  }
153 
154  inline
155  void
157  {
158  for (unsigned i = 0; i < N_LAYERS; i++)
159  if (_usage[i]) {
160  _layers[i]->clear();
161  _usage[i] = false;
162  }
164  }
165 
166  inline
167  void
169  {
170  _layers[a]->clear();
171  _usage[a] = false;
172  }
173 
174  inline
175  void
177  float ry,
178  int charge,
179  unsigned layerId,
180  int weight)
181  {
182  _usage[layerId] = true;
183  _layers[layerId]->vote(rx, ry, charge, weight);
184  }
185 
186  inline
187  void
189  float ry,
190  unsigned layerId,
191  int weight)
192  {
193  _usage[layerId] = true;
194  _layers[layerId]->vote(rx, ry, weight);
195  }
196 
197  inline
198  void
200  {
201  _layers[a]->dump();
202  }
203 
204  inline
205  void
206  TRGCDCHoughPlaneMulti2::vote(unsigned a, unsigned b, int c)
207  {
208  _usage[a] = true;
209  _layers[a]->vote(b, c);
210  }
211 
212  inline
213  void
214  TRGCDCHoughPlaneMulti2::dump(const std::string& a, const std::string& b) const
215  {
216  if (a == "merged") {
218  } else if (a == "region") {
220  } else {
221  for (unsigned i = 0; i < _nLayers; i++) {
222  std::cout << b << name() << " : layer " << i << std::endl;
223  _layers[i]->dump();
224  }
225  std::cout << b << name() << " : merged plane " << std::endl;
227  }
228  }
229 
230  inline
231  void
232  TRGCDCHoughPlaneMulti2::registerPattern(unsigned layerId, unsigned id)
233  {
234  _layers[layerId]->registerPattern(id);
235  }
236 
237  inline
238  const std::vector<unsigned>&
240  unsigned cellId) const
241  {
242  return _layers[layer]->patternId(cellId);
243  }
244 
245  inline
246  void
247  TRGCDCHoughPlaneMulti2::preparePatterns(unsigned layerId, unsigned nPatterns)
248  {
249  _layers[layerId]->preparePatterns(nPatterns);
250  }
251 
252  inline
253  unsigned
255  {
256  return _nLayers;
257  }
258 
259  inline
260  unsigned
262  unsigned layerId,
263  unsigned n)
264  {
265  _usage[layerId] = true;
266  _layers[layerId]->setEntry(serialId, n);
267  return n;
268  }
269 
271 } // namespace Belle2
272 
273 #endif
Belle2::TRGCDCHoughPlaneMulti2::~TRGCDCHoughPlaneMulti2
virtual ~TRGCDCHoughPlaneMulti2()
Destructor.
Definition: HoughPlaneMulti2.cc:59
Belle2::TRGCDCHoughPlaneBase::dump
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: HoughPlaneBase.cc:224
Belle2::TRGCDCHoughPlaneMulti2::clear
void clear(void) override
Clears all entries and regions.
Definition: HoughPlaneMulti2.h:144
Belle2::TRGCDCHoughPlaneMulti2::patternId
const std::vector< unsigned > & patternId(unsigned cellId) const
returns pattern ID which activates specified cell.
Belle2::TRGCDCHoughPlaneMulti2::nLayers
unsigned nLayers(void) const
returns # of Hough Boolean layers.
Definition: HoughPlaneMulti2.h:254
Belle2::TRGCDCHoughPlaneBase::yMax
float yMax(void) const
returns max. of y.
Definition: HoughPlaneBase.h:320
Belle2::TRGCDCHoughPlaneBoolean::vote
void vote(float rx, float ry, int weight=1) override
Votes.
Definition: HoughPlaneBoolean.h:151
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::charge
float charge(void) const
returns charge for this plane.
Definition: HoughPlaneBase.h:230
Belle2::TRGCDCHoughPlane::setEntry
unsigned setEntry(unsigned serialId, unsigned n) override
Sets entry.
Definition: HoughPlane.h:102
Belle2::TRGCDCHoughPlaneBase::nY
unsigned nY(void) const
return # of y bins.
Definition: HoughPlaneBase.h:297
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGCDCHoughPlaneMulti2::dump
void dump(unsigned layerId) const
Dumps debug information.
Definition: HoughPlaneMulti2.h:199
Belle2::TRGCDCHoughPlaneMulti2::_nLayers
unsigned _nLayers
# of layers.
Definition: HoughPlaneMulti2.h:128
Belle2::TRGCDCHoughPlaneMulti2::merge
void merge(void)
Merge layers into one.
Definition: HoughPlaneMulti2.cc:66
N_LAYERS
#define N_LAYERS
number of layers
Definition: HoughPlaneMulti.h:31
Belle2::TRGCDCHoughPlaneMulti2::_layers
TRGCDCHoughPlaneBoolean * _layers[N_LAYERS]
Hough plane for each layer.
Definition: HoughPlaneMulti2.h:131
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::TRGCDCHoughPlaneBase::xMin
float xMin(void) const
returns min. of x.
Definition: HoughPlaneBase.h:258
Belle2::TRGCDCHoughPlaneBoolean::preparePatterns
void preparePatterns(unsigned nPatterns)
allocate memory for patterns.
Definition: HoughPlaneBoolean.cc:256
Belle2::TRGCDCHoughPlaneMulti2::setEntry
unsigned setEntry(unsigned serialId, unsigned layerId, unsigned n)
Sets entry.
Definition: HoughPlaneMulti2.h:261
Belle2::TRGCDCHoughPlaneBase::xMax
float xMax(void) const
returns max. of x.
Definition: HoughPlaneBase.h:274
Belle2::TRGCDCHoughPlaneMulti2::clearCells
void clearCells(void)
Clears entires only.
Definition: HoughPlaneMulti2.h:156
Belle2::TRGCDCHoughPlaneMulti2::_reverse
std::vector< unsigned > * _reverse
Pattern ID's for each cell.
Definition: HoughPlaneMulti2.h:137
Belle2::TRGCDCHoughPlaneBase::vote
virtual void vote(float rx, float ry, int weight=1)
Voring.
Definition: HoughPlaneBase.h:507
Belle2::TRGCDCHoughPlaneBoolean::patternId
const std::vector< unsigned > & patternId(unsigned cellId) const
returns pattern ID which activates specified cell.
Definition: HoughPlaneBoolean.h:206
Belle2::TRGCDCHoughPlaneMulti2::finalizePatterns
void finalizePatterns(void)
finalize patterns.
Belle2::TRGCDCHoughPlaneMulti2::preparePatterns
void preparePatterns(unsigned layerId, unsigned nPatterns)
allocate memory for patterns.
Definition: HoughPlaneMulti2.h:247
Belle2::TRGCDCHoughPlaneMulti2::_usage
bool _usage[N_LAYERS]
Used or not.
Definition: HoughPlaneMulti2.h:134
Belle2::TRGCDCHoughPlaneBoolean
A class to represent a Hough parameter plane.
Definition: HoughPlaneBoolean.h:32
Belle2::TRGCDCHoughPlaneMulti2::registerPattern
void registerPattern(unsigned layerId, unsigned id)
registers a pattern..
Definition: HoughPlaneMulti2.h:232
Belle2::TRGCDCHoughPlaneMulti2::vote
void vote(float rx, float ry, int charge, unsigned layerId, int weight=1)
Voting.
Definition: HoughPlaneMulti2.h:176
Belle2::TRGCDCHoughPlaneMulti2::mergeOuters
void mergeOuters(void)
Merge outer layers into one.
Definition: HoughPlaneMulti2.cc:86
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::TRGCDCHoughPlaneMulti2::TRGCDCHoughPlaneMulti2
TRGCDCHoughPlaneMulti2(const std::string &name, const TRGCDCHoughTransformation &transformation, unsigned nX, float xMin, float xMax, unsigned nY, float yMin, float yMax, unsigned nLayers)
Contructor.
Definition: HoughPlaneMulti2.cc:26