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