Hi fellow rooters,
I’m trying to write a DAQ interface to display some basic histograms for incoming data in real-time. I’d like users to be able to determine what to plot with a simple string statement that would be interpreted as though they’d put it into a TTree::Draw command. We have an Event class with a dictionary, which is the only branch in our analyzed trees, so statemens would all be things like “event.pulse_integral / event.pulse_amplitude”, etc.
The best way I can think of right now is to use TTreeFormulas, so something like:
void RealTimeSpectrum::Initialize(const char* string_to_plot)
{
fTree = new TTree("tree","tree");
Event* dummy = new Event;
fTree.Branch("event",&dummy);
delete dummy;
fFormula = new TTreeFomula("myformula", string_to_plot, fTree);
fFormula->SetQuickLoad(true); //should I call this?
}
void RealTimeSpectrum::Process(Event* evt)
{
fTree->SetBranchAddress("event", &evt);
for(int i=0 ; i < fFormula->GetNdata(); ++i)
fHisto->Fill( fFormula->EvalInstance(i) );
}
I’m reasonably certain something like this will work, but is it the “right” way to go about it?
Should I call the SetQuickLoad method?
Is having to call SetBranchAddress or use an interpreted function like this going to be a huge performance hog? Is there a way to avoid having to carry around a TTree which doesn’t actually do anything directly? E.g., is there a reasonably straightforward way to do something like overload TFormula so that it knows about my Event class rather than using TTrees and branches for that effect?
Many thanks,
~Ben