Is it possible to add two branches which are TLorentzVector type and THEN apply a method such as TLorentzVector::M()? Example:
Here branch1, branch2, and branch3 are all of type TLorentzVector:
[quote]Here branch1, branch2, and branch3 are all of type TLorentzVector:
Code: tree->Draw("(branch1 + branch2 - branch3).M()");
[/quote]No it is not possible directly. There are 2 issues. First TTreeFormula does no see overload operator and second it can not pass object to the function it calls (it can only use method and function taking and returning numerical values).
Instead use the new tree proxy mechanim. Create a file sum.C which containing:
double sum() {
double result = 0;
TLorentzVector sum = branch1;
sum += branch2;
sum += branch3;
return sum.M();
}
And do