I read some topic about how TTree::Draw works, and I am able to read the TLorentzVectors stored in my tree.
I would like to sum my lorentz vectors before getting the mass and do something similar:
I know that it’s not so easy, because of how TTreeFormula has been thought.
In order to do that, I implemented my own classe, which of course is doing the job.
root [11] t->Draw("MyOwnFormula::M(lv, lv2)");
Error in <TTreeFormula::Compile>: Bad numerical expression : "MyOwnFormula::M(lv, lv2)"
Do you know what is wrong with my class and why I got a bad numerical expression ? I tried MyOwnFormula without Trees and only 2 TLorentzVectors created by my own and MyOwnFormula::M returns a Double_t
I imagine that this trick cannot be implemented so easily ?
I figured out if the problem was coming from my method MyOwnFormula::M or the TLorentzVector.
I replaced TLorentzVectors by Int_t… And it was working.
I suspect something coming from the use of TLorentzVector.
I probably do something wrong…
Does someone know why ? Can we use TLorentzVector though TTree::Draw() ?
Current TTree::Draw does not support calling function (or operator) that takes an object as parameter. To work around, you could pass the component of the two lorentzVector to a function (which takes only numerical types are argument). Another alternative is to a pass a ‘TTreeProxy’ script to TTree::Draw instead of a formula. In the TTree::Draw documentation (root.cern.ch/doc/master/classTT … c468523e45) look for the lines:new TFile("hsimple.root")
ntuple->Draw("hsimple.cxx");
I finally stored a third branch sum of the two first (summing term by term the lorentz vectors), in order to get the value more easily. Otherwise I coded a small .C in order to loop over my entries.
It’s not possible for me to overload my function with 4*(4 quantities from the LorentzVector) Too much arguments, I will make a mistake at some point…