GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TLstEvent.cxx
Go to the documentation of this file.
1#include <cstdio>
2#include <cstdlib>
3#include <ctime>
4#include <cstring>
5#include <cassert>
6
7#include "TLstEvent.h"
8
10{
11 // Default constructor
12 fData.resize(0);
13}
14
15void TLstEvent::Copy(TObject& rhs) const
16{
17 // Copies the entire TLstEvent.
18 static_cast<TLstEvent&>(rhs).fData = fData;
19}
20
22{
23 // Copy ctor.
24 rhs.Copy(*this);
25}
26
31
33{
34 if(&rhs != this) {
35 Clear();
36 }
37
38 rhs.Copy(*this);
39 return *this;
40}
41
42void TLstEvent::Clear(Option_t*)
43{
44 // Clears the TLstEvent.
45 fData.clear();
46}
47
48void TLstEvent::SetData(std::vector<char>& buffer)
49{
50 // Sets the data in the TLstEvent as the data argument passed into
51 // this function.
52 fData = buffer;
53 SwapBytes(false);
54}
55
56uint32_t TLstEvent::GetDataSize() const
57{
58 return fData.size();
59}
60
62{
63 // returns the allocated data.
64 return fData.data();
65}
66
67void TLstEvent::Print(const char* option) const
68{
69 /// Print data held in this class.
70 /// \param [in] option If 'a' (for "all") then the raw data will be
71 /// printed out too.
72 ///
73
74 std::cout << "Event start:" << std::endl;
75 if(option[0] == 'a') {
76 for(size_t i = 0; i < fData.size() / 4; ++i) {
77 std::cout << hex(((uint32_t*)fData.data())[i], 8) << std::endl;
78 if(i % 10 == 9) {
79 std::cout << std::endl;
80 } else {
81 std::cout << " ";
82 }
83 }
84 }
85}
86
87using BYTE = uint8_t;
88
89/// Byte swapping routine.
90///
91#define QWORD_SWAP(x) \
92 { \
93 BYTE _tmp; \
94 _tmp = *((BYTE*)(x)); \
95 *((BYTE*)(x)) = *(((BYTE*)(x)) + 7); \
96 *(((BYTE*)(x)) + 7) = _tmp; \
97 _tmp = *(((BYTE*)(x)) + 1); \
98 *(((BYTE*)(x)) + 1) = *(((BYTE*)(x)) + 6); \
99 *(((BYTE*)(x)) + 6) = _tmp; \
100 _tmp = *(((BYTE*)(x)) + 2); \
101 *(((BYTE*)(x)) + 2) = *(((BYTE*)(x)) + 5); \
102 *(((BYTE*)(x)) + 5) = _tmp; \
103 _tmp = *(((BYTE*)(x)) + 3); \
104 *(((BYTE*)(x)) + 3) = *(((BYTE*)(x)) + 4); \
105 *(((BYTE*)(x)) + 4) = _tmp; \
106 }
107
108/// Byte swapping routine.
109///
110#define DWORD_SWAP(x) \
111 { \
112 BYTE _tmp; \
113 _tmp = *((BYTE*)(x)); \
114 *((BYTE*)(x)) = *(((BYTE*)(x)) + 3); \
115 *(((BYTE*)(x)) + 3) = _tmp; \
116 _tmp = *(((BYTE*)(x)) + 1); \
117 *(((BYTE*)(x)) + 1) = *(((BYTE*)(x)) + 2); \
118 *(((BYTE*)(x)) + 2) = _tmp; \
119 }
120
121/// Byte swapping routine.
122///
123#define WORD_SWAP(x) \
124 { \
125 BYTE _tmp; \
126 _tmp = *((BYTE*)(x)); \
127 *((BYTE*)(x)) = *(((BYTE*)(x)) + 1); \
128 *(((BYTE*)(x)) + 1) = _tmp; \
129 }
130
132{
133 return 1;
134}
135
136// end
std::string hex(T val, int width=-1)
Definition Globals.h:129
uint8_t BYTE
LST event.
Definition TLstEvent.h:22
~TLstEvent() override
destructor
Definition TLstEvent.cxx:27
int SwapBytes(bool) override
convert event data between little-endian (Linux-x86) and big endian (MacOS-PPC)
uint32_t GetDataSize() const override
return the event size
Definition TLstEvent.cxx:56
void SetData(std::vector< char > &buffer)
set an externally allocated data buffer
Definition TLstEvent.cxx:48
char * GetData() override
return pointer to the data buffer
Definition TLstEvent.cxx:61
TLstEvent()
default constructor
Definition TLstEvent.cxx:9
std::vector< char > fData
event data buffer
Definition TLstEvent.h:47
void Clear(Option_t *opt="") override
clear event for reuse
Definition TLstEvent.cxx:42
void Copy(TObject &) const override
copy helper
Definition TLstEvent.cxx:15
TLstEvent & operator=(const TLstEvent &)
assignement operator
Definition TLstEvent.cxx:32
void Print(const char *option="") const override
show all event information
Definition TLstEvent.cxx:67
RAW event.
Definition TRawEvent.h:23