I have one class Calculator which is calculating a complex quantity. It doesn’t take as input floats but a TTree and computes the output using as inputs some leafs of the TTree, for example:
TTree* tree;
....
Calculator c(tree);
for (loop over entries) {
tree->GetEntry(ientry);
float result = c.compute();
}
internally Calculator uses TTreeFormula to combine some variables from the TTree and then it uses the output of the TTreeFormulas as input of an MVA algorithm.
Now I want to introduce a bias on the input variables, so my idea is to produce a new TTree, event-by-event. I don’t want to produce a complete TTree, copy of the original one, because it is too big, and because I want to introduce many kind of biases. So for example I want to do something like this
TTree* tree;
....
TTree* tree_with_bias;
tree_with_bias->SetDirectory(0);
...
Calculator c(tree_with_bias);
for (loop over entries) {
tree->GetEntry(ientry);
copy_and_bias_(tree, tree_with_bias);
tree_with_bias->GetEntry(0);
float result = c.compute();
}
The function copy_and_bias should take the ientry from tree, bias some variables, copy the biases variable (only for the entry ientry) in tree_with_bias.
At every step tree_with_bias should have only 1 entry. How to do it?
If I’ve well understood your idea is to create a friend TTree, without branches but only with alias. The problem is that alias is defined with string. I have c++ functions to bias the inputs and they are not representable as simple strings.
Sorry, you misunderstood my post.
I simply point out that there exist (at least) three different possibilities:
(1) you can add an “alias” to an existing tree,
(2) you can add a new branch (with new “leaves”) to an existing tree,
(3) you can create a new tree with its own new branches / “leaves” (and its own “aliases”, if you like) and make that new tree a “friend” of your existing tree.
It’s up to you which possibility you’ll use and/or how you “combine” them.
[quote=“Wile E. Coyote”]Sorry, you misunderstood my post.
I simply point out that there exist (at least) three different possibilities:
(1) you can add an “alias” to an existing tree,
(2) you can add a new branch (with new “leaves”) to an existing tree,
(3) you can create a new tree with its own new branches / “leaves” (and its own “aliases”, if you like) and make that new tree a “friend” of your existing tree.
It’s up to you which possibility you’ll use and/or how you “combine” them.[/quote]
as I said (1) is not possibile in my case. (2) and (3) means I have to write something on disk, I would prefer to avoid it, I want to do everythings on the fly.
read nominal variables from tree -> bias variables -> apply my tool