I want to extract the data from a TLeafElement and convert it to a string. Is there a easy way to do that?
I assume that your leaf contains any type of data (int, float, double, etc)
In this case use TLeafElement::GetValue and use of the C/C++ tools to
convert to a string, eg
If the leaf contains a string, use GetValuePointer, eg
That didnt sound too complicated, but do i recognize if it is a int,char or etc? and how do i handle pointers?
May be you should explain first what you are trying to do. In general, you should not have to call these functions.
well what i need to do the same as Leaf:show() but instead of getting the result printed i want to into strings. So if show() shows three varibles with data i want the data into three diffrent strings.
i’ve done it so far with integer and reals (but i put the data into integers and reals then), which works fine. But a TLeafElement is own defined object and because the data can whatever i want it into strings. I don’t know how to handle that.
Thank you for the help so far,
You could use a TTreeFormula and have to deal only with double (or even use TTreeFormula::PrintValue). See TTreePlayer::Scan for some usage.
How could i use TTreeFormula ? I don’t get how it could be used.
This is how i do it for integers:
Int_t value = (Int_t)leaf->GetValuePointer();
but i want the TLeafElement(bc of a TLeafElement can be anything) into chars. i get results like
EventInfo = NULL
m_event_ID = (EventID*)11e2a60
m_event_type = (EventType*)11ebcd0
m_trigger_info = (TriggerInfo*)0
when i use show(3). I want that data (which looks to me like it’s pointers) into charstrings that looks like “[(EventID*)11e2a60]” or something.
It would be great if you knew an easy way to do that.
and finally, what does “m_DataHeader = printing kStreamer case (500)” mean?
Unfortunately the code for TTree::Show prints directly to the screen so there is no simple way. You could try to follow (and copy/paste/modify) the path TTree::Show calls TLeafElement::PrintValue which calls TBranchElement::PrintValue which calls TStreamerInfo::PrintValue.
The message you mention means that TStreamerInfo::PrintValue does not know how to print this type of data.
Ok, I actually been down that road and looked but thought it looked really complicated (at least compered with the integers and floats etc) so I thought i should ask you guys.
So that is the only way to do it?