Skip to content

[main] rootls: add flag to show RNTuple field hierarchy #19355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

silverweed
Copy link
Contributor

@silverweed silverweed commented Jul 14, 2025

This Pull request:

adds a -R flag to rootls to print RNTuple field trees recursively (similarly to the -t flag for TTree). Fields are sorted by name.

Sample output (cut for brevity):

rootls -R ~/src/iotools/data/gg_data\~zstd.ntuple
ROOT::RNTuple  Dec 18 15:55 2024 mini;1 ""
  SumWeights                 float
  XSection                   float
  channelNumber              std::int32_t
  ditau_m                    float
  eventNumber                std::int32_t
  jet_E                      std::vector<float>
    _0.......................float
  jet_MV2c10                 std::vector<float>
    _0.......................float
  jet_eta                    std::vector<float>
    _0.......................float
  jet_jvt                    std::vector<float>
    _0.......................float
  jet_n                      std::uint32_t
  jet_phi                    std::vector<float>
    _0.......................float
  jet_pt                     std::vector<float>
    _0.......................float
  jet_pt_syst                std::vector<float>
    _0.......................float
  jet_trueflav               std::vector<std::int32_t>
    _0.......................std::int32_t
  jet_truthMatched           std::vector<bool>
    _0.......................bool
  largeRjet_D2               std::vector<float>
    _0.......................float

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

Copy link
Contributor

@enirolf enirolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For TTree, rootls talks about tree rather than ttree. Do we want to keep this convention and use ntuple instead of rntuple (and with it maybe use -n instead of -R)?

I don't have a strong opinion myself, just want to mention it for consideration!

@silverweed
Copy link
Contributor Author

use ntuple instead of rntuple (and with it maybe use -n instead of -R)?

A problem I see with that is that technically we have other "ntuple" classes other than RNTuple (like TNTuple), so maybe we want to be extra specific (it's also the name that people who know it know it by so perhaps more familiar and immediately recognizable)

Copy link

github-actions bot commented Jul 14, 2025

Test Results

    21 files      21 suites   3d 9h 51m 35s ⏱️
 3 205 tests  3 205 ✅ 0 💤 0 ❌
65 648 runs  65 648 ✅ 0 💤 0 ❌

Results for commit 6da3f1c.

♻️ This comment has been updated with latest results.

@enirolf
Copy link
Contributor

enirolf commented Jul 14, 2025

use ntuple instead of rntuple (and with it maybe use -n instead of -R)?

A problem I see with that is that technically we have other "ntuple" classes other than RNTuple (like TNTuple), so maybe we want to be extra specific (it's also the name that people who know it know it by so perhaps more familiar and immediately recognizable)

Yes, that actually also came up in my mind after posting this comment. It's a good reason to keep it like this, then!

Copy link
Contributor

@enirolf enirolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@jblomer jblomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I think we should add a roottest for this.

std::size_t maxNameLen = 0, maxTypeLen = 0;
std::vector<const ROOT::RFieldDescriptor *> fields;
fields.reserve(rootField.GetLinkIds().size());
for (const auto &childId : rootField.GetLinkIds()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have GetFieldIterable with a comparator parameter. Here would be a use case for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can use GetFieldIterable() to save a line, yes, but why would I need the comparator?

@pcanal
Copy link
Member

pcanal commented Jul 15, 2025

(and with it maybe use -n instead of -R)?

Why isn't both -t and -R spelt -r[ecursive]? Why make the distinction between the 2 containers?

@silverweed
Copy link
Contributor Author

@pcanal -r already has the meaning of "show every object in the hierarchy including subdirectories" (but without expanding them). That's a useful option to have without necessarily expanding all internal structures of trees and rntuples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants