Getting the TBranch variable type letter

Dear ROOT experts,

I am trying to get the TBranch variable type letter (as described in Case A of the TTree documentation [1]) of an existing branch. With branch.FindLeaf(branch.GetName()).GetTypeName() I manage to get the full type name (eg. Float_t), however, I require the letter only. Effectively, I need this to create another branch of the exactly same type which contains a subset of the original objects in a vector.

I could not find anything in the documentation that achieves this. Maybe I overlooked something simple…

Could you please help me with this?

Best regards,


ROOT Version: 6.12.07
Platform: Linux
Compiler: slc6_amd64_gcc700

Caveat: I am not an expert.
The code that actually parses the Leaflist string and makes leaves of different types is hardcoded here:

The easiest solution for scalars would probably be to code up your own mapping function or array between the letter codes and the types, since the list is pretty short. If you also need to deal with arrays of values in the branches, looking into cloning the branch might be more productive.

See also the (private) function:

Nice, copying some of that code will make it easier to write your own mapping function.

I’m sure there’s a joke about “reading the TLeafs”…

Dear @jfcaron, @pcanal,

Thank you for your prompt responses.

Yes, I actually started making my own mapping function, however, I was hoping that there would be something less hard-coded like a simple method that one could call “GetTypeChar()” :slight_smile:

Either way, I will manage to proceed!

Best wishes,

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