Skip to content

Commit a1da2be

Browse files
magnustymoteussilverweed
authored andcommitted
[ntuplebrowse] Add CreateTreeMapFromRNTuple
1 parent c98110a commit a1da2be

File tree

6 files changed

+62
-38
lines changed

6 files changed

+62
-38
lines changed

gui/treemap/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTTreeMap
1515
ROOT/RTreeMapPainter.hxx
1616
SOURCES
1717
RTreeMapBase.cxx
18-
RTreeMapImporter.cxx
1918
RTreeMapPainter.cxx
2019
DEPENDENCIES
21-
ROOTNTuple
22-
ROOTNTupleUtil
2320
Gpad
2421
RIO
2522
)

gui/treemap/inc/ROOT/RTreeMapPainter.hxx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include <vector>
2727

2828
namespace ROOT::Experimental {
29-
class RNTupleInspector;
30-
3129
// clang-format off
3230
/**
3331
\class ROOT::Experimental::RTreeMapPainter
@@ -36,22 +34,14 @@ class RNTupleInspector;
3634
3735
One can visualize an RNTuple in a TCanvas as a treemap like this:
3836
~~~ {.cpp}
39-
auto tm = RTreeMapPainter::ImportRNTuple("file.root", "ntuple_name");
37+
auto tm = ROOT::Experimental::CreateTreeMapFromRNTuple("file.root", "ntuple_name");
4038
auto c = new TCanvas("c_tm","TreeMap");
4139
c->Add(tm.release());
4240
~~~
4341
*/
4442
// clang-format on
4543
class RTreeMapPainter final : public ROOT::Experimental::RTreeMapBase, public TObject {
4644
public:
47-
/////////////////////////////////////////////////////////////////////////////
48-
/// \brief Logic for converting an RNTuple to RTreeMapPainter given RNTupleInspector
49-
static std::unique_ptr<RTreeMapPainter> ImportRNTuple(const ROOT::Experimental::RNTupleInspector &insp);
50-
51-
/////////////////////////////////////////////////////////////////////////////
52-
/// \brief Logic for converting an RNTuple to RTreeMapPainter given file and tuple names
53-
static std::unique_ptr<RTreeMapPainter> ImportRNTuple(std::string_view sourceFileName, std::string_view tupleName);
54-
5545
struct Node final : public ROOT::Experimental::RTreeMapBase::Node, public TObject {
5646
public:
5747
ClassDefOverride(Node, 1);
@@ -74,4 +64,4 @@ private:
7464
bool alignCenter = false) const final;
7565
};
7666
} // namespace ROOT::Experimental
77-
#endif
67+
#endif

tree/ntuplebrowse/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ HEADERS
1414
ROOT/RNTupleBrowseUtils.hxx
1515
ROOT/RNTupleClassicBrowse.hxx
1616
ROOT/RNTupleDrawVisitor.hxx
17+
ROOT/RNTupleTreeMap.hxx
1718
SOURCES
1819
src/RNTupleBrowseUtils.cxx
1920
src/RNTupleClassicBrowse.cxx
2021
src/RNTupleDrawVisitor.cxx
22+
src/RNTupleTreeMap.cxx
2123
LINKDEF
2224
LinkDef.h
2325
DEPENDENCIES
@@ -26,6 +28,7 @@ DEPENDENCIES
2628
Graf
2729
Hist
2830
ROOTNTuple
31+
ROOTNTupleUtil
2932
ROOTTreeMap
3033
)
3134

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// \file ROOT/RNTupleTreeMap.hxx
2+
/// \ingroup NTuple
3+
/// \author Patryk Tymoteusz Pilichowski <[email protected]>
4+
/// \date 2025-09-15
5+
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6+
/// is welcome!
7+
8+
/*************************************************************************
9+
* Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. *
10+
* All rights reserved. *
11+
* *
12+
* For the licensing terms see $ROOTSYS/LICENSE. *
13+
* For the list of contributors see $ROOTSYS/README/CREDITS. *
14+
*************************************************************************/
15+
16+
#ifndef ROOT_RNTupleTreeMap
17+
#define ROOT_RNTupleTreeMap
18+
19+
#include <ROOT/RNTupleInspector.hxx>
20+
#include <ROOT/RTreeMapPainter.hxx>
21+
22+
#include <memory>
23+
#include <string>
24+
25+
namespace ROOT {
26+
namespace Experimental {
27+
/////////////////////////////////////////////////////////////////////////////
28+
/// \brief Logic for converting an RNTuple to RTreeMapPainter given RNTupleInspector
29+
std::unique_ptr<RTreeMapPainter> CreateTreeMapFromRNTuple(const RNTupleInspector &insp);
30+
31+
/////////////////////////////////////////////////////////////////////////////
32+
/// \brief Logic for converting an RNTuple to RTreeMapPainter given file and tuple names
33+
std::unique_ptr<RTreeMapPainter> CreateTreeMapFromRNTuple(std::string_view sourceFileName, std::string_view tupleName);
34+
} // namespace Experimental
35+
36+
} // namespace ROOT
37+
38+
#endif

tree/ntuplebrowse/src/RNTupleClassicBrowse.cxx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717
#include <ROOT/RNTupleDrawVisitor.hxx>
1818
#include <ROOT/RNTupleDescriptor.hxx>
1919
#include <ROOT/RNTupleReader.hxx>
20-
#include <ROOT/RTreeMapPainter.hxx>
21-
#include <ROOT/RNTupleInspector.hxx>
20+
#include <ROOT/RNTupleTreeMap.hxx>
2221

2322
#include <TBrowser.h>
2423
#include <TObject.h>
2524
#include <TPad.h>
2625
#include <TText.h>
2726

28-
#include <memory>
29-
#include <string>
30-
3127
namespace {
3228

3329
class RFieldBrowsable final : public TObject {
@@ -108,7 +104,7 @@ class RVisualizationBrowsable : public TObject {
108104
if (!b || !gPad)
109105
return;
110106
gPad->GetListOfPrimitives()->Clear();
111-
fTreeMap = ROOT::Experimental::RTreeMapPainter::ImportRNTuple(*fInspector);
107+
fTreeMap = ROOT::Experimental::CreateTreeMapFromRNTuple(*fInspector);
112108
fTreeMap->Paint("");
113109
gPad->Update();
114110
}

gui/treemap/src/RTreeMapImporter.cxx renamed to tree/ntuplebrowse/src/RNTupleTreeMap.cxx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/// \file RTreeMapImporter.cxx
2-
/// \ingroup TreeMap ROOT7
1+
/// \file ROOT/RNTupleTreeMap.cxx
2+
/// \ingroup NTuple
33
/// \author Patryk Tymoteusz Pilichowski <[email protected]>
4-
/// \date 2025-08-21
4+
/// \date 2025-09-15
55
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
66
/// is welcome!
77

@@ -13,32 +13,31 @@
1313
* For the list of contributors see $ROOTSYS/README/CREDITS. *
1414
*************************************************************************/
1515

16-
#include <ROOT/RTreeMapPainter.hxx>
17-
#include <ROOT/RNTupleInspector.hxx>
16+
#include <ROOT/RNTupleTreeMap.hxx>
1817
#include <ROOT/RColumnElementBase.hxx>
1918

2019
#include <queue>
2120

22-
using namespace ROOT::Experimental;
23-
24-
static RTreeMapBase::Node CreateNode(const RNTupleInspector &insp, const ROOT::RFieldDescriptor &fldDesc,
25-
std::uint64_t childrenIdx, std::uint64_t nChildren, ROOT::DescriptorId_t rootId,
26-
size_t rootSize)
21+
static ROOT::Experimental::RTreeMapBase::Node
22+
CreateNode(const ROOT::Experimental::RNTupleInspector &insp, const ROOT::RFieldDescriptor &fldDesc,
23+
std::uint64_t childrenIdx, std::uint64_t nChildren, ROOT::DescriptorId_t rootId, size_t rootSize)
2724
{
2825
uint64_t size =
2926
(rootId != fldDesc.GetId()) ? insp.GetFieldTreeInspector(fldDesc.GetId()).GetCompressedSize() : rootSize;
3027
return {fldDesc.GetFieldName(), "", size, childrenIdx, nChildren};
3128
}
3229

33-
static RTreeMapBase::Node CreateNode(const RNTupleInspector::RColumnInspector &colInsp, std::uint64_t childrenIdx)
30+
static ROOT::Experimental::RTreeMapBase::Node
31+
CreateNode(const ROOT::Experimental::RNTupleInspector::RColumnInspector &colInsp, std::uint64_t childrenIdx)
3432
{
3533
return {"", ROOT::Internal::RColumnElementBase::GetColumnTypeName(colInsp.GetType()), colInsp.GetCompressedSize(),
3634
childrenIdx, 0};
3735
}
3836

39-
std::unique_ptr<RTreeMapPainter> RTreeMapPainter::ImportRNTuple(const ROOT::Experimental::RNTupleInspector &insp)
37+
std::unique_ptr<ROOT::Experimental::RTreeMapPainter>
38+
ROOT::Experimental::CreateTreeMapFromRNTuple(const ROOT::Experimental::RNTupleInspector &insp)
4039
{
41-
auto treemap = std::make_unique<RTreeMapPainter>();
40+
auto treemap = std::make_unique<ROOT::Experimental::RTreeMapPainter>();
4241
const auto &descriptor = insp.GetDescriptor();
4342
const auto rootId = descriptor.GetFieldZero().GetId();
4443
size_t rootSize = 0;
@@ -83,8 +82,9 @@ std::unique_ptr<RTreeMapPainter> RTreeMapPainter::ImportRNTuple(const ROOT::Expe
8382
return treemap;
8483
}
8584

86-
std::unique_ptr<RTreeMapPainter> RTreeMapPainter::ImportRNTuple(std::string_view sourceFileName, std::string_view tupleName)
85+
std::unique_ptr<ROOT::Experimental::RTreeMapPainter>
86+
ROOT::Experimental::CreateTreeMapFromRNTuple(std::string_view sourceFileName, std::string_view tupleName)
8787
{
88-
auto insp = RNTupleInspector::Create(tupleName, sourceFileName);
89-
return RTreeMapPainter::ImportRNTuple(*insp);
90-
}
88+
auto insp = ROOT::Experimental::RNTupleInspector::Create(tupleName, sourceFileName);
89+
return CreateTreeMapFromRNTuple(*insp);
90+
}

0 commit comments

Comments
 (0)