Belle II Software development
AutomatonCell.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#pragma once
9
10#include <tracking/trackingUtilities/numerics/Weight.h>
11
12namespace Belle2 {
17 namespace TrackingUtilities {
18
30
31 public:
33 enum ECellFlag : unsigned int {
34 c_Assigned = 1,
35 c_Start = 2,
36 c_PriorityPath = 4,
37 c_Cycle = 8,
38
39 c_Masked = 16,
40
41 c_Taken = 32,
42 c_Background = 64,
43 c_Priority = 128,
44 c_Reverse = 256,
45 c_Alias = 512,
46 c_BadADCOrTOT = 1024, // A CDCWireHit with bad ADC or TOT should not be used in pattern recognition.
47 c_BoardWithBadADC = 2048, // Ignore ADC info in filters (detected in each event)
48 c_BoardWithBadTOT = 4096 // Ignore TOT info in filters (detected in each event)
49 };
50
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 ECellFlag::c_BoardWithBadADC +
66 ECellFlag::c_BoardWithBadTOT
67 );
68
70 static const ECellFlags c_TemporaryFlags = ECellFlags(ECellFlag::c_Assigned +
71 ECellFlag::c_Start +
72 ECellFlag::c_PriorityPath +
73 ECellFlag::c_Cycle);
74
75 public:
78 : m_weight(0)
79 , m_state(0)
80 , m_flags(ECellFlag(0))
81 {
82 }
83
85 explicit AutomatonCell(const Weight& cellWeight)
86 : m_weight(cellWeight)
87 , m_state(0)
88 , m_flags(ECellFlag(0))
89 {
90 }
91
93 AutomatonCell(const Weight& cellWeight, const ECellFlags& initialFlags)
94 : m_weight(cellWeight)
95 , m_state(0)
96 , m_flags(initialFlags)
97 {
98 }
99
101 Weight getCellState() const
102 {
103 return m_state;
104 }
105
107 void setCellState(Weight state)
108 {
109 m_state = state;
110 }
111
121 Weight getCellWeight() const
122 {
123 return m_weight;
124 }
125
127 void setCellWeight(Weight weight)
128 {
129 m_weight = weight;
130 }
131
133 void setAssignedFlag(bool setTo = true)
134 {
136 }
137
143
145 bool hasAssignedFlag() const
146 {
147 return hasAnyFlags(ECellFlag::c_Assigned);
148 }
149
151 void setStartFlag(bool setTo = true)
152 {
154 }
155
158 {
160 }
161
163 bool hasStartFlag() const
164 {
165 return hasAnyFlags(ECellFlag::c_Start);
166 }
167
169 void setPriorityPathFlag(bool setTo = true)
170 {
172 }
173
179
182 {
183 return hasAnyFlags(ECellFlag::c_PriorityPath);
184 }
185
187 void setCycleFlag(bool setTo = true)
188 {
190 }
191
194 {
196 }
197
199 bool hasCycleFlag() const
200 {
201 return hasAnyFlags(ECellFlag::c_Cycle);
202 }
203
206 {
208 }
209
211 void setMaskedFlag(bool setTo = true)
212 {
214 }
215
218 {
220 }
221
223 bool hasMaskedFlag() const
224 {
225 return hasAnyFlags(ECellFlag::c_Masked);
226 }
227
229 void setTakenFlag(bool setTo = true)
230 {
232 }
233
236 {
238 }
239
244 bool hasTakenFlag() const
245 {
246 return hasAnyFlags(ECellFlag::c_Taken);
247 }
248
250 void setBackgroundFlag(bool setTo = true)
251 {
253 }
254
260
262 bool hasBackgroundFlag() const
263 {
264 return hasAnyFlags(ECellFlag::c_Background);
265 }
266
270 void setBadADCOrTOTFlag(bool setTo = true)
271 {
273 }
274
280
283 {
284 return hasAnyFlags(ECellFlag::c_BadADCOrTOT);
285 }
286
287
289 void setBoardWithBadADCFlag(bool setTo = true)
290 {
292 }
293
299
302 {
303 return hasAnyFlags(ECellFlag::c_BoardWithBadADC);
304 }
305
307 void setBoardWithBadTOTFlag(bool setTo = true)
308 {
310 }
311
317
320 {
321 return hasAnyFlags(ECellFlag::c_BoardWithBadTOT);
322 }
323
325 void setPriorityFlag(bool setTo = true)
326 {
328 }
329
335
337 bool hasPriorityFlag() const
338 {
339 return hasAnyFlags(ECellFlag::c_Priority);
340 }
341
343 void setReverseFlag(bool setTo = true)
344 {
346 }
347
350 {
352 }
353
355 bool hasReverseFlag() const
356 {
357 return hasAnyFlags(ECellFlag::c_Reverse);
358 }
359
361 void setAliasFlag(bool setTo = true)
362 {
364 }
365
368 {
370 }
371
373 bool hasAliasFlag() const
374 {
375 return hasAnyFlags(ECellFlag::c_Alias);
376 }
377
379 template<ECellFlags cellFlag>
380 void setFlags(bool setTo)
381 {
382 if (setTo) {
383 setFlags(cellFlag);
384 } else {
385 clearFlags(cellFlag);
386 }
387 }
388
394 const ECellFlags& getFlags() const
395 { return m_flags; }
396
399 { m_flags = ECellFlags(m_flags bitor flags); }
400
403 { m_flags = ECellFlags(m_flags bitand ~flags); }
404
406 bool hasAnyFlags(ECellFlags flags) const
407 { return m_flags bitand flags; }
408
409 private:
411 Weight m_weight = 1;
412
414 Weight m_state = 0;
415
418 };
419 }
421}
const ECellFlags & getFlags() const
Getter for the ordered combination of the cell flags to mark some status of the cell.
bool hasBadADCOrTOTFlag() const
Gets the current state of the bad ADC or TOT flag.
void unsetPriorityPathFlag()
Resets the priority path marker flag to false.
void setBackgroundFlag(bool setTo=true)
Sets the background flag to the given value. Default value true.
bool hasAssignedFlag() const
Gets the current state of the already assigned marker flag.
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
ECellFlag
Type for the status flags of cells in the cellular automata.
bool hasCycleFlag() const
Gets the current state of the cycle marker flag.
bool hasBoardWithBadADCFlag() const
Gets the current state of the bad ADC flag.
void unsetBoardWithBadTOTFlag()
Resets the bad TOT flag to false.
void unsetBackgroundFlag()
Resets the background flag to false.
static const ECellFlags c_AllFlags
Constant summing all possible cell flags.
bool hasBoardWithBadTOTFlag() const
Gets the current state of the bad TOT flag.
void setCycleFlag(bool setTo=true)
Sets the cycle marker flag to the given value. Default value true.
ECellFlag ECellFlags
Type for an ordered combination of the status flags of cells in the cellular automata.
bool hasReverseFlag() const
Gets the current state of the do not use flag marker flag.
bool hasStartFlag() const
Gets the current state of the start marker flag.
bool hasAliasFlag() const
Gets the current state of the do not use flag marker flag.
AutomatonCell()
Default constructor for ROOT compatibility. Cell weight defaults to 0.
ECellFlags m_flags
Storage for the cell status flags.
void unsetAliasFlag()
Resets the alias flag to false.
void unsetReverseFlag()
Resets the reverse flag to false.
void setAliasFlag(bool setTo=true)
Sets the alias flag to the given value. Default value true.
void setReverseFlag(bool setTo=true)
Sets the reverse flag to the given value. Default value true.
static const ECellFlags c_TemporaryFlags
Flags that are reset at the start of each run of the cellular automaton.
void setMaskedFlag(bool setTo=true)
Sets the masked flag to the given value. Default value true.
Weight m_weight
Storage for the cell weight.
void unsetMaskedFlag()
Resets the masked flag to false.
AutomatonCell(const Weight &cellWeight, const ECellFlags &initialFlags)
Constructor with a certain cell weight and initial flags to be set.
void unsetStartFlag()
Resets the start marker flag to false.
Weight m_state
Storage for the cell state set by the cellular automata.
void setFlags(ECellFlags flags)
Setter for the cell flags.
void unsetTemporaryFlags()
Resets the assigned, start and cycle marker flag.
bool hasAnyFlags(ECellFlags flags) const
Checks if a cell has any of a sum of given flags.
void unsetAssignedFlag()
Resets the already assigned marker flag to false.
void unsetBadADCOrTOTFlag()
Resets the bad ADC or TOT flag to false.
void setBoardWithBadADCFlag(bool setTo=true)
Set board with bad ADC flag.
void unsetTakenFlag()
Resets the taken flag to false.
bool hasMaskedFlag() const
Gets the current state of the masked marker flag.
void setFlags(bool setTo)
Setting accessing the flag by tag.
Weight getCellWeight() const
Getter for the cell weight.
Weight getCellState() const
Getter for the cell state.
bool hasBackgroundFlag() const
Gets the current state of the do not use flag marker flag.
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
void clearFlags(ECellFlags flags=c_AllFlags)
Clear all flags.
void setAssignedFlag(bool setTo=true)
Sets the already assigned marker flag to the given value. Default value true.
void unsetCycleFlag()
Resets the cycle marker flag to false.
void setCellState(Weight state)
Setter for the cell state.
bool hasPriorityPathFlag() const
Gets the current state of the priority path marker flag.
void setStartFlag(bool setTo=true)
Sets the start marker flag to the given value. Default value true.
void unsetPriorityFlag()
Resets the priority flag to false.
void unsetBoardWithBadADCFlag()
Resets the bad ADC flag to false.
AutomatonCell(const Weight &cellWeight)
Constructor with a certain cell weight.
bool hasPriorityFlag() const
Gets the current state of the do not use flag marker flag.
void setPriorityPathFlag(bool setTo=true)
Sets the priority path marker flag to the given value. Default value true.
void setPriorityFlag(bool setTo=true)
Sets the priority flag to the given value. Default value true.
void setBadADCOrTOTFlag(bool setTo=true)
Sets the bad ADC or TOT flag to the given value.
void setCellWeight(Weight weight)
Setter for the cell weight.
void setBoardWithBadTOTFlag(bool setTo=true)
Set board with bad TOT flag.
Abstract base class for different kinds of events.