GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TEventBuildingLoop.h
Go to the documentation of this file.
1#ifndef TEVENTBUILDINGLOOP_H
2#define TEVENTBUILDINGLOOP_H
3
4/** \addtogroup Loops
5 * @{
6 */
7
8////////////////////////////////////////////////////////////////////////////////
9///
10/// \class TEventBuildingLoop
11///
12/// This loop builds events (vectors of fragments) based on timestamps and a
13/// build windows.
14///
15////////////////////////////////////////////////////////////////////////////////
16
17#ifndef __CINT__
18#include <memory>
19#include <functional>
20#include <set>
21#endif
22
23#include "StoppableThread.h"
24#include "ThreadsafeQueue.h"
25#include "TFragment.h"
26
28public:
29 enum class EBuildMode { kDefault,
30 kTime,
33 kSkip };
34
35 static TEventBuildingLoop* Get(std::string name = "", EBuildMode mode = EBuildMode::kTimestamp, uint64_t buildWindow = 2000);
38 TEventBuildingLoop& operator=(const TEventBuildingLoop&) = delete;
39 TEventBuildingLoop& operator=(TEventBuildingLoop&&) noexcept = delete;
41
42#ifndef __CINT__
43 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>& InputQueue()
44 {
45 return fInputQueue;
46 }
47 std::shared_ptr<ThreadsafeQueue<std::vector<std::shared_ptr<const TFragment>>>>& OutputQueue()
48 {
49 return fOutputQueue;
50 }
51 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>& OutOfOrderQueue() { return fOutOfOrderQueue; }
52#endif
53
54 bool Iteration() override;
55
56 void ClearQueue() override;
57
58 size_t GetItemsPushed() override { return fOutputQueue->ItemsPushed(); }
59 size_t GetItemsPopped() override { return fOutputQueue->ItemsPopped(); }
60 size_t GetItemsCurrent() override { return fOutputQueue->Size(); }
61 size_t GetRate() override { return 0; }
62
63 void SetBuildWindow(uint64_t val) { fBuildWindow = val; }
64 uint64_t GetBuildWindow() const { return fBuildWindow; }
65
66 void SetSortDepth(unsigned int val) { fSortingDepth = val; }
67 unsigned int GetSortDepth() const { return fSortingDepth; }
68
69 std::string EndStatus() override;
70
71private:
72 TEventBuildingLoop(std::string name, EBuildMode mode, uint64_t buildWindow);
73
74#ifndef __CINT__
75 bool CheckBuildCondition(const std::shared_ptr<const TFragment>&);
76 bool CheckTimeCondition(const std::shared_ptr<const TFragment>&);
77 bool CheckTimestampCondition(const std::shared_ptr<const TFragment>&);
78 bool CheckTriggerIdCondition(const std::shared_ptr<const TFragment>&);
79
80 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>> fInputQueue;
81 std::shared_ptr<ThreadsafeQueue<std::vector<std::shared_ptr<const TFragment>>>> fOutputQueue;
82 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>> fOutOfOrderQueue;
83#endif
84
86 unsigned int fSortingDepth;
87 uint64_t fBuildWindow;
90
91#ifndef __CINT__
92 std::vector<std::shared_ptr<const TFragment>> fNextEvent;
93
94 std::multiset<std::shared_ptr<const TFragment>,
95 std::function<bool(std::shared_ptr<const TFragment>, std::shared_ptr<const TFragment>)>>
97#endif
98
99 /// \cond CLASSIMP
100 ClassDefOverride(TEventBuildingLoop, 0) // NOLINT(readability-else-after-return)
101 /// \endcond
102};
103
104/*! @} */
105#endif /* _TBUILDINGLOOP_H_ */
TEventBuildingLoop(const TEventBuildingLoop &)=delete
std::string EndStatus() override
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TFragment > > > & OutOfOrderQueue()
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TFragment > > > fOutOfOrderQueue
std::shared_ptr< ThreadsafeQueue< std::vector< std::shared_ptr< const TFragment > > > > fOutputQueue
void SetBuildWindow(uint64_t val)
size_t GetItemsCurrent() override
std::shared_ptr< ThreadsafeQueue< std::vector< std::shared_ptr< const TFragment > > > > & OutputQueue()
bool CheckTriggerIdCondition(const std::shared_ptr< const TFragment > &)
bool CheckTimestampCondition(const std::shared_ptr< const TFragment > &)
size_t GetItemsPopped() override
TEventBuildingLoop(TEventBuildingLoop &&) noexcept=delete
size_t GetRate() override
size_t GetItemsPushed() override
bool CheckTimeCondition(const std::shared_ptr< const TFragment > &)
std::vector< std::shared_ptr< const TFragment > > fNextEvent
bool CheckBuildCondition(const std::shared_ptr< const TFragment > &)
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TFragment > > > & InputQueue()
uint64_t GetBuildWindow() const
static TEventBuildingLoop * Get(std::string name="", EBuildMode mode=EBuildMode::kTimestamp, uint64_t buildWindow=2000)
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TFragment > > > fInputQueue
std::multiset< std::shared_ptr< const TFragment >, std::function< bool(std::shared_ptr< const TFragment >, std::shared_ptr< const TFragment >)> > fOrdered
unsigned int GetSortDepth() const
void SetSortDepth(unsigned int val)
void ClearQueue() override
bool Iteration() override