Branch Typecode

Dear ROOTers,

Is it possible to obtain the typecode for a given leaf? From the ROOT docs:

- C : a character string terminated by the 0 character - B : an 8 bit signed integer (Char_t) - b : an 8 bit unsigned integer (UChar_t) - S : a 16 bit signed integer (Short_t) - s : a 16 bit unsigned integer (UShort_t) - I : a 32 bit signed integer (Int_t) - i : a 32 bit unsigned integer (UInt_t) - F : a 32 bit floating point (Float_t) - D : a 64 bit floating point (Double_t) - L : a 64 bit signed integer (Long64_t) - l : a 64 bit unsigned integer (ULong64_t) - O : a boolean (Bool_t)

Or do I have to convert them from TLeaf::GetTypeName() back to the relevant character via a map?

Also, how to obtain this size specifier?

By default, a variable will be copied to the buffer with the number of bytes specified in the type descriptor character. However, if the type consists of 2 characters, the second character is an integer that specifies the number of bytes to be used when copying the variable to the output buffer. Example: X ; variable X, type Float_t Y/I : variable Y, type Int_t Y/I2 ; variable Y, type Int_t converted to a 16 bits integer

TLeaf::GetLenType() ?


  • Pete


The original type request is store (along with the name) in the title of the leaf. you will find there both the typecode and type specifier.

Out of curiosity, what lead you to need this information in that format?


I’ve written an application which transforms ntuples. You specify an input tuple, an output tuple and a list of transformations (in python). C++ does the grunt work. Transformations can either just copy a leaf, be an arbitrary formula or a C++ object which does some computation. It previously only coped with the float type, but I wanted to generalise it.