Dear all,
I have the following use case:
- generate events in the main loop,
- apply selections and fill histograms : we do this by reading in variables and cuts as strings (from text files), and evaluating them event by event using TTreeFormula
- fill an output tree for events that pass the selection.
I observe that for variables of type vector (or any vector), the value and formula evaluation always return to the first value. For simple doubles, no problem.
The problem appears specifically after the following sequence:
- ttf.GetNdata()
- ttf.EvalInstance()
- tree.Fill()
My questions and comments are:
-
what exactly is the role of GetNdata()? It returns the variable cardinality, but does it do something else internally? In which cases can it be skipped? At some point I saw that avoiding this call would not allow proper formula evaluation.
-
in the attached example, when I comment the GetNdata line the problem goes away (and the formulas are still properly evaluated - this doesn’t seem to be the case in general though). When I don’t fill the tree, the problem also goes away (but then I don’t get an output).
Is my code not correct, or if this is a bug, is there a safe workaround?
A simple macro reproducing the problem is attached.
thanks for your help,
Maarten
tree1.C (1.63 KB)