-
Notifications
You must be signed in to change notification settings - Fork 511
Expand file tree
/
Copy pathRawParser.cxx
More file actions
142 lines (132 loc) · 5.59 KB
/
Copy pathRawParser.cxx
File metadata and controls
142 lines (132 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// @file RawParser.cxx
/// @author Matthias Richter
/// @since 2019-10-15
/// @brief Generic parser for consecutive raw pages
#include "DPLUtils/RawParser.h"
#include "CommonUtils/VerbosityConfig.h"
#include "Headers/DataHeader.h"
#include "fmt/format.h"
#include <iostream>
namespace o2::framework::raw_parser
{
int RawParserHelper::sErrorMode = getenv("O2_DPL_RAWPARSER_ERRORMODE") ? atoi(getenv("O2_DPL_RAWPARSER_ERRORMODE")) : 1;
int RawParserHelper::sCheckIncompleteHBF = getenv("O2_DPL_RAWPARSER_CHECKINCOMPLETEHBF") ? atoi(getenv("O2_DPL_RAWPARSER_CHECKINCOMPLETEHBF")) : 1;
unsigned long RawParserHelper::sErrors = 0;
unsigned long RawParserHelper::sErrorLimit = getenv("O2_DPL_RAWPARSER_ERRORLIMIT") ? atoi(getenv("O2_DPL_RAWPARSER_ERRORLIMIT")) : 5;
unsigned long RawParserHelper::sErrorScale = 1;
bool RawParserHelper::checkPrintError(size_t& localCounter)
{
localCounter++;
sErrors++;
if (sErrorLimit == 0) {
return false;
}
if (sErrors > sErrorLimit * sErrorScale) {
sErrorScale *= 10;
}
return sErrors % sErrorScale == 0;
}
void RawParserHelper::warnDeadBeef(const o2::header::DataHeader* dh)
{
static auto maxWarn = o2::conf::VerbosityConfig::Instance().maxWarnDeadBeef;
static int contDeadBeef = 0;
if (++contDeadBeef <= maxWarn) {
LOGP(alarm, "Found input [{}/{}/0xDEADBEEF] assuming no payload for all links in this TF{}", dh->dataOrigin.as<std::string>(), dh->dataDescription.as<std::string>(), contDeadBeef == maxWarn ? fmt::format(". {} such inputs in row received, stopping reporting", contDeadBeef) : "");
}
}
void RDHFormatter<V7>::apply(std::ostream& os, V7 const& header, FormatSpec choice, const char* delimiter)
{
static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>1} {:>2}";
if (choice == FormatSpec::Info) {
os << "RDH v7";
} else if (choice == FormatSpec::TableHeader) {
os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "sId", "Mem", "CRU", "EP", "LID", "s", "df");
} else if (choice == FormatSpec::Entry) {
os << fmt::format(sFormatString,
header.packetCounter,
header.pageCnt,
header.feeId,
header.sourceID,
header.memorySize,
header.cruID,
header.endPointID,
header.linkID,
header.stop,
header.dataFormat);
}
os << delimiter;
}
void RDHFormatter<V6>::apply(std::ostream& os, V6 const& header, FormatSpec choice, const char* delimiter)
{
static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>1}";
if (choice == FormatSpec::Info) {
os << "RDH v6";
} else if (choice == FormatSpec::TableHeader) {
os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "sId", "Mem", "CRU", "EP", "LID", "s");
} else if (choice == FormatSpec::Entry) {
os << fmt::format(sFormatString,
header.packetCounter,
header.pageCnt,
header.feeId,
header.sourceID,
header.memorySize,
header.cruID,
header.endPointID,
header.linkID,
header.stop);
}
os << delimiter;
}
void RDHFormatter<V5>::apply(std::ostream& os, V5 const& header, FormatSpec choice, const char* delimiter)
{
static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>1}";
if (choice == FormatSpec::Info) {
os << "RDH v5";
} else if (choice == FormatSpec::TableHeader) {
os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "Mem", "CRU", "EP", "LID", "s");
} else if (choice == FormatSpec::Entry) {
os << fmt::format(sFormatString,
header.packetCounter,
header.pageCnt,
header.feeId,
header.memorySize,
header.cruID,
header.endPointID,
header.linkID,
header.stop);
}
os << delimiter;
}
void RDHFormatter<V4>::apply(std::ostream& os, V4 const& header, FormatSpec choice, const char* delimiter)
{
static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>10} {:>5} {:>1}";
if (choice == FormatSpec::Info) {
os << "RDH v4";
} else if (choice == FormatSpec::TableHeader) {
os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "Mem", "CRU", "EP", "LID", "HBOrbit", "HBBC", "s");
} else if (choice == FormatSpec::Entry) {
os << fmt::format(sFormatString,
header.packetCounter,
header.pageCnt,
header.feeId,
header.memorySize,
header.cruID,
header.endPointID,
header.linkID,
header.heartbeatOrbit,
header.heartbeatBC,
header.stop);
}
os << delimiter;
}
} // namespace o2::framework::raw_parser