Belle II Software  release-05-02-19
AutomatonCell.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/numerics/Weight.h>
13 
14 namespace Belle2 {
19  namespace TrackFindingCDC {
20 
31  class AutomatonCell {
32 
33  public:
35  enum ECellFlag : unsigned int {
36  c_Assigned = 1,
37  c_Start = 2,
38  c_PriorityPath = 4,
39  c_Cycle = 8,
40 
41  c_Masked = 16,
42 
43  c_Taken = 32,
44  c_Background = 64,
45  c_Priority = 128,
46  c_Reverse = 256,
47  c_Alias = 512,
48  c_BadADCOrTOT = 1024, // A CDCWireHit with bad ADC or TOT should not be used in pattern recognition.
49  };
50 
52  using ECellFlags = ECellFlag;
53 
55  static const ECellFlags c_AllFlags = ECellFlags(ECellFlag::c_Assigned +
56  ECellFlag::c_Start +
57  ECellFlag::c_PriorityPath +
58  ECellFlag::c_Cycle +
59  ECellFlag::c_Masked +
60  ECellFlag::c_Taken +
61  ECellFlag::c_Background +
62  ECellFlag::c_Reverse +
63  ECellFlag::c_Alias +
64  ECellFlag::c_BadADCOrTOT);
65 
67  static const ECellFlags c_TemporaryFlags = ECellFlags(ECellFlag::c_Assigned +
68  ECellFlag::c_Start +
69  ECellFlag::c_PriorityPath +
70  ECellFlag::c_Cycle);
71 
72  public:
75  : m_weight(0)
76  , m_flags(ECellFlag(0))
77  , m_state(0)
78  {
79  }
80 
82  explicit AutomatonCell(const Weight& cellWeight)
83  : m_weight(cellWeight)
84  , m_flags(ECellFlag(0))
85  , m_state(0)
86  {
87  }
88 
90  AutomatonCell(const Weight& cellWeight, const ECellFlags& initialFlags)
91  : m_weight(cellWeight)
92  , m_flags(initialFlags)
93  , m_state(0)
94  {
95  }
96 
98  Weight getCellState() const
99  {
100  return m_state;
101  }
102 
104  void setCellState(Weight state)
105  {
106  m_state = state;
107  }
108 
118  Weight getCellWeight() const
119  {
120  return m_weight;
121  }
122 
124  void setCellWeight(Weight weight)
125  {
126  m_weight = weight;
127  }
128 
130  void setAssignedFlag(bool setTo = true)
131  {
132  setFlags<ECellFlag::c_Assigned>(setTo);
133  }
134 
136  void unsetAssignedFlag()
137  {
138  setFlags<ECellFlag::c_Assigned>(false);
139  }
140 
142  bool hasAssignedFlag() const
143  {
144  return hasAnyFlags(ECellFlag::c_Assigned);
145  }
146 
148  void setStartFlag(bool setTo = true)
149  {
150  setFlags<ECellFlag::c_Start>(setTo);
151  }
152 
154  void unsetStartFlag()
155  {
156  setFlags<ECellFlag::c_Start>(false);
157  }
158 
160  bool hasStartFlag() const
161  {
162  return hasAnyFlags(ECellFlag::c_Start);
163  }
164 
166  void setPriorityPathFlag(bool setTo = true)
167  {
168  setFlags<ECellFlag::c_PriorityPath>(setTo);
169  }
170 
172  void unsetPriorityPathFlag()
173  {
174  setFlags<ECellFlag::c_PriorityPath>(false);
175  }
176 
178  bool hasPriorityPathFlag() const
179  {
180  return hasAnyFlags(ECellFlag::c_PriorityPath);
181  }
182 
184  void setCycleFlag(bool setTo = true)
185  {
186  setFlags<ECellFlag::c_Cycle>(setTo);
187  }
188 
190  void unsetCycleFlag()
191  {
192  setFlags<ECellFlag::c_Cycle>(false);
193  }
194 
196  bool hasCycleFlag() const
197  {
198  return hasAnyFlags(ECellFlag::c_Cycle);
199  }
200 
202  void unsetTemporaryFlags()
203  {
204  setFlags<c_TemporaryFlags>(false);
205  }
206 
208  void setMaskedFlag(bool setTo = true)
209  {
210  setFlags<ECellFlag::c_Masked>(setTo);
211  }
212 
214  void unsetMaskedFlag()
215  {
216  setFlags<ECellFlag::c_Masked>(false);
217  }
218 
220  bool hasMaskedFlag() const
221  {
222  return hasAnyFlags(ECellFlag::c_Masked);
223  }
224 
226  void setTakenFlag(bool setTo = true)
227  {
228  setFlags<ECellFlag::c_Taken>(setTo);
229  }
230 
232  void unsetTakenFlag()
233  {
234  setFlags<ECellFlag::c_Taken>(false);
235  }
236 
241  bool hasTakenFlag() const
242  {
243  return hasAnyFlags(ECellFlag::c_Taken);
244  }
245 
247  void setBackgroundFlag(bool setTo = true)
248  {
249  setFlags<ECellFlag::c_Background>(setTo);
250  }
251 
253  void unsetBackgroundFlag()
254  {
255  setFlags<ECellFlag::c_Background>(false);
256  }
257 
259  bool hasBackgroundFlag() const
260  {
261  return hasAnyFlags(ECellFlag::c_Background);
262  }
263 
267  void setBadADCOrTOTFlag(bool setTo = true)
268  {
269  setFlags<ECellFlag::c_BadADCOrTOT>(setTo);
270  }
271 
273  void unsetBadADCOrTOTFlag()
274  {
275  setFlags<ECellFlag::c_BadADCOrTOT>(false);
276  }
277 
279  bool hasBadADCOrTOTFlag() const
280  {
281  return hasAnyFlags(ECellFlag::c_BadADCOrTOT);
282  }
283 
285  void setPriorityFlag(bool setTo = true)
286  {
287  setFlags<ECellFlag::c_Priority>(setTo);
288  }
289 
291  void unsetPriorityFlag()
292  {
293  setFlags<ECellFlag::c_Priority>(false);
294  }
295 
297  bool hasPriorityFlag() const
298  {
299  return hasAnyFlags(ECellFlag::c_Priority);
300  }
301 
303  void setReverseFlag(bool setTo = true)
304  {
305  setFlags<ECellFlag::c_Reverse>(setTo);
306  }
307 
309  void unsetReverseFlag()
310  {
311  setFlags<ECellFlag::c_Reverse>(false);
312  }
313 
315  bool hasReverseFlag() const
316  {
317  return hasAnyFlags(ECellFlag::c_Reverse);
318  }
319 
321  void setAliasFlag(bool setTo = true)
322  {
323  setFlags<ECellFlag::c_Alias>(setTo);
324  }
325 
327  void unsetAliasFlag()
328  {
329  setFlags<ECellFlag::c_Alias>(false);
330  }
331 
333  bool hasAliasFlag() const
334  {
335  return hasAnyFlags(ECellFlag::c_Alias);
336  }
337 
339  template<ECellFlags cellFlag>
340  void setFlags(bool setTo)
341  {
342  if (setTo) {
343  setFlags(cellFlag);
344  } else {
345  clearFlags(cellFlag);
346  }
347  }
348 
354  const ECellFlags& getFlags() const
355  { return m_flags; }
356 
358  void setFlags(ECellFlags flags)
359  { m_flags = ECellFlags(m_flags bitor flags); }
360 
363  { m_flags = ECellFlags(m_flags bitand ~flags); }
364 
366  bool hasAnyFlags(ECellFlags flags) const
367  { return m_flags bitand flags; }
368 
369  private:
371  Weight m_weight = 1;
372 
375 
377  Weight m_state = 0;
378  };
379  }
381 }
Belle2::TrackFindingCDC::AutomatonCell::hasReverseFlag
bool hasReverseFlag() const
Gets the current state of the do not use flag marker flag.
Definition: AutomatonCell.h:323
Belle2::TrackFindingCDC::AutomatonCell::unsetCycleFlag
void unsetCycleFlag()
Resets the cycle marker flag to false.
Definition: AutomatonCell.h:198
Belle2::TrackFindingCDC::AutomatonCell::setCellState
void setCellState(Weight state)
Setter for the cell state.
Definition: AutomatonCell.h:112
Belle2::TrackFindingCDC::AutomatonCell::setReverseFlag
void setReverseFlag(bool setTo=true)
Sets the reverse flag to the given value. Default value true.
Definition: AutomatonCell.h:311
Belle2::TrackFindingCDC::AutomatonCell::setPriorityFlag
void setPriorityFlag(bool setTo=true)
Sets the priority flag to the given value. Default value true.
Definition: AutomatonCell.h:293
Belle2::TrackFindingCDC::AutomatonCell::unsetBadADCOrTOTFlag
void unsetBadADCOrTOTFlag()
Resets the bad ADC or TOT flag to false.
Definition: AutomatonCell.h:281
Belle2::TrackFindingCDC::AutomatonCell::hasAssignedFlag
bool hasAssignedFlag() const
Gets the current state of the already assigned marker flag.
Definition: AutomatonCell.h:150
Belle2::TrackFindingCDC::AutomatonCell::setCycleFlag
void setCycleFlag(bool setTo=true)
Sets the cycle marker flag to the given value. Default value true.
Definition: AutomatonCell.h:192
Belle2::TrackFindingCDC::AutomatonCell::hasBadADCOrTOTFlag
bool hasBadADCOrTOTFlag() const
Gets the current state of the bad ADC or TOT flag.
Definition: AutomatonCell.h:287
Belle2::TrackFindingCDC::AutomatonCell::hasMaskedFlag
bool hasMaskedFlag() const
Gets the current state of the masked marker flag.
Definition: AutomatonCell.h:228
Belle2::TrackFindingCDC::AutomatonCell::AutomatonCell
AutomatonCell()
Default constructor for ROOT compatibility. Cell weight defaults to 0.
Definition: AutomatonCell.h:82
Belle2::TrackFindingCDC::AutomatonCell::AutomatonCell
AutomatonCell(const Weight &cellWeight)
Constructor with a certain cell weight.
Definition: AutomatonCell.h:90
Belle2::TrackFindingCDC::AutomatonCell::setBadADCOrTOTFlag
void setBadADCOrTOTFlag(bool setTo=true)
Sets the bad ADC or TOT flag to the given value.
Definition: AutomatonCell.h:275
Belle2::TrackFindingCDC::AutomatonCell::unsetPriorityPathFlag
void unsetPriorityPathFlag()
Resets the priority path marker flag to false.
Definition: AutomatonCell.h:180
Belle2::TrackFindingCDC::AutomatonCell::unsetBackgroundFlag
void unsetBackgroundFlag()
Resets the background flag to false.
Definition: AutomatonCell.h:261
Belle2::TrackFindingCDC::AutomatonCell::setTakenFlag
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
Definition: AutomatonCell.h:234
Belle2::TrackFindingCDC::AutomatonCell::unsetMaskedFlag
void unsetMaskedFlag()
Resets the masked flag to false.
Definition: AutomatonCell.h:222
Belle2::TrackFindingCDC::AutomatonCell::hasAnyFlags
bool hasAnyFlags(ECellFlags flags) const
Checks if a cell has any of a sum of given flags.
Definition: AutomatonCell.h:374
Belle2::TrackFindingCDC::AutomatonCell::hasPriorityPathFlag
bool hasPriorityPathFlag() const
Gets the current state of the priority path marker flag.
Definition: AutomatonCell.h:186
Belle2::TrackFindingCDC::AutomatonCell::c_AllFlags
static const ECellFlags c_AllFlags
Constant summing all possible cell flags.
Definition: AutomatonCell.h:63
Belle2::TrackFindingCDC::AutomatonCell::getCellWeight
Weight getCellWeight() const
Getter for the cell weight.
Definition: AutomatonCell.h:126
Belle2::TrackFindingCDC::AutomatonCell::setBackgroundFlag
void setBackgroundFlag(bool setTo=true)
Sets the background flag to the given value. Default value true.
Definition: AutomatonCell.h:255
Belle2::TrackFindingCDC::AutomatonCell::setStartFlag
void setStartFlag(bool setTo=true)
Sets the start marker flag to the given value. Default value true.
Definition: AutomatonCell.h:156
Belle2::TrackFindingCDC::AutomatonCell::unsetTemporaryFlags
void unsetTemporaryFlags()
Resets the assigned, start and cycle marker flag.
Definition: AutomatonCell.h:210
Belle2::TrackFindingCDC::AutomatonCell::c_TemporaryFlags
static const ECellFlags c_TemporaryFlags
Flage that are reset at the start of each run of the cellular automaton.
Definition: AutomatonCell.h:75
Belle2::TrackFindingCDC::AutomatonCell::m_flags
ECellFlags m_flags
Storage for the cell status flags.
Definition: AutomatonCell.h:382
Belle2::TrackFindingCDC::AutomatonCell::hasAliasFlag
bool hasAliasFlag() const
Gets the current state of the do not use flag marker flag.
Definition: AutomatonCell.h:341
Belle2::TrackFindingCDC::AutomatonCell::setAssignedFlag
void setAssignedFlag(bool setTo=true)
Sets the already assigned marker flag to the given value. Default value true.
Definition: AutomatonCell.h:138
Belle2::TrackFindingCDC::AutomatonCell::setMaskedFlag
void setMaskedFlag(bool setTo=true)
Sets the masked flag to the given value. Default value true.
Definition: AutomatonCell.h:216
Belle2::TrackFindingCDC::AutomatonCell::setFlags
void setFlags(bool setTo)
Setting accessing the flag by tag.
Definition: AutomatonCell.h:348
Belle2::TrackFindingCDC::AutomatonCell::m_weight
Weight m_weight
Storage for the cell weight.
Definition: AutomatonCell.h:379
Belle2::TrackFindingCDC::AutomatonCell::hasBackgroundFlag
bool hasBackgroundFlag() const
Gets the current state of the do not use flag marker flag.
Definition: AutomatonCell.h:267
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::AutomatonCell::unsetReverseFlag
void unsetReverseFlag()
Resets the reverse flag to false.
Definition: AutomatonCell.h:317
Belle2::TrackFindingCDC::AutomatonCell::setPriorityPathFlag
void setPriorityPathFlag(bool setTo=true)
Sets the priority path marker flag to the given value. Default value true.
Definition: AutomatonCell.h:174
Belle2::TrackFindingCDC::AutomatonCell::ECellFlag
ECellFlag
Type for the status flags of cells in the cellular automata.
Definition: AutomatonCell.h:43
Belle2::TrackFindingCDC::AutomatonCell::unsetPriorityFlag
void unsetPriorityFlag()
Resets the priority flag to false.
Definition: AutomatonCell.h:299
Belle2::TrackFindingCDC::AutomatonCell::getFlags
const ECellFlags & getFlags() const
Getter for the ored combination of the cell flags to mark some status of the cell.
Definition: AutomatonCell.h:362
Belle2::TrackFindingCDC::AutomatonCell::hasPriorityFlag
bool hasPriorityFlag() const
Gets the current state of the do not use flag marker flag.
Definition: AutomatonCell.h:305
Belle2::TrackFindingCDC::AutomatonCell::clearFlags
void clearFlags(ECellFlags flags=c_AllFlags)
Clear all flags.
Definition: AutomatonCell.h:370
Belle2::TrackFindingCDC::AutomatonCell::hasTakenFlag
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
Definition: AutomatonCell.h:249
Belle2::TrackFindingCDC::AutomatonCell::unsetAliasFlag
void unsetAliasFlag()
Resets the alias flag to false.
Definition: AutomatonCell.h:335
Belle2::TrackFindingCDC::AutomatonCell::hasCycleFlag
bool hasCycleFlag() const
Gets the current state of the cycle marker flag.
Definition: AutomatonCell.h:204
Belle2::TrackFindingCDC::AutomatonCell::setAliasFlag
void setAliasFlag(bool setTo=true)
Sets the alias flag to the given value. Default value true.
Definition: AutomatonCell.h:329
Belle2::TrackFindingCDC::AutomatonCell::ECellFlags
ECellFlag ECellFlags
Type for an ored combination of the status flags of cells in the cellular automata.
Definition: AutomatonCell.h:60
Belle2::TrackFindingCDC::AutomatonCell::m_state
Weight m_state
Storage for the cell state set by the cellular automata.
Definition: AutomatonCell.h:385
Belle2::TrackFindingCDC::AutomatonCell::setCellWeight
void setCellWeight(Weight weight)
Setter for the cell weight.
Definition: AutomatonCell.h:132
Belle2::TrackFindingCDC::AutomatonCell::hasStartFlag
bool hasStartFlag() const
Gets the current state of the start marker flag.
Definition: AutomatonCell.h:168
Belle2::TrackFindingCDC::AutomatonCell::unsetAssignedFlag
void unsetAssignedFlag()
Resets the already assigned marker flag to false.
Definition: AutomatonCell.h:144
Belle2::TrackFindingCDC::AutomatonCell::unsetStartFlag
void unsetStartFlag()
Resets the start marker flag to false.
Definition: AutomatonCell.h:162
Belle2::TrackFindingCDC::AutomatonCell::unsetTakenFlag
void unsetTakenFlag()
Resets the taken flag to false.
Definition: AutomatonCell.h:240
Belle2::TrackFindingCDC::AutomatonCell::getCellState
Weight getCellState() const
Getter for the cell state.
Definition: AutomatonCell.h:106