Dear fellow rooters,
This may take a while to explain, and it may well be that I am attempting something not possible with the current framework. As an attempt at a quick summary: I want to be able to decide at run-time how much of a class to save to a tree (which I think I understand) and have that also determine the splittings of sub-branches in a TTree (which might not be possible.)
So, let’s say I have the following class definition:
class EventData{
public:
short verbosity;
Info generic;
MoreInfo more;
EvenMoreInfo evenmore;
ClassDef(EventData,1)
};
Each of the Info, MoreInfo, and EvenMoreInfo classes are composed purely of fundamental types (or possible vectors of fundamentals). Most of the time, I just want to store the generic info for the class, but I can also throw a switch somewhere to get more verbose output for debugging/etc.
So, my custom Streamer would look something like:
void EventData::Streamer(TBuffer& b)
{
if(b.IsReading()){
b>>verbosity;
b>>generic;
if(verbosity > 0) b>>more;
if(verbosity > 1) b>>evenmore;
}
else{
//etc...
}
}
All well and good so far. But, if I want to use this class in a TTree, I have to use splitting=-1 in TTree::Branch(). (As an aside, just what DOES get called here if splitting>0?)
But this puts just one top-level branch into my tree (let’s say “event”), so I can no longer use functions like tree->Draw(“energy”,“id > 2000”). (Assuming of course that the Info class contains ‘energy’ and ‘id’ members).
So, is there any way to selectively decide how much of my class to write while still using a high split level (or preserving in some other way the Draw, Scan, etc. functions of TTree with sub-branches)?
Thanks,
~Ben