Reading a std::string branch fails when using TTreeReader

I am using version 6.08.06 and I tried to read a branch containing a std::string using a TTreeReader:

TTreeReader reader(chain);

TTreeReaderValue<std::string> fileName(reader, "FileName");

Unfortunately I receive this error message when I run my macro:

Error in <TTreeReaderValueBase::GetBranchDataType()>: Unknown type and class combination: -1, string
Error in <TTreeReaderValueBase::CreateProxy()>: The branch FileName contains data of type {UNDETERMINED TYPE}, which does not have a dictionary.

However, if I read the branch like this:

std::string* fileName = nullptr;
chain->SetBranchAddress("FileName", &fileName);

It works without any problems.

It seems to be a problem specific to TTreeReaderValue. Because when I read a different branch containing a std::vector<std::string> it works without problems:

TTreeReaderArray<std::string> channelName(reader, "ChannelName");

I hope you can help me, because I would prefer to use the TTreeReader to access my tree data.

Cheers,

Achim

1 Like

Hi Achim,
I’ll check tomorrow what’s missing for TTreeReader.
Axel.

I didn’t manage today, but I didn’t forget you either…

Sloooow. But I’m able to reproduce it at least - I have a test that I will now (aka on Monday?) fix.

Axel.

Fixed in the master! I’d love to get a confirmation of that fix - can you build the master? Or if not, can you try against tomorrow’s nightly:

. /cvmfs/sft-nightlies.cern.ch/lcg/nightlies/dev3/Tue/ROOT/HEAD/x86_64-slc6-gcc62-opt/ROOT-env.sh 
root -l -b yourscript.C

Do you need this also in the next v6.08 patch release?

Thanks for reporting!

Axel.

Sorry for the delay.

I just built the master branch and I can confirm that the problem is fixed. If it is not too much work, it would be nice for us if this fix would be available within the next patch.

Thank you for your help

Cheers,

Achim

I have merged this into v6-08-00-patches, it will be part of a future 6.08/08.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.