I know this solution, but wanted to know whether what I ask is possible or not…
This would allow me to pass selection functions as strings in parameter files, have them interpreted as TTreeFormulas, and drive my analysis in a completely configurable way.
The following should also work:// Select.C
bool select(int x, int y) { // instead of int use the real type of x and y
return x+y>0; // x,y tree members. This example is not exactly complex
}and.L select.C
tree->Draw("x","select(x,y)");Cheers,
Philippe.
I have a similar problem and the proposed solution gives me the “Error in TTreeFormula::Compile: Bad numerical expression” error. Is this supposed to work as written?
Thanks for your fast reply. I was already using the branch names but I can’t get it to work. Here’s a piece of the code I’m using. I’m building the call to the function with values I read from an STL vector and put intro a string stream.
LlhFit_Azimuth and LlhFit_Zenith are the branches names:
Let me know if that’s good enough to troubleshoot the problem. It may very well be a stupid mistake of my part, but I’m not able to catch it. Many thanks again!
Marcos
PS: BTW, I’m using version 5.24/00b running on a RHEL 4.0 64 bits machine.
The problem is that since you compile your code but do not generate a dictionary (in particular for isEventInWindow), TTreeFormula has no way of knowing what the string ‘isEventInWindow’ represent.
To solve the problem either interpret your code or better yet generate a dictionary for isEventInWindow.
The problem is that since you compile your code but do not generate a dictionary (in particular for isEventInWindow), TTreeFormula has no way of knowing what the string ‘isEventInWindow’ represent.
To solve the problem either interpret your code or better yet generate a dictionary for isEventInWindow.
Cheers,
Philippe.[/quote]
I’m very interested in this functionality. This is the only obstacle that prevents me from compiling my code.
I’m learning now about how to generate the dictionary. Question: does the function I want to use in my selection formula have to be generated inside a class? Do I need to create a class containing this function in order to be able to put this function in a dictionary?
[quote]Do I need to create a class containing this function in order to be able to put this function in a dictionary?[/quote]No you do not need to. You can generate a dictionary for free standing function.