Dear Experts,
I am a beginner to root. I have stored all four momenta(px, py, pz, E) in one root file. They are saved in different branch. Now I want to make a four momentum out of it and save it in another tree. Could you please suggest me how to do that ?
Thanks in Advance
__
_
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
Hi,
assuming px, py, pz and E are floats, a solution could be:
auto createVect = [](float px, float py, float pz, float E) {
return ROOT::Math::PxPyPzEVector(px, py, pz, E);
}
ROOT::RDataFrame rdf("yourtree","yourfile.root");
rdf.Define("fourVect", createVect, {"px", "py", "pz", "E"});
rdf.Snapshot("yourNewTree", "yourNewFile");
Cheers,
D
… and at the cost of some runtime if you want to type less:
ROOT::RDataFrame rdf("yourtree","yourfile.root")
.Define("fourVect", "ROOT::Math::PxPyPzEVector(px, py, pz, E)")
.Snapshot("yourNewTree", "yourNewFile");
D