GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TDataParser.h
Go to the documentation of this file.
1#ifndef TDATAPARSER_H
2#define TDATAPARSER_H
3
4/** \addtogroup Sorting
5 * @{
6 */
7
8/////////////////////////////////////////////////////////////////
9///
10/// \class TDataParser
11///
12/// The TDataParser is the DAQ dependent part of GRSISort.
13/// It takes raw data and converts it into a generic TFragment
14/// that the rest of GRSISort can deal with.
15/// This is where event word masks are applied, and any changes
16/// to the event format must be implemented.
17///
18/////////////////////////////////////////////////////////////////
19
20#include "Globals.h"
21#include <ctime>
22#include <sstream>
23#include <vector>
24#include <map>
25#include <limits>
26
27#ifndef __CINT__
28#include <memory>
29#endif
30
31#include "TChannel.h"
32#include "TFragment.h"
33#include "TPPG.h"
34#include "TScaler.h"
35#include "TFragmentMap.h"
36#include "ThreadsafeQueue.h"
37#include "TEpicsFrag.h"
38#include "TGRSIOptions.h"
39
40class TRawEvent;
41
43public:
45 TDataParser(const TDataParser&) = default;
46 TDataParser(TDataParser&&) noexcept = default;
47 TDataParser& operator=(const TDataParser&) = delete;
48 TDataParser& operator=(TDataParser&&) noexcept = delete;
49 virtual ~TDataParser();
50 virtual void SetNoWaveForms(bool temp = true) { fNoWaveforms = temp; }
51 virtual void SetRecordDiag(bool temp = true) { fRecordDiag = temp; }
52
53 // if you add anything to these enums, only add at the end!
54 enum class EBank { kWFDN,
55 kGRF1,
56 kGRF2,
57 kGRF3,
58 kGRF4,
59 kFME0,
60 kFME1,
61 kFME2,
62 kFME3 };
63
64#ifndef __CINT__
65 virtual std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>& AddGoodOutputQueue(size_t maxSize = 50000)
66 {
67 std::ostringstream name;
68 name << "good_frag_queue_" << fGoodOutputQueues.size();
69 fGoodOutputQueues.push_back(std::make_shared<ThreadsafeQueue<std::shared_ptr<const TFragment>>>(name.str(), maxSize));
70 return fGoodOutputQueues.back();
71 }
72
73 virtual std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TBadFragment>>>& BadOutputQueue() { return fBadOutputQueue; }
74
75 virtual std::shared_ptr<ThreadsafeQueue<std::shared_ptr<TEpicsFrag>>>& ScalerOutputQueue() { return fScalerOutputQueue; }
76
77 virtual void SetStatusVariables(std::atomic_size_t* itemsPopped, std::atomic_long* inputSize)
78 {
79 fItemsPopped = itemsPopped;
80 fInputSize = inputSize;
81 }
82
83 virtual int Process(std::shared_ptr<TRawEvent>) = 0;
84 void Push(ThreadsafeQueue<std::shared_ptr<const TBadFragment>>& queue, const std::shared_ptr<TBadFragment>& frag);
85 void Push(std::vector<std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>>& queues, const std::shared_ptr<TFragment>& frag);
86#endif
87 virtual void ClearQueue();
88 virtual size_t ItemsPushed()
89 {
90 if(!fGoodOutputQueues.empty()) {
91 return fGoodOutputQueues.back()->ItemsPushed();
92 }
93 return std::numeric_limits<std::size_t>::max();
94 }
95 virtual void SetFinished();
96 virtual std::string OutputQueueStatus();
97
98protected:
99 // getters
100#ifndef __CINT__
101 std::vector<std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>>& GoodOutputQueues() { return fGoodOutputQueues; }
102#endif
103 bool NoWaveforms() const { return fNoWaveforms; }
104 bool RecordDiag() const { return fRecordDiag; }
105 TChannel* Channel() const { return fChannel; }
106
107 uint64_t MaxTriggerId() const { return fMaxTriggerId; }
108 uint64_t LastDaqId() const { return fLastDaqId; }
109 uint64_t LastTriggerId() const { return fLastTriggerId; }
110 uint64_t LastNetworkPacket() const { return fLastNetworkPacket; }
111
113
115 std::map<UInt_t, Long64_t> LastTimeStampMap() const { return fLastTimeStampMap; }
116
117 static TGRSIOptions* Options() { return fOptions; }
118
119 // setters
120 void LastTriggerId(const uint64_t& val) { fLastTriggerId = val; }
121
122 void FragmentHasWaveform(const bool& val) { fFragmentHasWaveform = val; }
123
124 static void Options(TGRSIOptions* val) { fOptions = val; }
125
126private:
127 // TODO consider making all of these private with protected access functions
128#ifndef __CINT__
129 std::vector<std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TFragment>>>> fGoodOutputQueues;
130 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<const TBadFragment>>> fBadOutputQueue;
131 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<TEpicsFrag>>> fScalerOutputQueue;
132#endif
133
134 bool fNoWaveforms; ///< The flag to turn wave_forms on or off
135 bool fRecordDiag; ///< The flag to turn on diagnostics recording
137
138 const uint64_t fMaxTriggerId; ///< The last trigger ID Called
139 uint64_t fLastDaqId; ///< The last daq ID in the raw file
140 uint64_t fLastTriggerId; ///< The last Trigged ID in the raw File
141 uint64_t fLastNetworkPacket; ///< The last network packet recieved.
142
143 std::map<Long_t, int> fFragmentIdMap;
145
146 TFragmentMap fFragmentMap; ///< Class that holds a map of fragments per address, takes care of calculating charges for GRF4 banks
147
148 std::map<UInt_t, Long64_t> fLastTimeStampMap;
149
150 static TGRSIOptions* fOptions; ///< Static pointer to TGRSIOptions, gets set on the first call of GriffinDataToFragment
151
152#ifndef __CINT__
153 std::atomic_size_t* fItemsPopped;
154 std::atomic_long* fInputSize;
155#endif
156};
157/*! @} */
158#endif
uint64_t fLastNetworkPacket
The last network packet recieved.
bool NoWaveforms() const
TChannel * Channel() const
bool fRecordDiag
The flag to turn on diagnostics recording.
virtual std::string OutputQueueStatus()
static void Options(TGRSIOptions *val)
std::vector< std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TFragment > > > > & GoodOutputQueues()
std::map< Long_t, int > fFragmentIdMap
virtual std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TBadFragment > > > & BadOutputQueue()
Definition TDataParser.h:73
TFragmentMap FragmentMap() const
virtual void SetFinished()
TDataParser(const TDataParser &)=default
void Push(ThreadsafeQueue< std::shared_ptr< const TBadFragment > > &queue, const std::shared_ptr< TBadFragment > &frag)
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TBadFragment > > > fBadOutputQueue
bool fFragmentHasWaveform
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< TEpicsFrag > > > fScalerOutputQueue
virtual void SetRecordDiag(bool temp=true)
Definition TDataParser.h:51
std::map< UInt_t, Long64_t > LastTimeStampMap() const
TDataParser(TDataParser &&) noexcept=default
virtual std::shared_ptr< ThreadsafeQueue< std::shared_ptr< TEpicsFrag > > > & ScalerOutputQueue()
Definition TDataParser.h:75
std::atomic_long * fInputSize
virtual std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TFragment > > > & AddGoodOutputQueue(size_t maxSize=50000)
Definition TDataParser.h:65
virtual int Process(std::shared_ptr< TRawEvent >)=0
std::map< UInt_t, Long64_t > fLastTimeStampMap
bool RecordDiag() const
static TGRSIOptions * fOptions
Static pointer to TGRSIOptions, gets set on the first call of GriffinDataToFragment.
TFragmentMap fFragmentMap
Class that holds a map of fragments per address, takes care of calculating charges for GRF4 banks.
static TGRSIOptions * Options()
virtual void ClearQueue()
const uint64_t fMaxTriggerId
The last trigger ID Called.
virtual void SetStatusVariables(std::atomic_size_t *itemsPopped, std::atomic_long *inputSize)
Definition TDataParser.h:77
void LastTriggerId(const uint64_t &val)
bool fNoWaveforms
The flag to turn wave_forms on or off.
std::vector< std::shared_ptr< ThreadsafeQueue< std::shared_ptr< const TFragment > > > > fGoodOutputQueues
uint64_t LastTriggerId() const
bool FragmentHasWaveform() const
uint64_t LastDaqId() const
uint64_t LastNetworkPacket() const
uint64_t MaxTriggerId() const
std::atomic_size_t * fItemsPopped
uint64_t fLastDaqId
The last daq ID in the raw file.
virtual void SetNoWaveForms(bool temp=true)
Definition TDataParser.h:50
void FragmentHasWaveform(const bool &val)
uint64_t fLastTriggerId
The last Trigged ID in the raw File.
TChannel * fChannel
virtual size_t ItemsPushed()
Definition TDataParser.h:88
RAW event.
Definition TRawEvent.h:23