28class RFieldBrowsable final :
public TObject {
30 std::shared_ptr<ROOT::RNTupleReader> fReader;
34 std::unique_ptr<TH1> fHistogram;
35 std::string fFieldName;
36 std::string fTypeName;
40 : fReader(reader), fFieldId(fieldId)
42 const auto &desc = fReader->GetDescriptor();
44 fIsLeaf = desc.GetFieldDescriptor(fBrowsableFieldId).GetLinkIds().empty();
45 fFieldName = desc.GetFieldDescriptor(fFieldId).GetFieldName();
46 fTypeName = desc.GetFieldDescriptor(fFieldId).GetTypeName();
49 void Browse(TBrowser *
b)
final
54 const auto &desc = fReader->GetDescriptor();
60 auto view = fReader->GetView<
void>(desc.GetQualifiedFieldName(fBrowsableFieldId));
62 ROOT::Internal::RNTupleDrawVisitor drawVisitor(fReader, desc.GetFieldDescriptor(fFieldId).GetFieldName());
63 view.GetField().AcceptVisitor(drawVisitor);
64 fHistogram = std::unique_ptr<TH1>(drawVisitor.MoveHist());
65 if (fHistogram->GetEntries() == 0) {
66 gPad->DrawFrame(-1., -1., 1., 1.);
67 TText *textEmpty =
new TText(0., 0.,
"Empty");
78 for (
const auto &
f : desc.GetFieldIterable(fBrowsableFieldId)) {
79 b->Add(
new RFieldBrowsable(fReader,
f.GetId()),
f.GetFieldName().c_str());
84 bool IsFolder() const final {
return !fIsLeaf; }
85 const char *GetIconName() const final {
return IsFolder() ?
"RNTuple-folder" :
"RNTuple-leaf"; }
87 const char *GetName() const final {
return fFieldName.c_str(); }
88 const char *GetTitle() const final {
return fTypeName.c_str(); }
91class RVisualizationBrowsable :
public TObject {
93 std::unique_ptr<ROOT::Experimental::RNTupleInspector> fInspector;
94 std::unique_ptr<ROOT::Experimental::RTreeMapPainter> fTreeMap;
97 RVisualizationBrowsable(
const ROOT::RNTuple &ntuple)
98 : fInspector(ROOT::Experimental::RNTupleInspector::Create(ntuple))
101 void Browse(TBrowser *
b)
final
105 gPad->GetListOfPrimitives()->Clear();
111 const char *GetIconName() const final {
return "RNTuple-visualization"; }
112 bool IsFolder() const final {
return false; }
113 const char *GetName() const final {
return "Visualization"; }
114 const char *GetTitle() const final {
return "TreeMap visualization of RNTuple structure and disk usage"; }
125 const auto &desc = reader->GetDescriptor();
126 b->Add(
new RVisualizationBrowsable(*
static_cast<const ROOT::RNTuple *
>(ntuple)),
"Visualization");
127 for (
const auto &
f : desc.GetTopLevelFields()) {
128 b->Add(
new RFieldBrowsable(reader,
f.GetId()),
f.GetFieldName().c_str());
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
Representation of an RNTuple data set in a ROOT file.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Using a TBrowser one can browse all ROOT objects.
Mother of all ROOT objects.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
std::unique_ptr< RTreeMapPainter > CreateTreeMapFromRNTuple(const RNTupleInspector &insp)
Logic for converting an RNTuple to RTreeMapPainter given RNTupleInspector.
void BrowseRNTuple(const void *ntuple, TBrowser *b)
DescriptorId_t GetNextBrowsableField(DescriptorId_t fieldId, const RNTupleDescriptor &desc)
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr DescriptorId_t kInvalidDescriptorId