19#include <fmt/format.h>
28std::string quote(std::string
const& s)
30 std::string out =
"\"";
31 for (
unsigned char c :
s) {
32 if (
c ==
'"' ||
c ==
'\\') {
35 }
else if (
c < 0x20) {
36 out += fmt::format(
"\\u{:04x}",
c);
44char const* boolean(
bool b)
46 return b ?
"true" :
"false";
51 auto&
h =
file.header();
53 fmt::print(R
"( "header": {{"version": {}, "begin": {}, "end": {}, "seekFree": {}, "nbytesFree": {}, "nfree": {}, )"
54 R"("nbytesName": {}, "units": {}, "compress": {}, "seekInfo": {}, "nbytesInfo": {}}},)"
56 h.version,
h.begin,
h.end,
h.seekFree,
h.nbytesFree,
h.nfree,
h.nbytesName, (
int)
h.units,
h.compress,
h.seekInfo,
h.nbytesInfo);
57 fmt::print(R
"( "keys": [)");
58 char const* sep =
"\n";
59 for (
auto& k :
file.topKeys()) {
60 fmt::print(R
"({} {{"name": {}, "class": {}, "cycle": {}, "seek": {}, "nbytes": {}, "objlen": {}}})",
61 sep, quote(k.name), quote(k.className), k.cycle, k.seekKey, k.nbytes, k.objlen);
64 fmt::print(
"\n ],\n");
65 fmt::print(R
"( "dataFrames": [)");
66 char const* dfSep =
"\n";
67 for (
auto& df :
file.dataFrames()) {
68 fmt::print(R
"({} {{"name": {}, "trees": [)", dfSep, quote(df));
70 char const* treeSep =
"\n";
71 for (
auto&
key :
file.keysOf(df)) {
72 if (
key.className !=
"TTree") {
76 fmt::print(R
"({} {{"name": {}, "entries": {}, "totBytes": {}, "zipBytes": {}, "branches": [)",
79 char const* branchSep =
"\n";
80 for (
auto&
b :
tree.branches) {
81 fmt::print(R
"({} {{"name": {}, "leaf": "TLeaf{}", "len": {}, "isUnsigned": {}, "countBranch": {}, )"
82 R"("entries": {}, "totBytes": {}, "zipBytes": {}, "baskets": [)",
83 branchSep, quote(b.name), b.leafClass, b.fixedLen, boolean(
b.isUnsigned), quote(
b.countBranch),
84 b.entries,
b.totBytes,
b.zipBytes);
86 char const* basketSep =
"";
87 for (
auto& basket :
b.baskets) {
88 fmt::print(
"{}[{}, {}, {}, {}, {}]", basketSep, basket.seek, basket.nbytes, basket.firstEntry, basket.nEntries,
89 boolean(basket.embedded));
98 fmt::print(
"\n ]\n}}\n");
103 auto&
h =
file.header();
104 fmt::print(
"ROOT file version {}, begin {}, end {}, compression {}, {} seeks\n",
h.version,
h.begin,
h.end,
h.compress,
105 h.version >= 1000000 ?
"64-bit" :
"32-bit");
106 fmt::print(
"\n{:<32} {:<16} {:>5} {:>14} {:>10} {:>10}\n",
"key",
"class",
"cycle",
"seek",
"nbytes",
"objlen");
107 for (
auto& k :
file.topKeys()) {
108 fmt::print(
"{:<32} {:<16} {:>5} {:>14} {:>10} {:>10}\n", k.name, k.className, k.cycle, k.seekKey, k.nbytes, k.objlen);
110 for (
auto& df :
file.dataFrames()) {
111 fmt::print(
"\n{}\n", df);
112 for (
auto&
key :
file.keysOf(df)) {
113 if (
key.className !=
"TTree") {
114 fmt::print(
" {} ({}, skipped)\n",
key.name,
key.className);
118 fmt::print(
" {}: {} entries, {} bytes, {} compressed\n",
tree.name,
tree.entries,
tree.totBytes,
tree.zipBytes);
119 for (
auto&
b :
tree.branches) {
120 fmt::print(
" {:<28} TLeaf{}{} len {}{}{}, {} baskets:",
b.name,
b.leafClass,
b.isUnsigned ?
" unsigned" :
"",
121 b.fixedLen,
b.countBranch.
empty() ?
"" :
", count ",
b.countBranch,
b.baskets.
size());
122 for (
auto& basket :
b.baskets) {
123 if (basket.embedded) {
124 fmt::print(
" [embedded {}+{}]", basket.firstEntry, basket.nEntries);
126 fmt::print(
" [{}:{} {}+{}]", basket.seek, basket.nbytes, basket.firstEntry, basket.nEntries);
140 for (
int i = 1;
i < argc; ++
i) {
141 if (std::strcmp(argv[
i],
"--json") == 0) {
143 }
else if (
path.empty()) {
151 fmt::print(stderr,
"usage: {} <file> [--json]\n", argv[0]);
163 fmt::print(stderr,
"{}: {}\n", argv[0], e.what());
Class for time synchronization of RawReader instances.
static std::unique_ptr< ByteSource > open(std::string url, const Options &)
GLboolean GLboolean GLboolean b
GLsizei const GLchar *const * path
int32_t const char * file
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))