ROOT Version (e.g. 6.12/06):
Platform, compiler (e.g. CentOS 7.4.1708, gcc6.2):
Is there some way of forcing TTreeFormula to pick up updated versions of its inputs?
My question is probably best illustrated in the short example below, which prints “45 45”.
I would like TTreeFormula to pick up the modification, of x and, therefore, print “45 90”.
(run by saving this snippet as foo.cpp, then running root foo.cpp+)
#include <TTree.h>
#include <TTreeFormula.h>
#include <iostream>
void foo()
{
Float_t xin, sum_yin{0.0};
TTree tree( "tree", "" );
tree.Branch( "x", &xin );
for ( auto i = 0; i < 10; ++i ) {
xin = i;
sum_yin += xin;
tree.Fill();
}
Float_t x, sum_y{0.0};
tree.SetBranchAddress( "x", &x );
TTreeFormula form( "form", "x", &tree );
for ( auto i = 0; i < tree.GetEntries(); ++i ) {
tree.GetEntry( i );
x *= 2.0;
sum_y += form.EvalInstance();
}
std::cout << sum_yin << " " << sum_y << std::endl;
}