Project
Loading...
Searching...
No Matches
RawParser.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#include "DPLUtils/RawParser.h"
19#include "Headers/DataHeader.h"
20#include "fmt/format.h"
21#include <iostream>
22
24{
25
26int RawParserHelper::sErrorMode = getenv("O2_DPL_RAWPARSER_ERRORMODE") ? atoi(getenv("O2_DPL_RAWPARSER_ERRORMODE")) : 1;
27int RawParserHelper::sCheckIncompleteHBF = getenv("O2_DPL_RAWPARSER_CHECKINCOMPLETEHBF") ? atoi(getenv("O2_DPL_RAWPARSER_CHECKINCOMPLETEHBF")) : 1;
28unsigned long RawParserHelper::sErrors = 0;
29unsigned long RawParserHelper::sErrorLimit = getenv("O2_DPL_RAWPARSER_ERRORLIMIT") ? atoi(getenv("O2_DPL_RAWPARSER_ERRORLIMIT")) : 5;
30unsigned long RawParserHelper::sErrorScale = 1;
31
32bool RawParserHelper::checkPrintError(size_t& localCounter)
33{
34 localCounter++;
35 sErrors++;
36 if (sErrorLimit == 0) {
37 return false;
38 }
40 sErrorScale *= 10;
41 }
42 return sErrors % sErrorScale == 0;
43}
44
46{
48 static int contDeadBeef = 0;
49 if (++contDeadBeef <= maxWarn) {
50 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) : "");
51 }
52}
53
54void RDHFormatter<V7>::apply(std::ostream& os, V7 const& header, FormatSpec choice, const char* delimiter)
55{
56 static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>1} {:>2}";
57 if (choice == FormatSpec::Info) {
58 os << "RDH v7";
59 } else if (choice == FormatSpec::TableHeader) {
60 os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "sId", "Mem", "CRU", "EP", "LID", "s", "df");
61 } else if (choice == FormatSpec::Entry) {
62 os << fmt::format(sFormatString,
63 header.packetCounter,
64 header.pageCnt,
65 header.feeId,
66 header.sourceID,
67 header.memorySize,
68 header.cruID,
69 header.endPointID,
70 header.linkID,
71 header.stop,
72 header.dataFormat);
73 }
74 os << delimiter;
75}
76void RDHFormatter<V6>::apply(std::ostream& os, V6 const& header, FormatSpec choice, const char* delimiter)
77{
78 static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>1}";
79 if (choice == FormatSpec::Info) {
80 os << "RDH v6";
81 } else if (choice == FormatSpec::TableHeader) {
82 os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "sId", "Mem", "CRU", "EP", "LID", "s");
83 } else if (choice == FormatSpec::Entry) {
84 os << fmt::format(sFormatString,
85 header.packetCounter,
86 header.pageCnt,
87 header.feeId,
88 header.sourceID,
89 header.memorySize,
90 header.cruID,
91 header.endPointID,
92 header.linkID,
93 header.stop);
94 }
95 os << delimiter;
96}
97
98void RDHFormatter<V5>::apply(std::ostream& os, V5 const& header, FormatSpec choice, const char* delimiter)
99{
100 static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>1}";
101 if (choice == FormatSpec::Info) {
102 os << "RDH v5";
103 } else if (choice == FormatSpec::TableHeader) {
104 os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "Mem", "CRU", "EP", "LID", "s");
105 } else if (choice == FormatSpec::Entry) {
106 os << fmt::format(sFormatString,
107 header.packetCounter,
108 header.pageCnt,
109 header.feeId,
110 header.memorySize,
111 header.cruID,
112 header.endPointID,
113 header.linkID,
114 header.stop);
115 }
116 os << delimiter;
117}
118
119void RDHFormatter<V4>::apply(std::ostream& os, V4 const& header, FormatSpec choice, const char* delimiter)
120{
121 static constexpr const char* sFormatString = "{:>5} {:>4} {:>4} {:>4} {:>3} {:>3} {:>3} {:>10} {:>5} {:>1}";
122 if (choice == FormatSpec::Info) {
123 os << "RDH v4";
124 } else if (choice == FormatSpec::TableHeader) {
125 os << fmt::format(sFormatString, "PkC", "pCnt", "fId", "Mem", "CRU", "EP", "LID", "HBOrbit", "HBBC", "s");
126 } else if (choice == FormatSpec::Entry) {
127 os << fmt::format(sFormatString,
128 header.packetCounter,
129 header.pageCnt,
130 header.feeId,
131 header.memorySize,
132 header.cruID,
133 header.endPointID,
134 header.linkID,
135 header.heartbeatOrbit,
136 header.heartbeatBC,
137 header.stop);
138 }
139 os << delimiter;
140}
141
142} // namespace o2::framework::raw_parser
Generic parser for consecutive raw pages.
workspace for raw parser internal utilities
Definition RawParser.h:39
header::RAWDataHeaderV5 V5
Definition RawParser.h:354
FormatSpec
specifier for printout
Definition RawParser.h:42
header::RAWDataHeaderV6 V6
Definition RawParser.h:353
header::RAWDataHeaderV4 V4
Definition RawParser.h:355
static void apply(std::ostream &, type const &, FormatSpec, const char *="")
Definition RawParser.h:53
static void warnDeadBeef(const o2::header::DataHeader *dh)
Definition RawParser.cxx:45
static bool checkPrintError(size_t &localCounter)
Definition RawParser.cxx:32
the main header struct
Definition DataHeader.h:618
DataDescription dataDescription
Definition DataHeader.h:636
std::enable_if_t< std::is_same< T, std::string >::value==true, T > as() const
get the descriptor as std::string
Definition DataHeader.h:301
uint32_t endPointID
bit 112 to 123: CRU ID
uint32_t packetCounter
bit 96 to 103: link id
uint64_t sourceID
bit 32 to 39: priority bit
uint32_t linkID
bit 80 to 95: memory size
uint16_t cruID
bit 104 to 111: packet counter
uint64_t stop
bit 32 to 47: pages counter
uint32_t memorySize
bit 64 to 79: offset to next packet in memory
uint64_t feeId
bit 8 to 15: header size
uint64_t pageCnt
bit 0 to 31: trigger type