CbmRoot
Loading...
Searching...
No Matches
CbmEventTriggers.h
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once
11
12#include <cstdint>
13#include <string>
14
15#if !defined(NO_ROOT) && !XPU_IS_HIP_CUDA
16#include <Rtypes.h> // for ClassDef
17#endif
18
19#include <boost/serialization/access.hpp>
20
24 public:
27 enum class ETrigger : uint32_t
28 {
29 Lambda = 0x00000001,
30 Ks = 0x00000002
31 };
32
33 //using Trigger_t = std::underlying_type_t<ETrigger>;
34 using Trigger_t = uint32_t;
35
37 CbmEventTriggers() = default;
38
41 explicit CbmEventTriggers(uint32_t bitmap) { fBitmap = bitmap; }
42
45
48
50 ~CbmEventTriggers() = default;
51
54
57
60 Trigger_t GetBitmap() const { return fBitmap; }
61
64 void Set(ETrigger key) { fBitmap |= static_cast<Trigger_t>(key); }
65
68 void Reset(ETrigger key) { fBitmap &= ~static_cast<Trigger_t>(key); }
69
71 void ResetAll() { fBitmap = 0; }
72
75 bool Test(ETrigger key) const { return static_cast<bool>(fBitmap & static_cast<Trigger_t>(key)); }
76
79 bool TestAll(Trigger_t bitmask) const { return bitmask == (fBitmap & bitmask); }
80
83 bool TestAny(Trigger_t bitmask) const { return static_cast<bool>(fBitmap | bitmask); }
84
86 std::string ToString() const;
87
88 private:
90
92 template<class Archive>
93 void serialize(Archive& ar, const unsigned int /*version*/)
94 {
95 ar& fBitmap;
96 }
97
98#if !defined(NO_ROOT) && !XPU_IS_HIP_CUDA
100#endif
101};
Class to store different triggers for a given event.
Trigger_t GetBitmap() const
Gets a bitmap.
CbmEventTriggers(uint32_t bitmap)
A constructor from integer.
CbmEventTriggers & operator=(const CbmEventTriggers &)=default
Copy assignment operator.
CbmEventTriggers(const CbmEventTriggers &)=default
Copy constructor.
bool TestAny(Trigger_t bitmask) const
Tests, if ANY of the triggers in the bitmask are on.
void ResetAll()
Resets all the triggers.
CbmEventTriggers & operator=(CbmEventTriggers &&)=default
Move assignment operator.
std::string ToString() const
String representation of the class content.
void serialize(Archive &ar, const unsigned int)
bool TestAll(Trigger_t bitmask) const
Tests, if ALL the triggers in the bitmask are on.
ClassDefNV(CbmEventTriggers, 2)
~CbmEventTriggers()=default
Destructor.
CbmEventTriggers(CbmEventTriggers &&)=default
Move constructor.
void Reset(ETrigger key)
Resets a trigger.
friend class boost::serialization::access
Trigger_t fBitmap
bitmap storing the triggers according to ETrigger
ETrigger
Defines a trigger bitmask.
@ Lambda
Lambda-trigger.
CbmEventTriggers()=default
Default constructor.
void Set(ETrigger key)
Sets a trigger.
bool Test(ETrigger key) const
Tests a particular single trigger.