|
21 | 21 | #include <string> |
22 | 22 | #include <array> |
23 | 23 | #include <string_view> |
| 24 | +#include <bitset> |
24 | 25 |
|
25 | 26 | namespace o2 |
26 | 27 | { |
@@ -59,15 +60,33 @@ class GlobalTrackID : public AbstractRef<25, 5, 2> |
59 | 60 | NSources |
60 | 61 | }; |
61 | 62 |
|
62 | | - static const std::array<DetID::mask_t, NSources> DetectorMasks; // RS cannot be made constexpr since operator| is not constexpr |
63 | 63 | using AbstractRef<25, 5, 2>::AbstractRef; |
64 | 64 |
|
65 | | - static const auto getSourceMask(int i) { return DetectorMasks[i]; } |
66 | | - static auto getSourceName(int i) { return DetID::getNames(getSourceMask(i)); } |
67 | | - |
| 65 | + static const std::array<DetID::mask_t, NSources> SourceDetectorsMasks; // RS cannot be made constexpr since operator| is not constexpr |
| 66 | + static constexpr std::string_view NONE{"none"}; ///< keywork for no sources |
| 67 | + static constexpr std::string_view ALL{"all"}; ///< keywork for all sources |
| 68 | + typedef std::bitset<NSources> mask_t; |
| 69 | + |
| 70 | + static constexpr std::array<mask_t, NSources> sMasks = ///< detectot masks |
| 71 | + {math_utils::bit2Mask(ITS), math_utils::bit2Mask(TPC), math_utils::bit2Mask(TRD), math_utils::bit2Mask(TOF), math_utils::bit2Mask(PHS), |
| 72 | + math_utils::bit2Mask(CPV), math_utils::bit2Mask(EMC), math_utils::bit2Mask(HMP), math_utils::bit2Mask(MFT), math_utils::bit2Mask(MCH), |
| 73 | + math_utils::bit2Mask(MID), math_utils::bit2Mask(ZDC), math_utils::bit2Mask(FT0), math_utils::bit2Mask(FV0), math_utils::bit2Mask(FDD), |
| 74 | + math_utils::bit2Mask(ITSTPC), math_utils::bit2Mask(TPCTOF), math_utils::bit2Mask(TPCTRD), math_utils::bit2Mask(ITSTPCTRD), |
| 75 | + math_utils::bit2Mask(ITSTPCTOF), math_utils::bit2Mask(TPCTRDTOF), math_utils::bit2Mask(ITSTPCTRDTOF)}; |
| 76 | + |
| 77 | + // methods for detector level manipulations |
| 78 | + static const auto getSourceDetectorsMask(int i) { return SourceDetectorsMasks[i]; } |
| 79 | + static bool includesDet(DetID id, GlobalTrackID::mask_t srcm); |
| 80 | + auto getSourceDetectorsMask() const { return getSourceDetectorsMask(getSource()); } |
| 81 | + bool includesDet(DetID id) const { return (getSourceDetectorsMask() & DetID::getMask(id)).any(); } |
| 82 | + |
| 83 | + // methods for source level manipulations |
| 84 | + static auto getSourceName(int s) { return DetID::getNames(getSourceDetectorsMask(s), '-'); } |
| 85 | + constexpr mask_t getSourceMask(int s) const { return sMasks[s]; } |
| 86 | + mask_t getSourceMask() const { return getSourceMask(getSource()); } |
68 | 87 | auto getSourceName() const { return getSourceName(getSource()); } |
69 | | - auto getSourceMask() const { return getSourceMask(getSource()); } |
70 | | - bool includesDet(DetID id) const { return (getSourceMask() & DetID::getMask(id)).any(); } |
| 88 | + static mask_t getSourcesMask(const std::string_view srcList); |
| 89 | + static bool includesSource(int s, mask_t srcm) { return srcm[s]; } |
71 | 90 |
|
72 | 91 | operator int() const { return int(getIndex()); } |
73 | 92 |
|
|
0 commit comments