BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnEnums.h
Go to the documentation of this file.
1/**
2 * \file BmnEnums.h
3 * \author Andrey Lebedev <andrey.lebedev@gsi.de> - Original author. First version of code for CBM experiment.
4 * \author Sergey Merts <Sergey.Merts@gmail.com> - Modification for BMN experiment.
5 * \date 2008-2014
6 * \brief Define enumerations used in tracking.
7 **/
8
9#ifndef BMNENUMS_H_
10#define BMNENUMS_H_
11
12#include <cstddef>
13#include <type_traits>
14
15/*
16 * A preprocessor definition to make an enumeration type a bitmask.
17 * If not familiar with bitmasks, see "C++ named requirements: BitmaskType" on cppreference (link:
18 * https://cppreference.dev/w/cpp/named_req/BitmaskType)
19 */
20#define MAKE_ENUM_BITMASK(EnumType) \
21 inline EnumType& operator|=(EnumType& lhv, const EnumType rhv) \
22 { \
23 lhv = (EnumType)((std::underlying_type_t<EnumType>)lhv | (std::underlying_type_t<EnumType>)rhv); \
24 return lhv; \
25 } \
26 inline EnumType& operator&=(EnumType& lhv, const EnumType rhv) \
27 { \
28 lhv = (EnumType)((std::underlying_type_t<EnumType>)lhv & (std::underlying_type_t<EnumType>)rhv); \
29 return lhv; \
30 } \
31 inline EnumType& operator^=(EnumType& lhv, const EnumType rhv) \
32 { \
33 lhv = (EnumType)((std::underlying_type_t<EnumType>)lhv ^ (std::underlying_type_t<EnumType>)rhv); \
34 return lhv; \
35 } \
36 constexpr EnumType operator|(const EnumType lhv, const EnumType rhv) \
37 { \
38 return (EnumType)((std::underlying_type_t<EnumType>)lhv | (std::underlying_type_t<EnumType>)rhv); \
39 } \
40 constexpr EnumType operator&(const EnumType lhv, const EnumType rhv) \
41 { \
42 return (EnumType)((std::underlying_type_t<EnumType>)lhv & (std::underlying_type_t<EnumType>)rhv); \
43 } \
44 constexpr EnumType operator^(const EnumType lhv, const EnumType rhv) \
45 { \
46 return (EnumType)((std::underlying_type_t<EnumType>)lhv ^ (std::underlying_type_t<EnumType>)rhv); \
47 } \
48 constexpr EnumType operator~(const EnumType value) \
49 { \
50 return (EnumType)(~((std::underlying_type_t<EnumType>)value)); \
51 }
52
53/*
54 * Checks if an enumeration-type argument has at least one of the provided flags (for bitmasks)
55 * @tparam T An enumeration type
56 * @param lhv An enumeration-type argument for which one wants to check the existence of some flags from `rhv`
57 * @param rhv Enumeration-type values one is looking for in the `lhv` argument
58 * @return 'true' if the enum argument has some of the provided flags, or 'false' if it doesn't
59 */
60template<typename T>
61inline auto HasAnyFlags(const T lhv, const T rhv) -> std::enable_if_t<std::is_enum_v<T>, bool>
62{
63 return (std::underlying_type_t<T>)(lhv & rhv) != 0 ? true : false;
64}
65
66/*
67 * Checks if an enumeration-type argument has all of the provided flags (for bitmasks)
68 * @tparam T An enumeration type
69 * @param lhv An enumeration-type argument for which one wants to check the existence of all the flags from `rhv`
70 * @param rhv Enumeration-type values one is looking for in the `lhv` argument
71 * @return 'true' if the enum argument has all of the provided flags, or 'false' if it doesn't
72 */
73template<typename T>
74inline auto HasAllFlags(const T lhv, const T rhv) -> std::enable_if_t<std::is_enum_v<T>, bool>
75{
76 return ((lhv & rhv) == rhv) ? true : false;
77}
78
79/**
80 * Define type of hit on detector station.
81 */
83{
84 kBMNSTRIPHIT = 0, /**< Strip hit. */
85 kBMNPIXELHIT = 1, /**< Pixel hit. */
86 kBMNMIXHIT = 2 /**< Mixed type of hits, i.e. both strip and pixel hits. **/
87};
88
89/**
90 * Define status code.
91 */
93{
94 kBMNSUCCESS = 0, /**< Success. */
95 kBMNERROR = 1, /**< Error. */
99};
100
101/**
102 * Define reconstructed track quality.
103 */
105{
106 kBMNGOOD = 0, /**< Good track. */
107 kBMNBAD = 1, /**< Bad track. */
108 kBMNGOODMERGE = 2 /**< Correctly merged track. */
109};
110
111/**
112 * Define system identificator.
113 */
115{
116 kBMNGEM = 0, /**< GEM detector. */
117 kBMNTOF = 2, /**< TOF detector. */
118 kBMNSTS = 4 /**< STS detector. */
119};
120
121/**
122 * Define status of TOF hit merging
123 */
125{
126 kBMNTOFGOOD = 0, /**< merged TOF hit. */
127 kBMNTOFBAD = 1, /**< not merged TOF hit. */
128};
129
130/**
131 * Define type of event
132 */
134{
135 kBMNBEAM = 6, /**< "beam" BC1 + BC2 + T0 + VC */
136 kBMNMINBIAS = 1, /**< "min.bias" BC1 + BC2 + T0 + VC + FD */
137};
138
139/**
140 * Define type of event
141 */
143{
144 kBMNPEDESTAL = 0, /**< pedestal event. */
145 kBMNPAYLOAD = 1, /**< spill event. */
146 kBMNEOS = 2, /**< End of spill. */
147 kBMNSTAT = 3, /**< Statistics. */
148 kBMNEMPTY = 4, /**< No event (wrong sync word or metadata payload) */
149};
150
151/**
152 * Define worker state
153 */
160
161/**
162 * Define experimental setup
163 */
165{
168};
169
170#endif /* BMNENUMS_H_ */
BmnStatus
Define status code.
Definition BmnEnums.h:93
@ kBMNTIMEOUT
Definition BmnEnums.h:96
@ kBMNFINISH
Definition BmnEnums.h:97
@ kBMNERROR
Error.
Definition BmnEnums.h:95
@ kBMNSUCCESS
Success.
Definition BmnEnums.h:94
@ kBMNCONTINUE
Definition BmnEnums.h:98
auto HasAnyFlags(const T lhv, const T rhv) -> std::enable_if_t< std::is_enum_v< T >, bool >
Definition BmnEnums.h:61
BmnTofHitQA
Define status of TOF hit merging.
Definition BmnEnums.h:125
@ kBMNTOFGOOD
merged TOF hit.
Definition BmnEnums.h:126
@ kBMNTOFBAD
not merged TOF hit.
Definition BmnEnums.h:127
BmnWorkerState
Define worker state.
Definition BmnEnums.h:155
@ kBMNWAIT
Definition BmnEnums.h:156
@ kBMNRECON
Definition BmnEnums.h:158
@ kBMNWORK
Definition BmnEnums.h:157
BmnSetup
Define experimental setup.
Definition BmnEnums.h:165
@ kSRCSETUP
Definition BmnEnums.h:167
@ kBMNSETUP
Definition BmnEnums.h:166
auto HasAllFlags(const T lhv, const T rhv) -> std::enable_if_t< std::is_enum_v< T >, bool >
Definition BmnEnums.h:74
BmnTriggerType
Define type of event.
Definition BmnEnums.h:134
@ kBMNMINBIAS
"min.bias" BC1 + BC2 + T0 + VC + FD
Definition BmnEnums.h:136
@ kBMNBEAM
"beam" BC1 + BC2 + T0 + VC
Definition BmnEnums.h:135
BmnHitType
Define type of hit on detector station.
Definition BmnEnums.h:83
@ kBMNMIXHIT
Mixed type of hits, i.e.
Definition BmnEnums.h:86
@ kBMNPIXELHIT
Pixel hit.
Definition BmnEnums.h:85
@ kBMNSTRIPHIT
Strip hit.
Definition BmnEnums.h:84
BmnEventType
Define type of event.
Definition BmnEnums.h:143
@ kBMNSTAT
Statistics.
Definition BmnEnums.h:147
@ kBMNEOS
End of spill.
Definition BmnEnums.h:146
@ kBMNPAYLOAD
spill event.
Definition BmnEnums.h:145
@ kBMNPEDESTAL
pedestal event.
Definition BmnEnums.h:144
@ kBMNEMPTY
No event (wrong sync word or metadata payload).
Definition BmnEnums.h:148
BmnTrackQa
Define reconstructed track quality.
Definition BmnEnums.h:105
@ kBMNBAD
Bad track.
Definition BmnEnums.h:107
@ kBMNGOODMERGE
Correctly merged track.
Definition BmnEnums.h:108
@ kBMNGOOD
Good track.
Definition BmnEnums.h:106
BmnSystemId
Define system identificator.
Definition BmnEnums.h:115
@ kBMNTOF
TOF detector.
Definition BmnEnums.h:117
@ kBMNGEM
GEM detector.
Definition BmnEnums.h:116
@ kBMNSTS
STS detector.
Definition BmnEnums.h:118