Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

std::string branches cannot be interpreted #63

Closed
douglasdavis opened this issue Mar 19, 2018 · 2 comments
Closed

std::string branches cannot be interpreted #63

douglasdavis opened this issue Mar 19, 2018 · 2 comments

Comments

@douglasdavis
Copy link

I'm saving a few std::strings as single entry branches as meta data in a tree. To retrieve that data I'm trying to just use the structure:

>>> meta_info_str = uproot.open('file.root')['tree'].array('meta')[0]

Where meta is an std::string branch.

I'm getting the ValueError:

cannot interpret branch b'meta' as a Python type

They are saved in C++ as follows:

/// header .. define class member
TTree* m_tree;
std::string m_some_meta_string;
/// in source .. set the branch
m_tree = new TTree("tree","tree");
m_tree->Branch("meta",&m_some_meta_string);
/// later assign it
m_some_meta_string = function_which_returns_a_string();

An example file can be found here: https://phy.duke.edu/~ddavis/public/example.root
The tree with some strings is called WtLoop_meta. String branches include generator, sampleType, campaign, and initialState. If I use tree.show() I see a None interpretation for the strings.

Docs say that uproot should be able to figure out std::string, am I screwing something up (e.g. saving the string to the ROOT file in a way that's incompatible with uproot)?

Using ROOT v6-10-08 to create the file and uproot v2.8.8 to read.

jpivarski added a commit that referenced this issue Mar 19, 2018
@jpivarski
Copy link
Member

A correction is on its way: it will be version 2.8.9 (in master now; going through CI tests). Thanks for the sample file— having it makes the debugging quick!

@douglasdavis
Copy link
Author

Works like a charm, thanks a lot!

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

No branches or pull requests

2 participants