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
4{
5 /// Default constructor
6 Clear();
7}
8
9TBadFragment::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
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
39void TBadFragment::Clear(Option_t* opt)
40{
42 fData.clear();
43 fFailedWord = -1;
44 fMultipleErrors = false;
45}
46
47void 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/
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}
std::string hex(T val, int width=-1)
Definition Globals.h:129
#define RESET_COLOR
Definition Globals.h:5
#define ALERTTEXT
Definition Globals.h:35
void Clear(Option_t *opt="") override
std::vector< uint32_t > fData
void Print(Option_t *opt="") const override
bool fMultipleErrors
void Print(Option_t *opt="") const override
Definition TFragment.cxx:98
void Clear(Option_t *opt="") override
Definition TFragment.cxx:17