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#include <cstdint>
22#endif
23
24#include "StoppableThread.h"
25#include "ThreadsafeQueue.h"
26#include "TFragment.h"
27
29public:
30 enum class EBuildMode : std::uint8_t { kDefault,
31 kTime,
34 kSkip };
35
36 static TEventBuildingLoop* Get(std::string name = "", EBuildMode mode = EBuildMode::kTimestamp, uint64_t buildWindow = 2000);
39 TEventBuildingLoop& operator=(const TEventBuildingLoop&) = delete;
40 TEventBuildingLoop& operator=(TEventBuildingLoop&&) noexcept = delete;
42
43#ifndef __CINT__
44 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>& InputQueue()
45 {
46 return fInputQueue;
47 }
48 std::shared_ptr<ThreadsafeQueue<std::vector<std::shared_ptr<const TFragment>>>>& OutputQueue()
49 {
50 return fOutputQueue;
51 }
52 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>& OutOfOrderQueue() { return fOutOfOrderQueue; }
53#endif
54
55 bool Iteration() override;
56
57 void ClearQueue() override;
58
59 size_t GetItemsPushed() override { return fOutputQueue->ItemsPushed(); }
60 size_t GetItemsPopped() override { return fOutputQueue->ItemsPopped(); }
61 size_t GetItemsCurrent() override { return fOutputQueue->Size(); }
62 size_t GetRate() override { return 0; }
63
64 void SetBuildWindow(uint64_t val) { fBuildWindow = val; }
65 uint64_t GetBuildWindow() const { return fBuildWindow; }
66
67 void SetSortDepth(unsigned int val) { fSortingDepth = val; }
68 unsigned int GetSortDepth() const { return fSortingDepth; }
69
70 std::string EndStatus() override;
71
72private:
73 TEventBuildingLoop(std::string name, EBuildMode mode, uint64_t buildWindow);
74
75#ifndef __CINT__
76 bool CheckBuildCondition(const std::shared_ptr<const TFragment>&);
77 bool CheckTimeCondition(const std::shared_ptr<const TFragment>&);
78 bool CheckTimestampCondition(const std::shared_ptr<const TFragment>&);
79 bool CheckTriggerIdCondition(const std::shared_ptr<const TFragment>&);
80
81 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>> fInputQueue;
82 std::shared_ptr<ThreadsafeQueue<std::vector<std::shared_ptr<const TFragment>>>> fOutputQueue;
83 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>> fOutOfOrderQueue;
84#endif
85
87 unsigned int fSortingDepth;
88 uint64_t fBuildWindow;
91
92#ifndef __CINT__
93 std::vector<std::shared_ptr<const TFragment>> fNextEvent;
94
95 std::multiset<std::shared_ptr<const TFragment>,
96 std::function<bool(std::shared_ptr<const TFragment>, std::shared_ptr<const TFragment>)>>
98#endif
99
100 /// \cond CLASSIMP
101 ClassDefOverride(TEventBuildingLoop, 0) // NOLINT(readability-else-after-return)
102 /// \endcond
103};
104
105/*! @} */
106#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