LorentzVector vs. TLorentzVector #21
-
I'm hitting the snag that things are LorentzVectors rather than TLorentzVectors, and so I can't do quick operations like .Perp(), .Angle() etc. Is there a neat/tidy way to convert from LV to TLV? For some reason it doesn't seem like LV can be cast to a TLV (although I really don't understand why...) Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
TLorentzVector is slow and cumbersome and not optimally suited to large volume data analysis. LorentzVectors are lighter and significantly faster. They are two completely different classes, so there is no inheritance or casting between them. You can usually get the same information from LorentzVectors using their utility functions https://root.cern/doc/v612/Vector.html for overview https://root.cern/doc/v612/namespaceROOT_1_1Math_1_1VectorUtil.html for helper functions. So you might want to add (in the function where you use angle) using ROOT::Math::VectorUtil::Angle; using ROOT::Math::VectorUtil::Perp; then auto angleDiff= Angle(p1,p2); auto perpComp= Perp(p1,p2); You can also look at https://github.com/dglazier/chanser/blob/master/core/Kinematics.h For more examples of LorentzVector manipulation. I think it would also be a good idea to include wrapper functions to Angle and Perp as part of the Kinematics class to simplify this. i.e. it would just be auto angleDiff= kin.Angle(p1,p2); I will start a discussion in developments for what we can add to Kinematics |
Beta Was this translation helpful? Give feedback.
-
Ah, my mistake, that is the perp component of 1 relative to another. There should be a Perp2 function in LorentzVector itself (leaving you to do the sqrt only if necessary) see auto perpComp=TMath::Sqrt(p4.Perp2()); |
Beta Was this translation helpful? Give feedback.
TLorentzVector is slow and cumbersome and not optimally suited to large volume data analysis. LorentzVectors are lighter and significantly faster. They are two completely different classes, so there is no inheritance or casting between them. You can usually get the same information from LorentzVectors using their utility functions
https://root.cern/doc/v612/Vector.html for overview
https://root.cern/doc/v612/namespaceROOT_1_1Math_1_1VectorUtil.html for helper functions.
So you might want to add (in the function where you use angle)
using ROOT::Math::VectorUtil::Angle;
using ROOT::Math::VectorUtil::Perp;
then
auto angleDiff= Angle(p1,p2);
auto perpComp= Perp(p1,p2);
You can also look at ht…