GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TScalerQueue.h
Go to the documentation of this file.
1#ifndef TTIGSCALERQUEUE_H
2#define TTIGSCALERQUEUE_H
3
4/** \addtogroup Sorting
5 * @{
6 */
7
8#include <cstdio>
9#include <queue>
10#include <map>
11
12#if !defined(__CINT__) && !defined(__CLING__)
13// NOLINTBEGIN(readability-identifier-naming, cppcoreguidelines-macro-usage)
14#define _GLIBCXX_USE_NANOSLEEP 1
15// NOLINTEND(readability-identifier-naming, cppcoreguidelines-macro-usage)
16#include <thread>
17#include <mutex>
18#endif
19
20#include "TObjArray.h"
21#include "TStopwatch.h"
22
23#include "TScaler.h"
24
25class TDeadtimeScalerQueue : public TObject {
26public:
27 static TDeadtimeScalerQueue* Get(); // Returns the Queue
30 TDeadtimeScalerQueue& operator=(const TDeadtimeScalerQueue&) = default;
31 TDeadtimeScalerQueue& operator=(TDeadtimeScalerQueue&&) noexcept = default;
33
34private:
36 static TDeadtimeScalerQueue* fDeadtimeScalerQueueClassPointer; // Pointer to the scaler Q singleton
37
38 std::queue<TScalerData*> fDeadtimeScalerQueue; // The scaler Queue itself
39 int fScalersInQueue{0}; // The current number of scalers in the Q
40
41 void StatusUpdate();
42 bool fStatusUpdateOn{false}; // flag that determines whether the Q status should be read out
43
44 bool fStop{false};
45
46 int fScalersIn{0};
48
49 TStopwatch* fStopwatch{nullptr}; // The stop watch used for timing in the status
50 void ResetRateCounter();
51
52 unsigned int fTotalScalersIn{0};
53 unsigned int fTotalScalersOut{0};
54
55 static std::map<int, int> fScalerIdMap;
56
57public:
58#if !defined(__CINT__) && !defined(__CLING__)
59#ifndef NO_MUTEX
60 static std::mutex All; // NOLINT(readability-identifier-naming)
61 static std::mutex Sorted; // NOLINT(readability-identifier-naming)
62#endif
63#endif
64
65 void Add(TScalerData*);
66
67 void Pop() override;
69
70 int Size() const;
71
72 void StartStatusUpdate();
73 void StopStatusUpdate();
74 void CheckStatus() const;
75
76 unsigned int GetTotalScalersIn() const { return fTotalScalersIn; }
77 unsigned int GetTotalScalersOut() const { return fTotalScalersOut; }
78
79 bool Running() const { return !fStop; }
80 void Stop() { fStop = true; }
81
82 void Print(Option_t* opt = "") const override;
83 void Clear(Option_t* opt = "") override;
84};
85
86class TRateScalerQueue : public TObject {
87public:
88 static TRateScalerQueue* Get(); // Returns the Queue
90 TRateScalerQueue(TRateScalerQueue&&) noexcept = default;
91 TRateScalerQueue& operator=(const TRateScalerQueue&) = default;
92 TRateScalerQueue& operator=(TRateScalerQueue&&) noexcept = default;
93 ~TRateScalerQueue() = default;
94
95private:
97 static TRateScalerQueue* fRateScalerQueueClassPointer; // Pointer to the scaler Q singleton
98
99 std::queue<TScalerData*> fRateScalerQueue; // The scaler Queue itself
100 int fScalersInQueue{0}; // The current number of scalers in the Q
101
102 void StatusUpdate();
103 bool fStatusUpdateOn{false}; // flag that determines whether the Q status should be read out
104
105 bool fStop{false};
106
109
110 TStopwatch* fStopwatch{nullptr}; // The stop watch used for timing in the status
111 void ResetRateCounter();
112
113 unsigned int fTotalScalersIn{0};
114 unsigned int fTotalScalersOut{0};
115
116 static std::map<int, int> fScalerIdMap;
117
118public:
119#if !defined(__CINT__) && !defined(__CLING__)
120#ifndef NO_MUTEX
121 static std::mutex All; // NOLINT(readability-identifier-naming)
122 static std::mutex Sorted; // NOLINT(readability-identifier-naming)
123#endif
124#endif
125
126 void Add(TScalerData*);
127
128 void Pop() override;
130
131 int Size() const;
132
133 void StartStatusUpdate();
134 void StopStatusUpdate();
135 void CheckStatus() const;
136
137 unsigned int GetTotalScalersIn() const { return fTotalScalersIn; }
138 unsigned int GetTotalScalersOut() const { return fTotalScalersOut; }
139
140 bool Running() const { return !fStop; }
141 void Stop() { fStop = true; }
142
143 void Print(Option_t* opt = "") const override;
144 void Clear(Option_t* opt = "") override;
145};
146/*! @} */
147#endif
TDeadtimeScalerQueue(TDeadtimeScalerQueue &&) noexcept=default
unsigned int fTotalScalersOut
void Add(TScalerData *)
std::queue< TScalerData * > fDeadtimeScalerQueue
unsigned int GetTotalScalersIn() const
TStopwatch * fStopwatch
void Pop() override
void Clear(Option_t *opt="") override
TScalerData * PopScaler()
static TDeadtimeScalerQueue * fDeadtimeScalerQueueClassPointer
static TDeadtimeScalerQueue * Get()
unsigned int fTotalScalersIn
unsigned int GetTotalScalersOut() const
TDeadtimeScalerQueue(const TDeadtimeScalerQueue &)=default
bool Running() const
static std::map< int, int > fScalerIdMap
void Print(Option_t *opt="") const override
static std::mutex Sorted
static std::mutex All
unsigned int GetTotalScalersOut() const
void Print(Option_t *opt="") const override
unsigned int GetTotalScalersIn() const
static std::mutex Sorted
static TRateScalerQueue * fRateScalerQueueClassPointer
void CheckStatus() const
unsigned int fTotalScalersOut
TScalerData * PopScaler()
void Clear(Option_t *opt="") override
void Add(TScalerData *)
bool Running() const
static std::mutex All
TStopwatch * fStopwatch
std::queue< TScalerData * > fRateScalerQueue
unsigned int fTotalScalersIn
void Pop() override
static TRateScalerQueue * Get()
TRateScalerQueue(TRateScalerQueue &&) noexcept=default
static std::map< int, int > fScalerIdMap
TRateScalerQueue(const TRateScalerQueue &)=default