GRSISort
"v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TBadFragment.cxx
Go to the documentation of this file.
1
#include "
TBadFragment.h
"
2
3
TBadFragment::TBadFragment
()
4
{
5
/// Default constructor
6
Clear
();
7
}
8
9
TBadFragment::TBadFragment
(
TFragment
& fragment, uint32_t* data,
int
size,
int
failedWord,
bool
multipleErrors)
10
:
TFragment
(fragment)
11
{
12
/// Construct a bad fragment from a fragment, the data it was created from, the size of that data, and the word the
13
/// parser failed on.
14
/// The data is only copied up to and including the next header word (high nibble 0x8).
15
16
// skipping the first word, we search for the next header
17
int
numWords = 1;
18
for
(numWords = 1; numWords < size; ++numWords) {
19
if
((data[numWords] & 0xf0000000) == 0x80000000) {
20
++numWords;
// to include this header
21
break
;
22
}
23
}
24
// only copy data up to the next header (including that header)
25
// if the above loop ended w/o finding a header numWords == size,
26
// i.e. we copy all the data
27
fData
.insert(
fData
.begin(), data, data + numWords);
28
fFailedWord
= failedWord;
29
fMultipleErrors
= multipleErrors;
30
}
31
32
TBadFragment::TBadFragment
(
TFragment
& fragment)
33
:
TFragment
(fragment), fFailedWord(-2)
34
{
35
/// Construct a bad fragment from a fragment.
36
/// The data is left empty, failed word set to -2, and multiple errors set to false.
37
}
38
39
void
TBadFragment::Clear
(Option_t* opt)
40
{
41
TFragment::Clear
(opt);
42
fData
.clear();
43
fFailedWord
= -1;
44
fMultipleErrors
=
false
;
45
}
46
47
void
TBadFragment::Print
(Option_t*)
const
48
{
49
/// Print out all fields of the fragment using TFragment::Print() and then print the raw data with the failed words
50
/// highlighted/
51
TFragment::Print
();
52
53
std::cout <<
"Raw data with "
<< (
fMultipleErrors
?
"multiple errors"
:
"single error"
) <<
" failed on word "
<<
fFailedWord
<<
":"
<< std::endl;
54
size_t
index = 0;
55
for
(index = 0; index <
fData
.size(); ++index) {
56
if
(index ==
static_cast<
size_t
>
(
fFailedWord
)) {
57
std::cout <<
ALERTTEXT
;
58
}
59
std::cout <<
hex
(
fData
[index], 8);
60
if
(index ==
static_cast<
size_t
>
(
fFailedWord
)) {
61
std::cout <<
RESET_COLOR
;
62
}
63
if
(index % 10 == 9) {
64
std::cout << std::endl;
65
}
else
{
66
std::cout <<
" "
;
67
}
68
}
69
if
(index % 10 != 0) {
70
std::cout << std::endl;
// add newline if the last data word didn't have one
71
}
72
}
hex
std::string hex(T val, int width=-1)
Definition
Globals.h:129
RESET_COLOR
#define RESET_COLOR
Definition
Globals.h:5
ALERTTEXT
#define ALERTTEXT
Definition
Globals.h:35
TBadFragment.h
TBadFragment::fFailedWord
int fFailedWord
Definition
TBadFragment.h:43
TBadFragment::Clear
void Clear(Option_t *opt="") override
Definition
TBadFragment.cxx:39
TBadFragment::TBadFragment
TBadFragment()
Definition
TBadFragment.cxx:3
TBadFragment::fData
std::vector< uint32_t > fData
Definition
TBadFragment.h:42
TBadFragment::Print
void Print(Option_t *opt="") const override
Definition
TBadFragment.cxx:47
TBadFragment::fMultipleErrors
bool fMultipleErrors
Definition
TBadFragment.h:44
TFragment
Definition
TFragment.h:29
TFragment::Print
void Print(Option_t *opt="") const override
Definition
TFragment.cxx:98
TFragment::Clear
void Clear(Option_t *opt="") override
Definition
TFragment.cxx:17
libraries
TFormat
TBadFragment.cxx
GRSISort ("v4.0.0.5") Reference Guide Generated on Mon Feb 3 2025 16:38:05.