I am making use of the very nice GetEntries(const char* selection) in a cut optimisation tool I have developed, and I would like to know if I can evaluate the result of “const char* selection” as applied to a single event?
where formulaString can be composed in a similar fashion to the selection string in GetEntries.
The reason I ask is because the only way I can think of doing it right now is by using SetBranchAddress which is less friendly than the nice string format used in GetEntries. If I want to change the formula in this case, I must assign a new set of branch addresses.
Sorry, Rene, this isn’t quite what I meant- I didn’t explain very well in my comparison. What I am trying to get is the value of an expression as applied to a given event- to use my string analogy, GetEntries is cutting on “B_s_Energy2 - B_s_Momentum2 < 10*GeV”; any event for which the outcome of the left side of the expression is less than 10GeV passes the cut.
What I am looking for is a way to evaluate the expression, rather than compare it, like this:
so that thisValue becomes the evaluated expression when applied to this particular entry (9.7E06, 1.02E07 being two examples of ones that would increment or do nothing to numberpassingcut in my previous example).
I assumed that GetEntries is doing this somewhere as it needs to evaluate the expression on an event-by-event basis in order to see if it passes/fails. I cannot work out how it is doing this however.
myTree->Draw("B_s_Energy**2 - B_s_Momentum**2 < 10*GeV","',"goff");
double *result = mytree->GetV1();
result[0] = result of expression for entry 0
result[1] = result of expression for entry 1
..
result[i] = result of expression for entry i
Rene
Could you provide an example of how to use TTreeFormula for this purpose? I’m having difficulty working out how to use it to evaluate to a Double_t in the documentation.