Skip to content

[ntuple] Add RField description members#7399

Merged
jblomer merged 3 commits intoroot-project:masterfrom
mxxo:rfield-desc
Mar 12, 2021
Merged

[ntuple] Add RField description members#7399
jblomer merged 3 commits intoroot-project:masterfrom
mxxo:rfield-desc

Conversation

@mxxo
Copy link
Copy Markdown
Contributor

@mxxo mxxo commented Mar 6, 2021

Allow setting RNTuple field descriptions. The immediate motivation for this PR is for use by the ongoing CMS RNTuple NanoAOD output module. The new APIs are a direct analogue to TBranch::SetTitle. Field descriptions are added at the RNTupleModel level. There currently is no way to adjust field descriptions after creation.

There is a new RNTupleModel::AddField overload that takes a description parameter and a new RNTupleModel::MakeFieldWithDescription method. The latter was added because of difficulties overloading the existing variadic template method MakeField.

@mxxo mxxo requested a review from jblomer March 6, 2021 21:18
@mxxo mxxo requested a review from pcanal as a code owner March 6, 2021 21:18
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-fedora30/cxx14, ROOT-fedora31/noimt, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@mxxo mxxo changed the title [ntuple] Add RField descriptions members [ntuple] Add RField description members Mar 6, 2021
Copy link
Copy Markdown
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.

Very nice! My only concern is the name MakeFieldWithDescription, which is a little long for my taste. How about MakeField and AddField overloads that take a tuple as a first parameter, so that you can write

MakeField<float>({"pt", "transverse momentum"}, 0.0);

for (auto& f: ntuple->GetDescriptor().GetTopLevelFields()) {
fieldDescriptions.push_back(f.GetFieldDescription());
}
ASSERT_EQ(fieldDescriptions.size(), 3);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Arguments of ASSERT_EQ and EXPECT_EQ should be reversed

@mxxo
Copy link
Copy Markdown
Contributor Author

mxxo commented Mar 9, 2021

I like the tuple approach much better! I'm struggling to build master right now but will rebase with this change as soon as I can.

RFieldDescriptor already has a descriptor member, so descriptions
are already written to and read from the header but are always empty.

The next step is to allow setting field descriptions at the
RNTupleModel level.
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-fedora30/cxx14, ROOT-fedora31/noimt, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

Add overloads to RNTupleModel's field creation methods to allow
setting field descriptions.
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-fedora30/cxx14, ROOT-fedora31/noimt, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

Also ensure that models as fields get their description
set accordingly.
@mxxo mxxo requested a review from jblomer March 10, 2021 00:09
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-fedora30/cxx14, ROOT-fedora31/noimt, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Copy Markdown

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Errors:

  • [2021-03-10T00:16:12.056Z] LINK : fatal error LNK1104: cannot open file 'C:\build\workspace\root-pullrequests-build\build\bin\libCore.dll' [C:\build\workspace\root-pullrequests-build\build\core\Core.vcxproj]

Copy link
Copy Markdown
Contributor

@jalopezg-git jalopezg-git left a comment

Choose a reason for hiding this comment

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

I was wondering where the field description was [already] serialized/deserialized; I found it in RNTupleDescriptor.cxx: SerializeField().

LGTM. :-)

@jblomer jblomer merged commit d43d4be into root-project:master Mar 12, 2021
mxxo added a commit to mxxo/cmssw that referenced this pull request Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants