18#ifndef ROOT_Math_GenVector_VectorUtil
19#define ROOT_Math_GenVector_VectorUtil 1
46 namespace VectorUtil {
61 template <
class Vector1,
class Vector2>
63 typename Vector1::Scalar
dphi =
v2.Phi() -
v1.Phi();
82 template <
class Vector1,
class Vector2>
85 typename Vector1::Scalar
deta =
v2.Eta() -
v1.Eta();
97 template <
class Vector1,
class Vector2>
100 typename Vector1::Scalar
drap =
v2.Rapidity() -
v1.Rapidity();
112 template <
class Vector1,
class Vector2>
126 template <
class Vector1,
class Vector2>
142 template <
class Vector1,
class Vector2>
154 if(arg > 1.0) arg = 1.0;
155 if(arg < -1.0) arg = -1.0;
169 template <
class Vector1,
class Vector2>
183 template <
class Vector1,
class Vector2>
185 double magU2 =
u.X()*
u.X() +
u.Y()*
u.Y() +
u.Z()*
u.Z();
199 template <
class Vector1,
class Vector2>
212 template <
class Vector1,
class Vector2>
214 double magU2 =
u.X()*
u.X() +
u.Y()*
u.Y() +
u.Z()*
u.Z();
228 template <
class Vector1,
class Vector2>
248 template <
class Vector1,
class Vector2>
250 typedef typename Vector1::Scalar
Scalar;
257 return mm2 < 0.0 ? -
sqrt(-mm2) :
sqrt(mm2);
265 template <
class Vector1,
class Vector2>
267 typedef typename Vector1::Scalar
Scalar;
287 template <
class Vector>
289 if (std::fmod(alpha, 2 *
TMath::Pi()) == 0.)
292 double sina = sin(alpha);
294 double cosa = cos(alpha);
308 template <
class Vector>
310 if (std::fmod(alpha, 2 *
TMath::Pi()) == 0.)
313 double sina = sin(alpha);
315 double cosa = cos(alpha);
329 template <
class Vector>
331 if (std::fmod(alpha, 2 *
TMath::Pi()) == 0.)
334 double sina = sin(alpha);
336 double cosa = cos(alpha);
350 template <
class Vector>
351 Vector
Rotate(
const Vector &
v,
double alpha,
const Vector &axis)
353 if (std::fmod(alpha, 2 *
TMath::Pi()) == 0.)
355 const double ll = std::sqrt(axis.X() * axis.X() + axis.Y() * axis.Y() + axis.Z() * axis.Z());
358 const double sa = std::sin(alpha);
359 const double ca = std::cos(alpha);
360 const double dx = axis.X() / ll;
361 const double dy = axis.Y() / ll;
362 const double dz = axis.Z() / ll;
368 const double xX =
v.X();
369 const double yY =
v.Y();
370 const double zZ =
v.Z();
386 template<
class Vector,
class RotationMatrix>
407 template <
class LVector,
class BoostVector>
414 GenVector_Throw(
"Beta Vector supplied to set Boost represents speed >= c");
418 double gamma = 1.0 /
sqrt(1.0 - b2);
420 double gamma2 = b2 > 0 ? (gamma - 1.0)/b2 : 0.0;
424 double t2 = gamma*(
v.T() +
bp);
437 template <
class LVector,
class T>
440 GenVector_Throw(
"Beta Vector supplied to set Boost represents speed >= c");
445 typename LVector::Scalar
x2 = gamma *
v.X() + gamma *
beta *
v.T();
446 typename LVector::Scalar
t2 = gamma *
beta *
v.X() + gamma *
v.T();
459 template <
class LVector>
462 GenVector_Throw(
"Beta Vector supplied to set Boost represents speed >= c");
467 double y2 = gamma *
v.Y() + gamma *
beta *
v.T();
468 double t2 = gamma *
beta *
v.Y() + gamma *
v.T();
480 template <
class LVector>
483 GenVector_Throw(
"Beta Vector supplied to set Boost represents speed >= c");
488 double z2 = gamma *
v.Z() + gamma *
beta *
v.T();
489 double t2 = gamma *
beta *
v.Z() + gamma *
v.T();
503 template<
class Matrix,
class CoordSystem,
class U>
507 vret.SetXYZ(
m(0,0) *
v.x() +
m(0,1) *
v.y() +
m(0,2) *
v.z() ,
508 m(1,0) *
v.x() +
m(1,1) *
v.y() +
m(1,2) *
v.z() ,
509 m(2,0) *
v.x() +
m(2,1) *
v.y() +
m(2,2) *
v.z() );
518 template<
class Matrix,
class CoordSystem,
class U>
522 pret.SetXYZ(
m(0,0) *
p.x() +
m(0,1) *
p.y() +
m(0,2) *
p.z() ,
523 m(1,0) *
p.x() +
m(1,1) *
p.y() +
m(1,2) *
p.z() ,
524 m(2,0) *
p.x() +
m(2,1) *
p.y() +
m(2,2) *
p.z() );
535 template<
class CoordSystem,
class Matrix>
539 vret.SetXYZT(
m(0,0)*
v.x() +
m(0,1)*
v.y() +
m(0,2)*
v.z() +
m(0,3)*
v.t() ,
540 m(1,0)*
v.x() +
m(1,1)*
v.y() +
m(1,2)*
v.z() +
m(1,3)*
v.t() ,
541 m(2,0)*
v.x() +
m(2,1)*
v.y() +
m(2,2)*
v.z() +
m(2,3)*
v.t() ,
542 m(3,0)*
v.x() +
m(3,1)*
v.y() +
m(3,2)*
v.z() +
m(3,3)*
v.t() );
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char y2
DisplacementVector3D< CoordSystem, U > Mult(const Matrix &m, const DisplacementVector3D< CoordSystem, U > &v)
Multiplications of a generic matrices with a DisplacementVector3D of any coordinate system.
Vector1::Scalar DeltaR2(const Vector1 &v1, const Vector2 &v2)
Find square of the difference in pseudorapidity (Eta) and Phi between two generic vectors The only re...
double Perp(const Vector1 &v, const Vector2 &u)
Find the magnitude of the vector component of v perpendicular to the given direction of u.
LVector boostY(const LVector &v, double beta)
Boost a generic Lorentz Vector class along the Y direction with a factor beta The only requirement on...
Vector1::Scalar DeltaRapidityPhi(const Vector1 &v1, const Vector2 &v2)
Find difference in Rapidity (y) and Phi between two generic vectors The only requirements on the Vect...
Vector1::Scalar DeltaR(const Vector1 &v1, const Vector2 &v2)
Find difference in pseudorapidity (Eta) and Phi between two generic vectors The only requirements on ...
Vector1::Scalar DeltaPhi(const Vector1 &v1, const Vector2 &v2)
Find aximutal Angle difference between two generic vectors ( v2.Phi() - v1.Phi() ) The only requireme...
LVector boost(const LVector &v, const BoostVector &b)
Boost a generic Lorentz Vector class using a generic 3D Vector class describing the boost The only re...
double Angle(const Vector1 &v1, const Vector2 &v2)
Find Angle between two vectors.
Vector RotateZ(const Vector &v, double alpha)
rotation along Z axis for a generic vector by an Angle alpha returning a new vector.
Vector1::Scalar DeltaR2RapidityPhi(const Vector1 &v1, const Vector2 &v2)
Find square of the difference in true rapidity (y) and Phi between two generic vectors The only requi...
Vector RotateY(const Vector &v, double alpha)
rotation along Y axis for a generic vector by an Angle alpha returning a new vector.
Vector RotateX(const Vector &v, double alpha)
rotation along X axis for a generic vector by an Angle alpha returning a new vector.
double CosTheta(const Vector1 &v1, const Vector2 &v2)
Find CosTheta Angle between two generic 3D vectors pre-requisite: vectors implement the X(),...
Vector1 PerpVector(const Vector1 &v, const Vector2 &u)
Find the vector component of v perpendicular to the given direction of u.
double Perp2(const Vector1 &v, const Vector2 &u)
Find the magnitude square of the vector component of v perpendicular to the given direction of u.
double Phi_0_2pi(double phi)
Return a phi angle in the interval (0,2*PI].
Vector Rotate(const Vector &v, double alpha, const Vector &axis)
rotation along a custom axis for a generic vector by an Angle alpha (in rad) returning a new vector.
double Phi_mpi_pi(double phi)
Returns phi angle in the interval (-PI,PI].
Vector1::Scalar InvariantMass2(const Vector1 &v1, const Vector2 &v2)
Returns the square of what InvariantMass(const Vector1&, const Vector2&) would return.
Vector1 ProjVector(const Vector1 &v, const Vector2 &u)
Find the projection of v along the given direction u.
LVector boostZ(const LVector &v, double beta)
Boost a generic Lorentz Vector class along the Z direction with a factor beta The only requirement on...
LVector boostX(const LVector &v, T beta)
Boost a generic Lorentz Vector class along the X direction with a factor beta The only requirement on...
Vector1::Scalar InvariantMass(const Vector1 &v1, const Vector2 &v2)
return the invariant mass of two LorentzVector The only requirement on the LorentzVector is that they...
double beta(double x, double y)
Calculates the beta function.
Namespace for new Math classes and functions.
void GenVector_Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
Rotation3D::Scalar Scalar
Namespace for new ROOT classes and functions.