|
ROOT
Reference Guide |
|
Go to the documentation of this file.
18 #ifndef ROOT_Math_GenVector_VectorUtil
19 #define ROOT_Math_GenVector_VectorUtil 1
45 namespace VectorUtil {
58 template <
class Vector1,
class Vector2>
63 }
else if ( dphi <= -
M_PI ) {
79 template <
class Vector1,
class Vector2>
83 return dphi*dphi + deta*deta;
94 template <
class Vector1,
class Vector2>
98 return dphi*dphi + drap*drap;
109 template <
class Vector1,
class Vector2>
122 template <
class Vector1,
class Vector2>
137 template <
class Vector1,
class Vector2>
140 double v1_r2 =
v1.X()*
v1.X() +
v1.Y()*
v1.Y() +
v1.Z()*
v1.Z();
141 double v2_r2 =
v2.X()*
v2.X() +
v2.Y()*
v2.Y() +
v2.Z()*
v2.Z();
142 double ptot2 = v1_r2*v2_r2;
146 double pdot =
v1.X()*
v2.X() +
v1.Y()*
v2.Y() +
v1.Z()*
v2.Z();
148 if(arg > 1.0) arg = 1.0;
149 if(arg < -1.0) arg = -1.0;
163 template <
class Vector1,
class Vector2>
164 inline double Angle(
const Vector1 &
v1,
const Vector2 &
v2) {
176 template <
class Vector1,
class Vector2>
178 double magU2 = u.X()*u.X() + u.Y()*u.Y() + u.Z()*u.Z();
179 if (magU2 == 0)
return Vector1(0,0,0);
180 double d =
v.Dot(u)/magU2;
181 return Vector1( u.X() *
d, u.Y() *
d, u.Z() *
d);
192 template <
class Vector1,
class Vector2>
193 inline Vector1
PerpVector(
const Vector1 &
v,
const Vector2 & u) {
205 template <
class Vector1,
class Vector2>
206 inline double Perp2(
const Vector1 &
v,
const Vector2 & u) {
207 double magU2 = u.X()*u.X() + u.Y()*u.Y() + u.Z()*u.Z();
208 double prjvu =
v.Dot(u);
209 double magV2 =
v.Dot(
v);
210 return magU2 > 0.0 ? magV2-prjvu*prjvu/magU2 : magV2;
221 template <
class Vector1,
class Vector2>
222 inline double Perp(
const Vector1 &
v,
const Vector2 & u) {
240 template <
class Vector1,
class Vector2>
247 Scalar mm2 = ee*ee - xx*xx - yy*yy - zz*zz;
254 template <
class Vector1,
class Vector2>
261 Scalar mm2 = ee*ee - xx*xx - yy*yy - zz*zz;
278 template <
class Vector>
280 double sina =
sin(alpha);
281 double cosa =
cos(alpha);
282 double y2 =
v.Y() * cosa -
v.Z()*sina;
283 double z2 =
v.Z() * cosa +
v.Y() * sina;
285 vrot.SetXYZ(
v.X(), y2, z2);
295 template <
class Vector>
297 double sina =
sin(alpha);
298 double cosa =
cos(alpha);
299 double x2 =
v.X() * cosa +
v.Z() * sina;
300 double z2 =
v.Z() * cosa -
v.X() * sina;
302 vrot.SetXYZ(
x2,
v.Y(), z2);
312 template <
class Vector>
314 double sina =
sin(alpha);
315 double cosa =
cos(alpha);
316 double x2 =
v.X() * cosa -
v.Y() * sina;
317 double y2 =
v.Y() * cosa +
v.X() * sina;
319 vrot.SetXYZ(
x2, y2,
v.Z());
331 template<
class Vector,
class RotationMatrix>
332 Vector
Rotate(
const Vector &
v,
const RotationMatrix & rot) {
336 double x2 = rot(0,0)*xX + rot(0,1)*yY + rot(0,2)*zZ;
337 double y2 = rot(1,0)*xX + rot(1,1)*yY + rot(1,2)*zZ;
338 double z2 = rot(2,0)*xX + rot(2,1)*yY + rot(2,2)*zZ;
340 vrot.SetXYZ(
x2,y2,z2);
352 template <
class LVector,
class BoostVector>
353 LVector
boost(
const LVector &
v,
const BoostVector &
b) {
357 double b2 = bx*bx + by*by + bz*bz;
359 GenVector::Throw (
"Beta Vector supplied to set Boost represents speed >= c");
363 double bp = bx*
v.X() + by*
v.Y() + bz*
v.Z();
364 double gamma2 = b2 > 0 ? (
gamma - 1.0)/b2 : 0.0;
365 double x2 =
v.X() + gamma2*bp*bx +
gamma*bx*
v.T();
366 double y2 =
v.Y() + gamma2*bp*by +
gamma*by*
v.T();
367 double z2 =
v.Z() + gamma2*bp*bz +
gamma*bz*
v.T();
368 double t2 =
gamma*(
v.T() + bp);
370 lv.SetXYZT(
x2,y2,z2,t2);
381 template <
class LVector,
class T>
384 GenVector::Throw (
"Beta Vector supplied to set Boost represents speed >= c");
392 lv.SetXYZT(
x2,
v.Y(),
v.Z(),t2);
402 template <
class LVector>
405 GenVector::Throw (
"Beta Vector supplied to set Boost represents speed >= c");
412 lv.SetXYZT(
v.X(),y2,
v.Z(),t2);
422 template <
class LVector>
425 GenVector::Throw (
"Beta Vector supplied to set Boost represents speed >= c");
432 lv.SetXYZT(
v.X(),
v.Y(),z2,t2);
449 template<
class Matrix,
class CoordSystem,
class U>
453 vret.
SetXYZ(
m(0,0) *
v.x() +
m(0,1) *
v.y() +
m(0,2) *
v.z() ,
454 m(1,0) *
v.x() +
m(1,1) *
v.y() +
m(1,2) *
v.z() ,
455 m(2,0) *
v.x() +
m(2,1) *
v.y() +
m(2,2) *
v.z() );
464 template<
class Matrix,
class CoordSystem,
class U>
468 pret.
SetXYZ(
m(0,0) * p.
x() +
m(0,1) * p.
y() +
m(0,2) * p.
z() ,
469 m(1,0) * p.
x() +
m(1,1) * p.
y() +
m(1,2) * p.
z() ,
470 m(2,0) * p.
x() +
m(2,1) * p.
y() +
m(2,2) * p.
z() );
481 template<
class CoordSystem,
class Matrix>
485 vret.
SetXYZT(
m(0,0)*
v.x() +
m(0,1)*
v.y() +
m(0,2)*
v.z() +
m(0,3)*
v.t() ,
486 m(1,0)*
v.x() +
m(1,1)*
v.y() +
m(1,2)*
v.z() +
m(1,3)*
v.t() ,
487 m(2,0)*
v.x() +
m(2,1)*
v.y() +
m(2,2)*
v.z() +
m(2,3)*
v.t() ,
488 m(3,0)*
v.x() +
m(3,1)*
v.y() +
m(3,2)*
v.z() +
m(3,3)*
v.t() );
Vector1::Scalar DeltaR2RapidityPhi(const Vector1 &v1, const Vector2 &v2)
Find square of the difference in true rapidity (y) and Phi betwen two generic vectors The only requir...
Vector RotateY(const Vector &v, double alpha)
rotation along Y axis for a generic vector by an Angle alpha returning a new vector.
LorentzVector< CoordSystem > & SetXYZT(Scalar xx, Scalar yy, Scalar zz, Scalar tt)
set the values of the vector from the cartesian components (x,y,z,t) (if the vector is held in anothe...
Vector1 PerpVector(const Vector1 &v, const Vector2 &u)
Find the vector component of v perpendicular to the given direction of u.
Class describing a generic position vector (point) in 3 dimensions.
Vector1::Scalar InvariantMass2(const Vector1 &v1, const Vector2 &v2)
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...
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.
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 DeltaR2(const Vector1 &v1, const Vector2 &v2)
Find square of the difference in pseudorapidity (Eta) and Phi betwen two generic vectors The only req...
double Angle(const Vector1 &v1, const Vector2 &v2)
Find Angle between two vectors.
Vector1::Scalar DeltaR(const Vector1 &v1, const Vector2 &v2)
Find difference in pseudorapidity (Eta) and Phi betwen two generic vectors The only requirements on t...
Vector RotateX(const Vector &v, double alpha)
rotation along X axis for a generic vector by an Angle alpha returning a new vector.
double beta(double x, double y)
Calculates the beta function.
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...
void Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
Vector1::Scalar DeltaPhi(const Vector1 &v1, const Vector2 &v2)
Find aximutal Angle difference between two generic vectors ( v2.Phi() - v1.Phi() ) The only requireme...
double CosTheta(const Vector1 &v1, const Vector2 &v2)
Find CosTheta Angle between two generic 3D vectors pre-requisite: vectors implement the X(),...
static constexpr double mm2
double Phi_0_2pi(double phi)
Return a phi angle in the interval (0,2*PI].
Vector1::Scalar DeltaRapidityPhi(const Vector1 &v1, const Vector2 &v2)
Find difference in Rapidity (y) and Phi betwen two generic vectors The only requirements on the Vecto...
DisplacementVector3D< CoordSystem, U > Mult(const Matrix &m, const DisplacementVector3D< CoordSystem, U > &v)
Multiplications of a generic matrices with a DisplacementVector3D of any coordinate system.
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...
Rotation3D::Scalar Scalar
Vector1 ProjVector(const Vector1 &v, const Vector2 &u)
Find the projection of v along the given direction u.
DisplacementVector3D< CoordSystem, Tag > & SetXYZ(Scalar a, Scalar b, Scalar c)
set the values of the vector from the cartesian components (x,y,z) (if the vector is held in polar or...
Class describing a generic displacement vector in 3 dimensions.
double Phi_mpi_pi(double phi)
Returns phi angle in the interval (-PI,PI].
static const double x2[5]
Vector Rotate(const Vector &v, const RotationMatrix &rot)
rotation on a generic vector using a generic rotation class.
Vector RotateZ(const Vector &v, double alpha)
rotation along Z axis for a generic vector by an Angle alpha returning a new vector.
double Perp(const Vector1 &v, const Vector2 &u)
Find the magnitude of the vector component of v perpendicular to the given direction of u.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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...
Namespace for new Math classes and functions.
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...