diff --git a/math/genvector/inc/Math/GenVector/VectorUtil.h b/math/genvector/inc/Math/GenVector/VectorUtil.h index 07a2f6c99d516..90bfff81d0652 100644 --- a/math/genvector/inc/Math/GenVector/VectorUtil.h +++ b/math/genvector/inc/Math/GenVector/VectorUtil.h @@ -83,6 +83,21 @@ namespace ROOT { return dphi*dphi + deta*deta; } + /** + Find square of the difference in true rapidity (y) and Phi betwen two generic vectors + The only requirements on the Vector classes is that they implement the Phi() and Rapidity() method + \param v1 Vector 1 + \param v2 Vector 2 + \return Angle between the two vectors + \f[ \Delta R2 = ( \Delta \phi )^2 + ( \Delta \y )^2 \f] + */ + template + inline typename Vector1::Scalar DeltaR2RapidityPhi( const Vector1 & v1, const Vector2 & v2) { + typename Vector1::Scalar dphi = DeltaPhi(v1,v2); + typename Vector1::Scalar drap = v2.Rapidity() - v1.Rapidity(); + return dphi*dphi + drap*drap; + } + /** Find difference in pseudorapidity (Eta) and Phi betwen two generic vectors The only requirements on the Vector classes is that they implement the Phi() and Eta() method @@ -96,7 +111,18 @@ namespace ROOT { return std::sqrt( DeltaR2(v1,v2) ); } - + /** + Find difference in Rapidity (y) and Phi betwen two generic vectors + The only requirements on the Vector classes is that they implement the Phi() and Rapidity() method + \param v1 Vector 1 + \param v2 Vector 2 + \return Angle between the two vectors + \f[ \Delta R = \sqrt{ ( \Delta \phi )^2 + ( \Delta y )^2 } \f], + */ + template + inline typename Vector1::Scalar DeltaRapidityPhi( const Vector1 & v1, const Vector2 & v2) { + return std::sqrt( DeltaR2RapidityPhi(v1,v2) ); + } /** Find CosTheta Angle between two generic 3D vectors diff --git a/math/physics/inc/TLorentzVector.h b/math/physics/inc/TLorentzVector.h index 0eab6083d356a..7a1c6da25f39b 100644 --- a/math/physics/inc/TLorentzVector.h +++ b/math/physics/inc/TLorentzVector.h @@ -181,8 +181,9 @@ class TLorentzVector : public TObject { // Transverse energy w.r.t. given axis. inline Double_t DeltaPhi(const TLorentzVector &) const; - inline Double_t DeltaR(const TLorentzVector &) const; + inline Double_t DeltaR(const TLorentzVector &, Bool_t useRapidity=kFALSE) const; inline Double_t DrEtaPhi(const TLorentzVector &) const; + inline Double_t DrRapidityPhi(const TLorentzVector &) const; inline TVector2 EtaPhiVector(); inline Double_t Angle(const TVector3 & v) const; @@ -460,16 +461,27 @@ inline Double_t TLorentzVector::DeltaPhi(const TLorentzVector & v) const { inline Double_t TLorentzVector::Eta() const { return PseudoRapidity(); } -inline Double_t TLorentzVector::DeltaR(const TLorentzVector & v) const { - Double_t deta = Eta()-v.Eta(); - Double_t dphi = TVector2::Phi_mpi_pi(Phi()-v.Phi()); - return TMath::Sqrt( deta*deta+dphi*dphi ); + +inline Double_t TLorentzVector::DeltaR(const TLorentzVector & v, const Bool_t useRapidity) const { + if(useRapidity){ + Double_t drap = Rapidity()-v.Rapidity(); + Double_t dphi = TVector2::Phi_mpi_pi(Phi()-v.Phi()); + return TMath::Sqrt( drap*drap+dphi*dphi ); + } else { + Double_t deta = Eta()-v.Eta(); + Double_t dphi = TVector2::Phi_mpi_pi(Phi()-v.Phi()); + return TMath::Sqrt( deta*deta+dphi*dphi ); + } } inline Double_t TLorentzVector::DrEtaPhi(const TLorentzVector & v) const{ return DeltaR(v); } +inline Double_t TLorentzVector::DrRapidityPhi(const TLorentzVector & v) const{ + return DeltaR(v, kTRUE); +} + inline TVector2 TLorentzVector::EtaPhiVector() { return TVector2 (Eta(),Phi()); }