Hi Tom,
The class you are looking for is TTreeFormula. You can see a simple-ish and compact use case in the implementation of TTreePlayer::Scan. (TTreeViewer also indirectly uses TTreeFormula, via calls to TTree::Draw, which is implemented in the class TSelectorDraw).
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
On Behalf Of Tom Roberts
Sent: Thursday, February 15, 2007 3:06 PM
To: 'ROOT Talk'
Subject: [ROOT] working around bugs and limitations?
I am trying to present my users with a stable and user-friendly application based on Root. This is proving to be unexpectedly difficult.
I have found it is not possible to compile a function containing expressions entered by the user, as CINT simply does not play nice with others, and if an expression is invalid it can cause the entire Root instance to cease working (e.g. error message "cannot create file" in code without any file creation, or lots of "busy" functions).
[Is it possible to add a function with the functionality of ProcessLineSync(), but is guaranteed to return to the caller, even if the string contains a .L command and the file has compilation errors? Such errors must NOT cause side effects like making the program cease to work. I need it callable from a macro, so cannot use longjmp().]
As a workaround, I would like to use TFormula. Unfortunately the documentation is both sparse and obscure. Here's what I want to do: Given a TNtuple, I want to read its events one at a time, and for each event evaluate several user-entered expressions that use the names of its branches (plus arithmetic operators and the usual math functions). Those expression values are used to apply cuts and generate a histogram. [Yes, TTreeViewer can do something similar, but its code is obscure and its user interface is usable only by experts.]
So some questions about TFormula:
There are fNpar parameters, initially zero with a max of 1000.
They can be given names, can the expression refer to them by name?
Can I use the first ~30 parameters, give them the names of the
branches, and set their values when I read each event?
How can I set fNpar to do that?
TFormula changes fNpar internally, in obscure ways -- what is that?
Some of those changes are linked to magic values of the expression
number (100,200,...) -- what is that? It looks like additional tokens can be added -- how might I add
a token with the name of a branch that evaluates to the value of a specific float variable?
The code comments refer to a fictional class TNtupleFormula -- this looks like it might be precisely what I want. What happened to it? Why isn't there a class that simply evaluates formulas within a TNtuple (the code I see is obscure and complicated)?
Tom Roberts Received on Thu Feb 15 2007 - 22:41:15 CET
This archive was generated by hypermail 2.2.0 : Sat Feb 17 2007 - 05:50:00 CET