33 out << fmt::format(
"BCid: 0x{:x} Orbit: 0x{:x} EvtType: {:d}", rof.interactionRecord.bc, rof.interactionRecord.orbit, (
int)rof.eventType) << std::endl;
34 for (
auto colIt = decoder.
getData().begin() + rof.firstEntry; colIt != decoder.
getData().begin() + rof.firstEntry + rof.nEntries; ++colIt) {
35 out << *colIt << std::endl;
40int main(
int argc,
char* argv[])
43 po::options_description
generic(
"Generic options");
44 std::string outFilename =
"";
45 unsigned long int nHBs = 0;
46 unsigned long int firstHB = 0;
50 (
"help",
"produce help message")
51 (
"output", po::value<std::string>(&outFilename),
"Output text file")
52 (
"first", po::value<unsigned long int>(&firstHB),
"First HB to read")
53 (
"nHBs", po::value<unsigned long int>(&nHBs),
"Number of HBs read")
54 (
"rdh-only", po::value<bool>()->implicit_value(
true),
"Only show RDHs")
55 (
"decode", po::value<bool>()->implicit_value(
true),
"Decode output")
56 (
"feeId-config-file", po::value<std::string>()->default_value(
""),
"Filename with crate FEE ID correspondence")
57 (
"electronics-delay-file", po::value<std::string>()->default_value(
""),
"Filename with electronics delay");
60 po::options_description hidden(
"hidden options");
62 (
"input", po::value<std::vector<std::string>>(),
"Input filename");
65 po::options_description cmdline;
66 cmdline.add(generic).add(hidden);
68 po::positional_options_description
pos;
71 po::store(po::command_line_parser(argc, argv).options(cmdline).positional(
pos).run(), vm);
74 if (vm.count(
"help")) {
75 std::cout <<
"Usage: " << argv[0] <<
" <input_raw_filename> [input_raw_filename_1 ...]\n";
76 std::cout <<
generic << std::endl;
79 if (vm.count(
"input") == 0) {
80 std::cout <<
"no input file specified" << std::endl;
84 std::vector<std::string> inputfiles{vm[
"input"].as<std::vector<std::string>>()};
86 bool runDecoder = (vm.count(
"decode") > 0 && vm[
"decode"].as<
bool>() ==
true);
87 std::unique_ptr<o2::mid::Decoder> decoder{
nullptr};
89 std::ofstream outFile;
90 std::ostream& out = (outFilename.empty()) ? std::cout : (outFile.open(outFilename), outFile);
92 unsigned long int iHB = 0;
93 bool isRdhOnly = vm.count(
"rdh-only") > 0;
102 while (rawFileReader.
readHB()) {
103 if (iHB >= firstHB) {
105 auto it = parser.
begin();
109 gsl::span<const uint8_t> payload(it.data(), it.size());
112 decoder =
o2::mid::createDecoder(*rdhPtr,
true, vm[
"electronics-delay-file"].as<std::string>().c_str(),
"", vm[
"feeId-config-file"].as<std::string>().c_str());
114 decode(*decoder, payload, *rdhPtr, out);
115 }
else if (!isRdhOnly) {
117 size_t wordLength = isBare ? 16 : 32;
118 for (
size_t iword = 0; iword < payload.size(); iword += wordLength) {
119 auto word = payload.subspan(iword, wordLength);
121 for (
auto it = word.rbegin(); it != word.rend(); ++it) {
122 auto ibInWord = word.rend() - it;
123 if (ibInWord == 4 || ibInWord == 9) {
126 if (ibInWord == 5 || ibInWord == 10) {
129 out << fmt::format(
"{:02x}",
static_cast<int>(*it));
132 for (
auto it = word.begin(); it != word.end(); ++it) {
133 out << fmt::format(
"{:02x}",
static_cast<int>(*it));
141 rawFileReader.
clear();
143 if (nHBs > 0 && iHB >= nHBs + firstHB) {
std::unique_ptr< Decoder > createDecoder(const o2::header::RDHAny &rdh, bool isDebugMode, const ElectronicsDelay &electronicsDelay, const CrateMasks &crateMasks, const FEEIdConfig &feeIdConfig)