Classes | |
struct | IDigit |
Simple structure form compile-time evaluation of the Nth decimal digit for the given number. More... | |
struct | IDigits |
Simple structr efor compile-time evaluation of the range of decimal digits N1->N2 (N2 is excluded) for the given integral type. More... | |
struct | Digit |
simple structure for evaluation of Nth digit for the integral type More... | |
struct | Digits |
simple structure for evaluation of range of decomal digits N1->N2 (N2 is excluded) for the integral type More... | |
class | Line |
A very simple class to describe a 3D-line. More... | |
struct | _AbsCompare |
The trivial structure for comparison of "numbers" by the absolute value. More... | |
class | MD5 |
struct | TypeWrapper |
Simple helepr routine to wrap the type. More... | |
Namespaces | |
namespace | detail |
namespace | GSL |
namespace | Operators |
LHCbMath/MatrixTransforms.h. | |
namespace | SymMatrixInverter |
namespace to hold actual implementation of templated matrix inversion routines for symmetric matrices | |
namespace | SymPosDefMatrixInverter |
namespace to hold actual implementation of templated matrix inversion routines for symmetric positive definite matrices | |
Typedefs | |
typedef Line< XYZPoint, XYZVector > | XYZLine |
3D cartesian line (double) | |
typedef Line< Polar3DPoint, Polar3DVector > | Polar3DLine |
3D ploar line (double) | |
typedef Line< RhoEtaPhiPoint, RhoEtaPhiVector > | RhoEtaPhiLine |
3D RhoEtaPhi line (double) | |
typedef Line< RhoZPhiPoint, RhoZPhiVector > | RhoZPhiLine |
3D RhoZPhi line (double) | |
typedef Line< XYZPointF, XYZVectorF > | XYZLineF |
3D cartesian line (float) | |
typedef Line< Polar3DPointF, Polar3DVectorF > | Polar3DLineF |
3D ploar line (float) | |
typedef Line< RhoEtaPhiPointF, RhoEtaPhiVectorF > | RhoEtaPhiLineF |
3D RhoEtaPhi line (float) | |
typedef Line< RhoZPhiPointF, RhoZPhiVectorF > | RhoZPhiLineF |
3D RhoZPhi line (float) | |
Functions | |
template<class TYPE> | |
TYPE | digit (const TYPE value, const unsigned int N) |
simple function which evaluate N-th decimal digit for the integral value | |
template<class TYPE> | |
TYPE | digits (const TYPE value, const unsigned int N1, const unsigned int N2) |
simple function which evaluate the range of decimal digits N1-.N2 (N2 is excluded) for the integral values | |
template<typename aLine, typename aPlane, typename aPoint> | |
bool | intersection (const aLine &line, const aPlane &plane, aPoint &intersect, double &mu) |
calculate intersection point between a aLine and aPlane. | |
template<typename aLine, typename aPlane> | |
bool | intersection (const aPlane &plane0, const aPlane &plane1, aLine &intersect) |
Calculate aLine, the intersection of two aPlanes pane0 and plane1. | |
template<typename aPoint, typename aPlane> | |
bool | intersection (const aPlane &plane0, const aPlane &plane1, const aPlane &plane2, aPoint &intersect) |
Calculate aPoint, the intersection of three aPlanes. | |
template<typename aPoint, typename aLine> | |
double | impactParameter (const aPoint &point, const aLine &line) |
Return the distance between point and line. | |
template<typename aLine, typename bLine> | |
double | distance (const aLine &line0, const bLine &line1) |
Compute the distance between two lines. | |
template<typename aLine, typename bLine, typename aPoint> | |
bool | closestPoints (const aLine &line0, const bLine &line1, aPoint &p0, aPoint &p1) |
Get nearest aPoints p0 and p1 between aLines line0 and abd bLine line2 such that p0 = line0.beginPoint() + mu0 * line0.direction() p1 = line1.beginPoint() + mu1 * line1.direction(). | |
template<typename aLine, typename aPoint> | |
double | closestPointParam (const aPoint &point, const aLine &line) |
Return scalar parameter defining the point on aLine which is closest to an aPoint, such that closest point = line.beginPoint() + scalar * line.direction(). | |
template<typename aLine, typename aPoint> | |
aPoint | closestPoint (const aPoint &point, const aLine &line) |
Return aPoint on aLine which is closest to an aPoint. | |
template<typename aLine, typename bLine> | |
bool | closestPointParams (const aLine &line0, const bLine &line1, double &mu0, double &mu1) |
Calculate scalar parameters defining points of nearest approach between aLine line0 and bLine line1. | |
template<typename aLine, typename bLine> | |
bool | parallel (const aLine &line0, const bLine &line1) |
Estimate whether two lines are parallel Use dot product of line0.direction() and line1.direction() = 1. | |
template<class C, class T> | |
double | sigma2mass2 (const ROOT::Math::LorentzVector< C > &momentum, const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > &covariance) |
evaluate the dispersion of M^2 from the particle 4-vector and the covarinace matrix | |
template<class C, class T> | |
double | sigma2mass (const ROOT::Math::LorentzVector< C > &momentum, const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > &covariance) |
evaluate the dispersion of M from the particle 4-vector and the covarinace matrix | |
template<class C, class T> | |
double | sigmamass (const ROOT::Math::LorentzVector< C > &momentum, const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > &covariance) |
evaluate sigma(M) from the particle 4-vector and the covarinace matrix | |
template<class C, class T> | |
double | chi2mass (const double mass, const ROOT::Math::LorentzVector< C > &momentum, const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > &covariance) |
evaluate the chi2 of the mass | |
template<class OUTPUTTYPE> | |
unsigned int | SolveQuadraticEquation (const double a, const double b, const double c, OUTPUTTYPE out) |
Solve the quadratic equation: a*x*x + b*x + c = 0;. | |
template<class T> | |
bool | invertPosDefSymMatrix (T &matrix) |
invert symmetric positive definite matrices | |
template<class T> | |
bool | invertSymMatrix (T &matrix) |
invert symmetric matrices | |
template<typename M> | |
SMatrix< typename M::value_type, M::kRows, M::kRows, MatRepSym< typename M::value_type, M::kRows > > | Symmetrize (const M &rhs) |
Create a new symmetric matrix from the upper triangle of the input matrix. | |
template<class C, class T> | |
const ROOT::Math::SVector< T, 3 > & | geo2LA (const ROOT::Math::PositionVector3D< C > &source, ROOT::Math::SVector< T, 3 > &dest) |
fill Linear Algebra - vector from 3D-point | |
template<class C, class T> | |
const ROOT::Math::SVector< T, 3 > & | geo2LA (const ROOT::Math::DisplacementVector3D< C > &source, ROOT::Math::SVector< T, 3 > &dest) |
fill Linear Algebra - vector from 3D-vector | |
template<class C, class T> | |
const ROOT::Math::SVector< T, 4 > & | geo2LA (const ROOT::Math::LorentzVector< C > &source, ROOT::Math::SVector< T, 4 > &dest) |
fill Linear Algebra - vector from 4D-vector | |
template<class C, class T> | |
const ROOT::Math::SVector< T, 3 > & | geo2LA (const ROOT::Math::LorentzVector< C > &source, ROOT::Math::SVector< T, 3 > &dest) |
fill Linear Algebra 3-vector from the spatial components of 4D-(Lorentz)vector | |
template<class C, class T> | |
const ROOT::Math::PositionVector3D< C > & | la2geo (const ROOT::Math::SVector< T, 3 > &source, ROOT::Math::PositionVector3D< C > &dest) |
fill 3D-point from Linear Algebra vector | |
template<class C, class T> | |
const ROOT::Math::DisplacementVector3D< C > & | la2geo (const ROOT::Math::SVector< T, 3 > &source, ROOT::Math::DisplacementVector3D< C > &dest) |
fill 3D-vector from Linear Algebra vector | |
template<class C, class T> | |
const ROOT::Math::LorentzVector< C > & | la2geo (const ROOT::Math::SVector< T, 4 > &source, ROOT::Math::LorentzVector< C > &dest) |
fill Lorentz vector from Linear Algebra vector | |
template<class C, class T> | |
T | Similarity (const ROOT::Math::DisplacementVector3D< C > &delta, const ROOT::Math::SMatrix< T, 3, 3, ROOT::Math::MatRepSym< T, 3 > > &matrix) |
construct similarity("chi2") using 3D-vector | |
template<class C, class T> | |
T | Similarity (const ROOT::Math::SMatrix< T, 3, 3, ROOT::Math::MatRepSym< T, 3 > > &matrix, const ROOT::Math::DisplacementVector3D< C > &delta) |
construct similarity("chi2") using 3D-vector | |
template<class C, class T> | |
T | Similarity (const ROOT::Math::LorentzVector< C > &delta, const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > &matrix) |
construct similarity("chi2") using 4D-vector | |
template<class C, class T> | |
T | Similarity (const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > &matrix, const ROOT::Math::LorentzVector< C > &delta) |
construct similarity("chi2") using 4D-vector | |
template<class C, class T> | |
const ROOT::Math::LorentzVector< C > & | add (ROOT::Math::LorentzVector< C > &v1, const ROOT::Math::SVector< T, 4 > &v2) |
increment LorentzVector with 4-component linear vector | |
template<class T1, class T2, unsigned int D, class R> | |
ROOT::Math::SMatrix< T1, D, D, ROOT::Math::MatRepSym< T1, D > > & | add (ROOT::Math::SMatrix< T1, D, D, ROOT::Math::MatRepSym< T1, D > > &matrix, const ROOT::Math::SMatrix< T2, D, D, R > &other) |
increment the symmetric matrix with "symmetrized" part of other matrix | |
template<class T, class C, class M> | |
const ROOT::Math::LorentzVector< C > & | geo2LA (const ROOT::Math::SVector< T, 3 > &source, const M mass, ROOT::Math::LorentzVector< C > &dest) |
Fill Lorentz vector from 3D displacement vector + Mass. | |
template<class T, class R, class M> | |
void | JacobdP4dMom (const ROOT::Math::SVector< T, 3 > &mom, const M mass, ROOT::Math::SMatrix< R, 4, 3 > &J) |
Compute the jacobian for the transformation of a covariance matrix with rows representing track parameters TxTyQop and columns in xyz into a covariance matrix representing the track parameters in PxPyPzE and columns xyz. | |
template<class T, unsigned int D> | |
size_t | setToScalar (ROOT::Math::SVector< T, D > &m, const T &value=T()) |
set all elements of vector equal to some scalar value | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
size_t | setToScalar (ROOT::Math::SMatrix< T, D1, D2, R > &m, const T &value=T()) |
set all elements of matrix equal to some scalar value | |
template<class T, unsigned int D, class R> | |
size_t | setToUnit (ROOT::Math::SMatrix< T, D, D, R > &m, const T &value=T(1)) |
set square matrix to be proportional to unit matrix | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
size_t | scale (ROOT::Math::SMatrix< T, D1, D2, R > &m, const T &value) |
efficient scale all elements of the matrix | |
template<class T, unsigned int D> | |
size_t | scale (ROOT::Math::SVector< T, D > &m, const T &value) |
efficient scale all elements of the vector | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
T | max_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find the maximal element in matrix | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
T | min_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find the minimal element in matrix | |
template<class T, unsigned int D> | |
T | max_element (const ROOT::Math::SVector< T, D > &m) |
find the maximal element in vector | |
template<class T, unsigned int D> | |
T | min_element (const ROOT::Math::SVector< T, D > &m) |
find the minimal element in vector | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
T | maxabs_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find the element in matrix with the maximal absolute value | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
T | minabs_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find the element in matrix with the minimal absolute value | |
template<class T, unsigned int D1, unsigned int D2, class R, class CMP> | |
std::pair< unsigned int, unsigned int > | ind_max_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m, CMP cmp) |
find an index of the maximal element in matrix | |
template<class T, unsigned int D, class CMP> | |
std::pair< unsigned int, unsigned int > | ind_max_element (const ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > &m, CMP cmp) |
find an index of the maximal element in symmetric matrix | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
std::pair< unsigned int, unsigned int > | ind_max_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find an index of the maximal element in matrix | |
template<class T, unsigned int D1, unsigned int D2, class R, class CMP> | |
std::pair< unsigned int, unsigned int > | ind_min_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m, CMP cmp) |
find an index of the minimal element in matrix | |
template<class T, unsigned int D, class CMP> | |
std::pair< unsigned int, unsigned int > | ind_min_element (const ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > &m, CMP cmp) |
find an index of the minimal element in symmetric matrix | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
std::pair< unsigned int, unsigned int > | ind_min_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find an index of the minimal element in the matrix | |
template<class T, unsigned int D, class CMP> | |
unsigned int | ind_max_element (const ROOT::Math::SVector< T, D > &m, CMP cmp) |
find an index of the maximal element in the vector | |
template<class T, unsigned int D, class CMP> | |
unsigned int | ind_min_element (const ROOT::Math::SVector< T, D > &m, CMP cmp) |
find an index of the minimal element in the vector | |
template<class T, unsigned int D> | |
unsigned int | ind_max_element (const ROOT::Math::SVector< T, D > &m) |
find an index of the maximal element in the vector | |
template<class T, unsigned int D> | |
unsigned int | ind_min_element (const ROOT::Math::SVector< T, D > &m) |
find an index of the minimal element in the vector | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
std::pair< unsigned int, unsigned int > | ind_maxabs_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find an index of the element with the maximal absolute value | |
template<class T, unsigned int D1, unsigned int D2, class R> | |
std::pair< unsigned int, unsigned int > | ind_minabs_element (const ROOT::Math::SMatrix< T, D1, D2, R > &m) |
find an index of the element with the minimal absolute value | |
template<class T, unsigned int D> | |
unsigned int | ind_maxabs_element (const ROOT::Math::SVector< T, D > &m) |
find an index of the element with maximal absolute value | |
template<class T, unsigned int D> | |
unsigned int | ind_minabs_element (const ROOT::Math::SVector< T, D > &m) |
find an index of the element with minimal absolute value | |
template<class T, unsigned int D, class R> | |
T | trace (const ROOT::Math::SMatrix< T, D, D, R > &m) |
evaluate the trace (sum of diagonal elements) of the square matrix | |
template<class B, class T, unsigned int D, class R> | |
T | trace (ROOT::Math::Expr< B, T, D, D, R > &m) |
evaluate the trace (sum of diagonal elements) of the square matrix | |
template<class T, unsigned int D, class R, class CMP> | |
T | min_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m, CMP cmp) |
find the minimal diagonal element | |
template<class T, unsigned int D, class R, class CMP> | |
T | max_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m, CMP cmp) |
find the maximal diagonal element | |
template<class T, unsigned int D, class R> | |
T | max_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m) |
find the maximal diagonal element of square matrix | |
template<class T, unsigned int D, class R> | |
T | min_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m) |
find the maximal diagonal element of the square matrix | |
template<class T, unsigned int D, class R> | |
T | maxabs_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m) |
find the diagonal element of square matrix with maximal absolute value | |
template<class T, unsigned int D, class R> | |
T | minabs_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m) |
find the diagonal element of the square matrix with the minimal absolute value | |
template<class T, unsigned int D1, unsigned int D2, class R, class P> | |
size_t | count_if (const ROOT::Math::SMatrix< T, D1, D2, R > &m, P pred) |
count the number of elements in matrix, which satisfy the certain criteria | |
template<class T, unsigned int D, class P> | |
size_t | count_if (const ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > &m, P pred) |
count the number of elements in matrix, which satisfy the certain criteria | |
template<class T, unsigned int D, class R, class P> | |
size_t | count_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m, P pred) |
count number of diagonal elements in matrix, which satisfy certain criteria | |
template<class T, unsigned int D1, unsigned int D2, class R, class P> | |
bool | check_if (const ROOT::Math::SMatrix< T, D1, D2, R > &m, P pred) |
check the presence of at least one element which satisfy the criteria | |
template<class T, unsigned int D, class R, class P> | |
bool | check_diagonal (const ROOT::Math::SMatrix< T, D, D, R > &m, P pred) |
check the presence of at least one diagonal element which satisfy the criteria | |
template<class T1, class T2, unsigned int D1, unsigned int D2, class R1, class R2, class P> | |
bool | equal_if (const ROOT::Math::SMatrix< T1, D1, D2, R1 > &m1, const ROOT::Math::SMatrix< T2, D1, D2, R2 > &m2, P pred) |
check the "equality" of the two matrices by checking element-by-element: true == pred( m1(i,j) , m2(i,j) ) | |
template<class T, unsigned int D1, unsigned int D2, class R, class P> | |
bool | equal_if (const ROOT::Math::SMatrix< T, D1, D2, R > &m1, const ROOT::Math::SMatrix< T, D1, D2, R > &m2, P pred) |
check the "equality" of the two matrices by checking element-by-element: true == pred( m1(i,j) , m2(i,j) ) | |
template<class T, class T2, unsigned int D> | |
void | update (ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > &left, const ROOT::Math::SVector< T2, D > &vect, const double scale) |
update the symmetric matrix according to the rule m += s*v*v^T | |
template<class T, class B, class T2, unsigned int D> | |
void | update (ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > &left, const ROOT::Math::VecExpr< B, T2, D > &vect, const double scale) |
update the symmetric matrix according to the rule m += s*v*v^T | |
template<class T, class R, class T2, class T3, unsigned int D1, unsigned int D2> | |
void | update (ROOT::Math::SMatrix< T, D1, D2, R > &left, const ROOT::Math::SVector< T2, D1 > &vct1, const ROOT::Math::SVector< T3, D2 > &vct2, const double scale=1.0) |
update the matrix according to the rule m += s*v1*v2^T | |
template<class T, class T1, class T2, class R, unsigned int D1, unsigned int D2> | |
T | mult (const ROOT::Math::SVector< T1, D1 > &vct1, const ROOT::Math::SMatrix< T, D1, D2, R > &mtrx, const ROOT::Math::SVector< T2, D2 > &vct2) |
useful shortcut for product of vector, matrix and vector (v1^T*M*v2) | |
template<class T, class T2, class R, unsigned int D> | |
void | update (ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > &left, const ROOT::Math::SMatrix< T2, D, D, R > &right, const double scale=1.0) |
update the symmetric matrix according to the rule m += scale * ( m + m^T ) | |
template<class T, class T2, class B, class R, unsigned int D> | |
void | update (ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > &left, const ROOT::Math::Expr< B, T2, D, D, R > &right, const double scale=1.0) |
update the symmetric matrix according to the rule m += scale * ( m + m^T ) | |
template<typename TYPE> | |
TYPE | pow (TYPE __x, unsigned long __n) |
Simple utility for efficient "pow". | |
template<typename ITERATOR, typename aLine> | |
unsigned int | intersectionLineSphere (const aLine &line, const double radius2, ITERATOR out) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with sphere of radius sqrt(radius) | |
template<typename ITERATOR, typename aLine> | |
unsigned int | intersectionLineCylinder (const aLine &line, const double radius2, ITERATOR out) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with cylinder of radius sqrt(radius) | |
template<typename ITERATOR, typename aLine> | |
unsigned int | intersectionLinePlaneX (const aLine &line, const double X, ITERATOR out) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with plane x=X | |
template<typename ITERATOR, typename aLine> | |
unsigned int | intersectionLinePlaneY (const aLine &line, const double Y, ITERATOR out) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with plane y=Y | |
template<typename ITERATOR, typename aLine> | |
unsigned int | intersectionLinePlaneZ (const aLine &line, const double Z, ITERATOR out) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with plane z=Z | |
template<typename ITERATOR, typename aLine> | |
unsigned int | intersectionLinePlanePhi (const aLine &line, const double Phi, ITERATOR out) |
find intersection ticks for the line parametrized beginPoint + direction() * Tick with half-plane phi=Phi | |
template<typename ITERATOR, typename aLine> | |
unsigned int | intersectionLineCone (const aLine &line, const double Theta, ITERATOR out) |
find intersection ticks for the line parametrized beginPoint + direction() * Tick with cone theta=Theta |
typedef Line<XYZPoint, XYZVector> Gaudi::Math::XYZLine |
typedef Line<XYZPointF, XYZVectorF> Gaudi::Math::XYZLineF |
TYPE Gaudi::Math::digit | ( | const TYPE | value, | |
const unsigned int | N | |||
) | [inline] |
simple function which evaluate N-th decimal digit for the integral value
unsigned int value = ... ; unsigned int N = ... ; const int digN = Gaudi::Math::digit ( value , N ) ;
Definition at line 399 of file Digit.h.
00400 { 00401 // ====================================================================== 00402 BOOST_STATIC_ASSERT ( boost::integer_traits<TYPE>::is_specialized ) ; 00403 BOOST_STATIC_ASSERT ( boost::integer_traits<TYPE>::is_integral ) ; 00404 BOOST_STATIC_ASSERT ( !boost::integer_traits<TYPE>::is_signed ) ; 00405 // ====================================================================== 00406 if ( N > (unsigned int) boost::integer_traits<TYPE>::digits10 ) { return 0 ; } // RETURN 00407 else if ( N < (unsigned int) boost::integer_traits<TYPE>::digits10 ) 00408 { 00409 // ==================================================================== 00410 const TYPE ten = 10 ; 00411 const TYPE aux = Gaudi::Math::pow ( ten , N ) ; 00412 return (value/aux)%10 ; // RETURN 00413 // ==================================================================== 00414 } 00415 // ====================================================================== 00416 const unsigned long long val = value ; 00417 const unsigned long long ten = 10 ; 00418 const unsigned long long aux = Gaudi::Math::pow ( ten , N ) ; 00419 return (val/aux)%10 ; // RETURN 00420 // ====================================================================== 00421 }
TYPE Gaudi::Math::digits | ( | const TYPE | value, | |
const unsigned int | N1, | |||
const unsigned int | N2 | |||
) | [inline] |
simple function which evaluate the range of decimal digits N1-.N2 (N2 is excluded) for the integral values
unsigned int value = ... ; unsigned int N1 = ... ; unsigned int N2 = ... ; const bool digN1N2 = Gaudi::Math::digits( value , N1 , N2 ) ;
Definition at line 442 of file Digit.h.
00445 { 00446 // ====================================================================== 00447 BOOST_STATIC_ASSERT ( boost::integer_traits<TYPE>::is_specialized ) ; 00448 BOOST_STATIC_ASSERT ( boost::integer_traits<TYPE>::is_integral ) ; 00449 BOOST_STATIC_ASSERT ( !boost::integer_traits<TYPE>::is_signed ) ; 00450 // ====================================================================== 00451 if ( N2 > 1 + boost::integer_traits<TYPE>::digits10 ) 00452 { return digits ( value , N1 , 1 + boost::integer_traits<TYPE>::digits10 ) ; } 00453 // ====================================================================== 00454 if ( N1 >= N2 || 00455 N1 > (unsigned int) boost::integer_traits<TYPE>::digits10 ) 00456 { return 0 ; } // RETURN 00457 // 00458 if ( N1 < (unsigned int) boost::integer_traits<TYPE>::digits10 && 00459 N2 - N1 < (unsigned int) boost::integer_traits<TYPE>::digits10 ) 00460 { 00461 // ==================================================================== 00462 const TYPE ten = 10 ; 00463 const TYPE aux1 = Gaudi::Math::pow ( ten , N1 ) ; 00464 const TYPE aux2 = Gaudi::Math::pow ( ten , N2 - N1 ) ; 00465 return (value/aux1)%aux2 ; // RETURN 00466 // ==================================================================== 00467 } 00468 // ====================================================================== 00469 const unsigned long long val = value ; 00470 const unsigned long long ten = 10 ; 00471 const unsigned long long aux1 = Gaudi::Math::pow ( ten , N1 ) ; 00472 const unsigned long long aux2 = Gaudi::Math::pow ( ten , N2 - N1 ) ; 00473 return (val/aux1)%aux2 ; // RETURN 00474 // ====================================================================== 00475 }
bool Gaudi::Math::intersection | ( | const aLine & | line, | |
const aPlane & | plane, | |||
aPoint & | intersect, | |||
double & | mu | |||
) |
calculate intersection point between a aLine and aPlane.
aLine must satisfy point = line.beginPoint() + scalar*line.direction() and export its vector type as aLine::Vector
aPlane must have methods Normal() and HesseDistance()
aPoint must be constructible from object with x(), y(), z() methods.
Juan Palacios
line,: | generic line | |
plane,: | generic plane | |
intersect,: | Intersection point | |
mu,: | scalar defining point on line which intersects plane |
bool Gaudi::Math::intersection | ( | const aPlane & | plane0, | |
const aPlane & | plane1, | |||
aLine & | intersect | |||
) |
Calculate aLine, the intersection of two aPlanes pane0 and plane1.
aLine must satisfy point = line.beginPoint() + scalar*line.direction() and export its vector and point types as aLine::Vector and aLine::Point respectively
aPlane must have methods Normal() and HesseDistance() and export its scalar type as aPlane::Scalar
plane0,: | aPlane to be intersected | |
plane1,: | aPlane to be intersected | |
intersect,: | aLine of intersection between plane0 and plane1 |
bool Gaudi::Math::intersection | ( | const aPlane & | plane0, | |
const aPlane & | plane1, | |||
const aPlane & | plane2, | |||
aPoint & | intersect | |||
) |
Calculate aPoint, the intersection of three aPlanes.
aPlane must have methods Normal() and HesseDistance() and export its scalar type as aPlane::Scalar
aPoint must be constructible from object with x(), y(), z() methods.
plane0,: | aPlane to be intersected | |
plane1,: | aPlane to be intersected | |
plane2,: | aPlane to be intersected | |
intersect,: | aPoint, point of intersection between three planes |
double Gaudi::Math::impactParameter | ( | const aPoint & | point, | |
const aLine & | line | |||
) |
Return the distance between point and line.
point,: | aPoint who's distance to line is to be calculated | |
line,: | aLine who's distance to point is to be calculated |
double Gaudi::Math::distance | ( | const aLine & | line0, | |
const bLine & | line1 | |||
) |
Compute the distance between two lines.
aLine and bLine must satisfy point = line.beginPoint() + scalar*line.direction() and export its vector and point types as Line::Vector and Line::Point respectively
line0,: | aLine in distance calculation | |
line1,: | bLine in distance calculation |
bool Gaudi::Math::closestPoints | ( | const aLine & | line0, | |
const bLine & | line1, | |||
aPoint & | p0, | |||
aPoint & | p1 | |||
) |
Get nearest aPoints p0 and p1 between aLines line0 and abd bLine line2 such that p0 = line0.beginPoint() + mu0 * line0.direction() p1 = line1.beginPoint() + mu1 * line1.direction().
aLine must satisfy point = line.beginPoint() + scalar*line.direction()
aPoint must be constructible from object with x(), y(), z() methods.
line0,: | aLine in distance calculation | |
line1,: | bLine in distance calculation | |
p0,: | closest point line0.beginPoint() + mu0 * line0.direction() | |
p1,: | closest point line1.beginPoint() + mu1 * line1.direction() |
double Gaudi::Math::closestPointParam | ( | const aPoint & | point, | |
const aLine & | line | |||
) |
Return scalar parameter defining the point on aLine which is closest to an aPoint, such that closest point = line.beginPoint() + scalar * line.direction().
aLine must satisfy point = line.beginPoint() + scalar*line.direction()
aPoint must be constructible from object with x(), y(), z() methods.
point,: | ||
line,: |
aPoint Gaudi::Math::closestPoint | ( | const aPoint & | point, | |
const aLine & | line | |||
) |
Return aPoint on aLine which is closest to an aPoint.
aLine must satisfy point = line.beginPoint() + scalar*line.direction() and export its vector and point types as aLine::Vector and aLine::Point respectively
aPoint must be constructible from object with x(), y(), z() methods.
point,: | ||
line,: |
bool Gaudi::Math::closestPointParams | ( | const aLine & | line0, | |
const bLine & | line1, | |||
double & | mu0, | |||
double & | mu1 | |||
) |
Calculate scalar parameters defining points of nearest approach between aLine line0 and bLine line1.
If p0 and p1 are the points of closest approach, mu0 and mu1 satisfy p0 = line0.beginPoint() + mu0 * line0.direction() p0 = line1.beginPoint() + mu1 * line1.direction()
line0 | ||
line1 | ||
mu0,: | scalar parameter defining point on line0 closest to line1 | |
mu1,: | scalar parameter defining point on line1 closest to line0 |
bool Gaudi::Math::parallel | ( | const aLine & | line0, | |
const bLine & | line1 | |||
) |
Estimate whether two lines are parallel Use dot product of line0.direction() and line1.direction() = 1.
line0 | ||
line1 |
double Gaudi::Math::sigma2mass2 | ( | const ROOT::Math::LorentzVector< C > & | momentum, | |
const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > & | covariance | |||
) | [inline] |
evaluate the dispersion of M^2 from the particle 4-vector and the covarinace matrix
const LHCb::Particle* p = ... ; double s2m2 = sigma2mass2 ( p -> momentum() , p -> momCovMatrix() ) ;
momentum | (in) the particle momentum | |
covariance | (in) 4x4 covarinnce matrix |
Definition at line 46 of file Kinematics.h.
00048 { 00049 // get the vector d(M2)/dp_i : 00050 ROOT::Math::SVector<T,4> dM2dp; 00051 dM2dp [0] = -2 * momentum.Px () ; 00052 dM2dp [1] = -2 * momentum.Py () ; 00053 dM2dp [2] = -2 * momentum.Pz () ; 00054 dM2dp [3] = 2 * momentum.E () ; 00055 // 00056 return ROOT::Math::Similarity ( covariance , dM2dp ) ; 00057 }
double Gaudi::Math::sigma2mass | ( | const ROOT::Math::LorentzVector< C > & | momentum, | |
const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > & | covariance | |||
) | [inline] |
evaluate the dispersion of M from the particle 4-vector and the covarinace matrix
const LHCb::Particle* p = ... ; double s2m = sigma2mass ( p -> momentum() , p -> momCovMatrix() ) ;
momentum | (in) the particle momentum | |
covariance | (in) 4x4 covarinnce matrix |
Definition at line 80 of file Kinematics.h.
00082 { 00083 const double s2m2 = sigma2mass2( momentum , covariance ) ; 00084 const double m2 = momentum.M2 () ; 00085 if ( 0 < m2 ) { return 0.25 * s2m2 / m2 ; } 00086 return -1000000 ; // RETURN 00087 }
double Gaudi::Math::sigmamass | ( | const ROOT::Math::LorentzVector< C > & | momentum, | |
const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > & | covariance | |||
) | [inline] |
evaluate sigma(M) from the particle 4-vector and the covarinace matrix
const LHCb::Particle* p = ... ; double sigma = sigmamass ( p -> momentum() , p -> momCovMatrix() ) ;
momentum | (in) the particle momentum | |
covariance | (in) 4x4 covarinnce matrix |
Definition at line 110 of file Kinematics.h.
00112 { 00113 const double s2m = sigma2mass ( momentum , covariance ) ; 00114 if ( 0 < s2m ) { return ::sqrt ( s2m ) ; } 00115 return s2m ; 00116 }
double Gaudi::Math::chi2mass | ( | const double | mass, | |
const ROOT::Math::LorentzVector< C > & | momentum, | |||
const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > & | covariance | |||
) | [inline] |
evaluate the chi2 of the mass
const LHCb::Particle* B = ... ; const double chi2 = chi2mass ( 5.279 * Gaudi::Units::GeV , B -> momentum() , B -> momCovMatrix() ) ;
mass | (in) nominal mass | |
momentum | (in) 4-momentum of the particle | |
covariance | (in) 4x4-covariance matrix |
Definition at line 140 of file Kinematics.h.
00143 { 00144 // sigma^2(M^2): 00145 const double s2 = 1.0 / Gaudi::Math::sigma2mass2 ( momentum , covariance ) ; 00146 // delta(M^2) 00147 const double dm2 = momentum.M2() - mass * mass ; 00148 // (delta^2(M^2))/(sigma^2(M^2)) 00149 return ( dm2 * dm2 ) * s2 ; 00150 }
unsigned int Gaudi::Math::SolveQuadraticEquation | ( | const double | a, | |
const double | b, | |||
const double | c, | |||
OUTPUTTYPE | out | |||
) | [inline] |
Solve the quadratic equation: a*x*x + b*x + c = 0;.
a | equation parameter | |
b | equation parameter | |
c | equation parameter | |
out | output iterator |
Definition at line 27 of file MathHelperFun.h.
00031 { 00032 if( 0 == a ) // it is indeed a linear equation: b*x + c = 0 00033 { 00034 // no solution! 00035 if( b == 0 ) { return 0 ; } // RETURN !!! 00036 // 1 solution! 00037 *out++ = -1.0 * c / b ; 00038 *out++ = -1.0 * c / b ; // double the solutions 00039 return 1; // RETURN !!! 00040 } 00041 double d = b * b - 4.0 * a * c ; 00042 // no solutions 00043 if( d < 0 ) { return 0; } // RETURN !!! 00044 // 1 or 2 solution 00045 d = sqrt( d ) ; 00046 *out++ = 0.5 * ( -b - d ) / a ; 00047 *out++ = 0.5 * ( -b + d ) / a ; 00048 // return number of solutions; 00049 return 0 == d ? 1 : 2 ; // RETURN !!! 00050 };
bool Gaudi::Math::invertPosDefSymMatrix | ( | T & | matrix | ) | [inline] |
invert symmetric positive definite matrices
For matrix dimensions N <= 6, hand-optimized template specializations exist.
A Cholesky decomposition is used. For real M = M^T non-singular, one can write M = L L^T, where L is a lower triangular with positive elements on the diagonale.
Except for very small matrices (about 2x2 and below), this implementation is more accurate than the matrix inversion routine that comes with ROOT for SMatrix's symmetric positive definite case.
Because of the way Cholesky decomposition works, prescaling matrix entries to improve condition number is usually not neccessary (the decomposition involves steps which effectively amount to applying such a prescaling).
Starting with matrix sizes of about 4x4 upward, this routine is faster than SMatrix's built-in Invert() for the symmetric case. Again, benchmark before starting to believe!
matrix | symmetric positive definite matrix |
Definition at line 53 of file MatrixInversion.h.
00054 { 00055 enum { N = T::kRows }; 00056 typedef typename T::value_type F; 00057 typedef typename ROOT::Math::MatRepSym<F, N> R; 00058 typedef typename ROOT::Math::SMatrix<F, N, N, R> M; 00059 return Gaudi::Math::SymPosDefMatrixInverter::inverter<M, F, N>()(matrix); 00060 }
bool Gaudi::Math::invertSymMatrix | ( | T & | matrix | ) | [inline] |
invert symmetric matrices
For matrix dimensions N <= 6, hand-optimized template specializations exist.
A variant of Cholesky decomposition is used. For real M = M^T non-singular, one can write M = L O L^T, where L is a lower triangular with positive elements on the diagonale and O is a diagonal matrix with entries +1 or -1, depending on the sign of the eigenvalues of M.
Except for very small matrices (about 2x2 and below), this implementation can be more accurate than the matrix inversion routine that comes with ROOT for SMatrix's symmetric case, provided that the elements on the diagonale dominate in magnitude (i.e. the contribution to L(i,i) from M(i,i) should be the largest contribution in magnitude). In any case, you should check which routine works best for you.
Because of the way Cholesky decomposition works, prescaling matrix entries to improve condition number is usually not neccessary (the decomposition involves steps which effectively amount to applying such a prescaling).
Starting with matrix sizes of about 5x5 upward, this routine is faster that SMatrix's built-in Invert() for the symmetric case. Again, benchmark before starting to believe!
matrix | symmetric matrix to invert |
Definition at line 91 of file MatrixInversion.h.
00092 { 00093 enum { N = T::kRows }; 00094 typedef typename T::value_type F; 00095 typedef typename ROOT::Math::MatRepSym<F, N> R; 00096 typedef typename ROOT::Math::SMatrix<F, N, N, R> M; 00097 return Gaudi::Math::SymMatrixInverter::inverter<M, F, N>()(matrix); 00098 }
SMatrix<typename M::value_type, M::kRows, M::kRows, MatRepSym<typename M::value_type, M::kRows> > Gaudi::Math::Symmetrize | ( | const M & | rhs | ) |
Create a new symmetric matrix from the upper triangle of the input matrix.
Definition at line 35 of file MatrixManip.h.
00035 { 00036 00037 SMatrix<typename M::value_type, M::kRows, M::kRows, 00038 MatRepSym<typename M::value_type, M::kRows> > result; 00039 00040 for ( unsigned int i = 0; i < M::kRows; ++i ) { 00041 for ( unsigned int j = 0; j < M::kRows; ++j ) { 00042 if (i<=j) result(i,j) = rhs(i,j); 00043 } 00044 } 00045 return result; 00046 }
const ROOT::Math::SVector<T,3>& Gaudi::Math::geo2LA | ( | const ROOT::Math::PositionVector3D< C > & | source, | |
ROOT::Math::SVector< T, 3 > & | dest | |||
) | [inline] |
fill Linear Algebra - vector from 3D-point
const Gaudi::XYZPoint xyzv = ... ; Gaudi::Vector4 lav ; // fill Linear Algebra vector from 3D-point geo2LA ( xyzv , lav ) ;
source | (input) 3D-point | |
dest | (output) Linear Algebra vector |
Definition at line 62 of file MatrixTransforms.h.
00064 { 00065 dest ( 0 ) = source.X () ; 00066 dest ( 1 ) = source.Y () ; 00067 dest ( 2 ) = source.Z () ; 00068 return dest ; 00069 }
const ROOT::Math::SVector<T,3>& Gaudi::Math::geo2LA | ( | const ROOT::Math::DisplacementVector3D< C > & | source, | |
ROOT::Math::SVector< T, 3 > & | dest | |||
) | [inline] |
fill Linear Algebra - vector from 3D-vector
const Gaudi::XYZVector xyzv = ... ; Gaudi::Vector4 lav ; // fill Linear Algebra vector from 3D-Vector geo2LA ( xyzv , lav ) ;
source | (input) 3D-Vector | |
dest | (output) Linear Algebra vector |
Definition at line 93 of file MatrixTransforms.h.
00095 { 00096 dest ( 0 ) = source.X () ; 00097 dest ( 1 ) = source.Y () ; 00098 dest ( 2 ) = source.Z () ; 00099 return dest ; 00100 }
const ROOT::Math::SVector<T,4>& Gaudi::Math::geo2LA | ( | const ROOT::Math::LorentzVector< C > & | source, | |
ROOT::Math::SVector< T, 4 > & | dest | |||
) | [inline] |
fill Linear Algebra - vector from 4D-vector
const Gaudi::LorenztVector lorv = ... ; Gaudi::Vector4 lav ; // fill Linear Algebra vector from Lorenz Vector geo2LA ( lorv , lav ) ;
source | (input) Lorentz Vector | |
dest | (output) Linear Algebra vector |
Definition at line 124 of file MatrixTransforms.h.
00126 { 00127 dest ( 0 ) = source.X () ; 00128 dest ( 1 ) = source.Y () ; 00129 dest ( 2 ) = source.Z () ; 00130 dest ( 3 ) = source.E () ; 00131 return dest ; 00132 }
const ROOT::Math::SVector<T,3>& Gaudi::Math::geo2LA | ( | const ROOT::Math::LorentzVector< C > & | source, | |
ROOT::Math::SVector< T, 3 > & | dest | |||
) | [inline] |
fill Linear Algebra 3-vector from the spatial components of 4D-(Lorentz)vector
const Gaudi::LorenztVector lorv = ... ; Gaudi::Vector3 v3 ; // fill Linear Algebra vector from Lorenz Vector geo2LA ( lorv , v3 ) ;
source | (input) Lorentz Vector | |
dest | (output) Linear Algebra vector |
Definition at line 157 of file MatrixTransforms.h.
00159 { 00160 dest ( 0 ) = source.X () ; 00161 dest ( 1 ) = source.Y () ; 00162 dest ( 2 ) = source.Z () ; 00163 return dest ; 00164 }
const ROOT::Math::PositionVector3D<C>& Gaudi::Math::la2geo | ( | const ROOT::Math::SVector< T, 3 > & | source, | |
ROOT::Math::PositionVector3D< C > & | dest | |||
) | [inline] |
fill 3D-point from Linear Algebra vector
Gaudi::XYZPoint xyzv = ... ; const Gaudi::Vector4 lav ; // fill 3D-point from Linear Algebra vector la2geo ( xyzv , lav ) ;
source | (input) Linear Algebra vector | |
dest | (output) 3D-point |
Definition at line 188 of file MatrixTransforms.h.
00190 { 00191 dest.SetX ( source ( 0 ) ) ; 00192 dest.SetY ( source ( 1 ) ) ; 00193 dest.SetZ ( source ( 2 ) ) ; 00194 return dest ; 00195 }
const ROOT::Math::DisplacementVector3D<C>& Gaudi::Math::la2geo | ( | const ROOT::Math::SVector< T, 3 > & | source, | |
ROOT::Math::DisplacementVector3D< C > & | dest | |||
) | [inline] |
fill 3D-vector from Linear Algebra vector
Gaudi::XYZVector xyzv = ... ; const Gaudi::Vector4 lav ; // fill 3D-Vector from Linear Algebra vector la2geo ( xyzv , lav ) ;
source | (input) Linear Algebra vector | |
dest | (output) 3D-vector |
Definition at line 219 of file MatrixTransforms.h.
00221 { 00222 dest.SetX ( source ( 0 ) ) ; 00223 dest.SetY ( source ( 1 ) ) ; 00224 dest.SetZ ( source ( 2 ) ) ; 00225 return dest ; 00226 }
const ROOT::Math::LorentzVector<C>& Gaudi::Math::la2geo | ( | const ROOT::Math::SVector< T, 4 > & | source, | |
ROOT::Math::LorentzVector< C > & | dest | |||
) | [inline] |
fill Lorentz vector from Linear Algebra vector
const Gaudi::LorenztVector lorv = ... ; Gaudi::Vector4 lav ; // fill Linear Algebra vector from Lorenz Vector geo2LA ( lorv , lav ) ;
source | (input) Lorentz Vector | |
dest | (output) Linear Algebra vector |
Definition at line 250 of file MatrixTransforms.h.
00252 { 00253 dest.SetPx ( source ( 0 ) ) ; 00254 dest.SetPy ( source ( 1 ) ) ; 00255 dest.SetPz ( source ( 2 ) ) ; 00256 dest.SetE ( source ( 3 ) ) ; 00257 return dest ; 00258 }
T Gaudi::Math::Similarity | ( | const ROOT::Math::DisplacementVector3D< C > & | delta, | |
const ROOT::Math::SMatrix< T, 3, 3, ROOT::Math::MatRepSym< T, 3 > > & | matrix | |||
) | [inline] |
construct similarity("chi2") using 3D-vector
E.g. one can ask the "chi2"-distance inbetween vertices:
const LHCb::Vertex* v1 = ... ; const LHCb::Vertex* v2 = ... ; int ifail = 0 ; // evaluate the chi2 distance const double chi2 = Gaudi::Math::Similarity ( v1->position() - v2.position() , ( v1->covMatrix() + v2->covMatrix() ).Sinverse( ifail ) ) ; if ( 0 != ifail ) { ... error here ... } ; always() << " Chi2 distance between vertices is " << chi2 << endreq ;
matrix | (input) symmetric (3x3) matrix used for similarity | |
delta | (input) 3D- vector |
Definition at line 289 of file MatrixTransforms.h.
00291 { 00292 ROOT::Math::SVector<T,3> tmp ; 00293 return ROOT::Math::Similarity ( geo2LA ( delta , tmp ) , matrix ) ; 00294 }
T Gaudi::Math::Similarity | ( | const ROOT::Math::SMatrix< T, 3, 3, ROOT::Math::MatRepSym< T, 3 > > & | matrix, | |
const ROOT::Math::DisplacementVector3D< C > & | delta | |||
) | [inline] |
construct similarity("chi2") using 3D-vector
E.g. one can ask the "chi2"-distance inbetween vertices:
const LHCb::Vertex* v1 = ... ; const LHCb::Vertex* v2 = ... ; int ifail = 0 ; // evaluate the chi2 distance const double chi2 = Gaudi::Math::Similarity ( ( v1->covMatrix() + v2->covMatrix() ).Sinverse( ifail ) , v1->position() - v2.position() ) ; if ( 0 != ifail ) { ... error here ... } ; always() << " Chi2 distance between vertices is " << chi2 << endreq ;
matrix | (input) symmetric (3x3) matrix used for similarity | |
delta | (input) 3D- vector |
Definition at line 325 of file MatrixTransforms.h.
00327 { return Similarity ( delta , matrix ) ; }
T Gaudi::Math::Similarity | ( | const ROOT::Math::LorentzVector< C > & | delta, | |
const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > & | matrix | |||
) | [inline] |
construct similarity("chi2") using 4D-vector
E.g. one can ask the "chi2"-distance inbetween momenta of particles
const LHCb::Particle* p1 = ... ; const LHCb::Particle* p2 = ... ; int ifail = 0 ; // evaluate the chi2 distance const double chi2 = Gaudi::Math::Similarity ( p1->momentum() - p2.momentum() , ( p1->momCovMatrix() + p2->momCovMatrix() ).Sinverse( ifail ) ) ; if ( 0 != ifail ) { ... error here ... } ; always() << " Chi2 distance in momenta is " << chi2 << endreq ;
delta | (input) Lorentz vector | |
matrix | (input) symmetric (4x4) matrix used for similarity |
Definition at line 358 of file MatrixTransforms.h.
00360 { 00361 ROOT::Math::SVector<T,4> tmp ; 00362 return ROOT::Math::Similarity ( geo2LA( delta , tmp ) , matrix ) ; 00363 }
T Gaudi::Math::Similarity | ( | const ROOT::Math::SMatrix< T, 4, 4, ROOT::Math::MatRepSym< T, 4 > > & | matrix, | |
const ROOT::Math::LorentzVector< C > & | delta | |||
) | [inline] |
construct similarity("chi2") using 4D-vector
E.g. one can ask the "chi2"-distance inbetween momenta of particles
const LHCb::Particle* p1 = ... ; const LHCb::Particle* p2 = ... ; int ifail = 0 ; // evaluate the chi2 distance const double chi2 = Gaudi::Math::Similarity * ( p1->momCovMatrix() + p2->momCovMatrix() ).Sinverse( ifail ) , p1->momentum() - p2.momentum() ) ; if ( 0 != ifail ) { ... error here ... } ; always() << " Chi2 distance in momenta is " << chi2 << endreq ;
matrix | (input) symmetric (4x4) matrix used for similarity | |
delta | (input) Lorentz vector |
Definition at line 394 of file MatrixTransforms.h.
00396 { return Similarity ( delta , matrix ) ; }
const ROOT::Math::LorentzVector<C>& Gaudi::Math::add | ( | ROOT::Math::LorentzVector< C > & | v1, | |
const ROOT::Math::SVector< T, 4 > & | v2 | |||
) | [inline] |
increment LorentzVector with 4-component linear vector
Gaudi::LorentzVector v1 = ... ; const Gaudi::Vector4 v2 = ... ; // update Lorentz vector with LA vector: Gaudi::Math::add ( v1 , v2 ) ;
v1 | (input/output) LorentzVector to be updated | |
v2 | (input) Linear Algebra vector, to be added to LorentzVector |
Definition at line 420 of file MatrixTransforms.h.
00421 { return v1 += ROOT::Math::LorentzVector<C> 00422 ( v2 ( 0 ) , v2 ( 1 ) , v2 ( 2 ) , v2 ( 3 ) ) ; }
ROOT::Math::SMatrix<T1,D,D,ROOT::Math::MatRepSym<T1,D> >& Gaudi::Math::add | ( | ROOT::Math::SMatrix< T1, D, D, ROOT::Math::MatRepSym< T1, D > > & | matrix, | |
const ROOT::Math::SMatrix< T2, D, D, R > & | other | |||
) | [inline] |
increment the symmetric matrix with "symmetrized" part of other matrix
Gaudi::SymMatrix3x3 matrix = ... ; const Gaudi::Matrix3x3 other = ... ; // update "matrix" with the upper triangular part of "other" Gaudi::Math::add ( matrix , other ) ;
matrix | symmetric matrix to be updated | |
other | matrix, upper traingle is used for updating |
Definition at line 446 of file MatrixTransforms.h.
00448 { 00449 for ( unsigned int i = 0 ; i < D ; ++i ) 00450 { for ( unsigned int j = i ; j < D ; ++j ) { matrix(i,j) += other(i,j); } } 00451 return matrix ; 00452 }
const ROOT::Math::LorentzVector<C>& Gaudi::Math::geo2LA | ( | const ROOT::Math::SVector< T, 3 > & | source, | |
const M | mass, | |||
ROOT::Math::LorentzVector< C > & | dest | |||
) | [inline] |
Fill Lorentz vector from 3D displacement vector + Mass.
geoLA(xyz, mass, lav)
[in] | source | Linear Algebra vector3D |
[in] | mass | Mass |
[out] | dest | Lorentz Vector |
Definition at line 473 of file MatrixTransforms.h.
00476 { 00477 // first calculate momentum in carthesian coordinates: 00478 const double p = 1/fabs(source(2)) ; 00479 const double n = sqrt( 1 + source(0)*source(0)+source(1)*source(1)) ; 00480 const double pz = p/n ; 00481 const double px = pz*source(0) ; 00482 const double py = pz*source(1) ; 00483 dest.SetPx ( px ) ; 00484 dest.SetPy ( py ) ; 00485 dest.SetPz ( pz ) ; 00486 dest.SetE ( std::sqrt ( p*p + mass*mass ) ) ; 00487 return dest ; 00488 }
void Gaudi::Math::JacobdP4dMom | ( | const ROOT::Math::SVector< T, 3 > & | mom, | |
const M | mass, | |||
ROOT::Math::SMatrix< R, 4, 3 > & | J | |||
) | [inline] |
Compute the jacobian for the transformation of a covariance matrix with rows representing track parameters TxTyQop and columns in xyz into a covariance matrix representing the track parameters in PxPyPzE and columns xyz.
ROOT::Math::SMatrix<T, 3 ,3 ,R> covTxTyQoP_xyz = .... ; ROOT::Math::SVector<C,3>& particleMomentum=...; ROOT::Math::SMatrix<T, 4 , 3, R > covPxPyPzE_xyz; massOfParticle = ...; ROOT::Math::SMatrix<T,4,3,R> Jacob; JacobdP4dMom (particleMomentum, massOfParticle, Jacob) ; covPxPyPzE_xyz = Jacob * covTxTyQoP_xyz;
mom | (input) the txtyqop vector of track/particle momenta | |
mass | (input) the particle mass | |
J | (output) the Jacobian for the transformation |
Definition at line 516 of file MatrixTransforms.h.
00519 { 00520 double tx = mom(0) ; 00521 double ty = mom(1) ; 00522 double qop = mom(2) ; 00523 double p = 1/fabs(qop) ; 00524 double n2 = 1 + tx*tx + ty*ty ; 00525 double n = std::sqrt(n2) ; 00526 double n3 = n2*n ; 00527 double px = p*tx/n ; 00528 double py = p*ty/n ; 00529 double pz = p/n ; 00530 double E = sqrt(p*p+mass*mass) ; 00531 00532 J(0,0) = p * (1+ty*ty)/n3 ; // dpx/dtx 00533 J(0,1) = p * tx * -ty/n3 ; // dpx/dty 00534 J(0,2) = -px/qop ; // dpx/dqop 00535 00536 J(1,0) = p * ty * -tx/n3 ; // dpy/dtx 00537 J(1,1) = p * (1+tx*tx)/n3 ; // dpy/dty 00538 J(1,2) = -py/qop ; // dpy/dqop 00539 00540 J(2,0) = pz * -tx/n2 ; // dpz/dtx 00541 J(2,1) = pz * -ty/n2 ; // dpz/dtx 00542 J(2,2) = -pz/qop ; // dpz/dqop 00543 00544 J(3,0) = 0.0 ; // dE/dtx 00545 J(3,1) = 0.0 ; // dE/dty 00546 J(3,2) = p/E * -p/qop ; // dE/dqop 00547 00548 return ; 00549 }
size_t Gaudi::Math::setToScalar | ( | ROOT::Math::SVector< T, D > & | m, | |
const T & | value = T() | |||
) | [inline] |
set all elements of vector equal to some scalar value
Gaudi::Vector3 vct = ... ; // set all elements to be equal to 10.0 : Gaudi::Math::setToScalar( vct , 10.0 ) ; // set all elements to be eual to 0 : Gaudi::Math::setToScalar( vct ) ;
m | (input/output)vector to be modified | |
value | (input) new value for all vector elements |
Definition at line 72 of file MatrixUtils.h.
size_t Gaudi::Math::setToScalar | ( | ROOT::Math::SMatrix< T, D1, D2, R > & | m, | |
const T & | value = T() | |||
) | [inline] |
set all elements of matrix equal to some scalar value
Gaudi::Matrix4x3 mtrx1 = ... ; Gaudi::SymMatrix5x5 mtrx2 = ... ; // set all elements to be equal to 10.0 : Gaudi::Math::setToScalar( mtrx1 , 10.0 ) ; // set all elements to be eual to 0 : Gaudi::Math::setToScalar( mtrx2 , 10.0 ) ;
m | (input/output) matrix to be modified | |
value | (input) new value for all matrix elements |
Definition at line 101 of file MatrixUtils.h.
00102 { 00103 std::fill ( m.begin() , m.end() , value ) ; 00104 return m.end() - m.begin() ; 00105 }
size_t Gaudi::Math::setToUnit | ( | ROOT::Math::SMatrix< T, D, D, R > & | m, | |
const T & | value = T(1) | |||
) | [inline] |
set square matrix to be proportional to unit matrix
Gaudi::Matrix4x4 mtrx1 = ... ; Gaudi::SymMatrix3x3 mtrx2 = ... ; // set mtrx1 to be equal unit matrix Gaudi::Math::setToUnit ( mtrx1 ) ; // set mtrx2 to be equal unit matrix, multiplied by 2 Gaudi::Math::setToUnit ( mtrx2 , 2.0 ) ;
[in,out] | m | matrix to be modified |
[in] | value | value to be used as diagonal elements |
nullify the matrix:
set diagonal elements
Definition at line 128 of file MatrixUtils.h.
00129 { 00131 std::fill ( m.begin() , m.end() , T(0.0) ) ; 00133 for ( unsigned int i = 0 ; i < D ; ++i ) { m(i,i) = value ; } 00134 return m.end() - m.begin() ; 00135 }
size_t Gaudi::Math::scale | ( | ROOT::Math::SMatrix< T, D1, D2, R > & | m, | |
const T & | value | |||
) | [inline] |
efficient scale all elements of the matrix
Gaudi::Matrix4x3 mtrx1 = ... ; Gaudi::SymMatrix5x5 mtrx2 = ... ; // multiply all elements by 100: Gaudi::Math::scale ( mtrx1 , 100.0 ) ; // divide all elements by 4 : Gaudi::Math::scale ( mtrx2 , 1.0/4.0 ) ;
m | (input/output) matrix to be modified | |
value | (input) scaling coefficient |
Definition at line 161 of file MatrixUtils.h.
00162 { 00163 typedef typename ROOT::Math::SMatrix<T,D1,D2,R>::iterator iterator ; 00164 for ( iterator it = m.begin() ; m.end() != it ; ++it ) { (*it) *= value ; } 00165 return m.end() - m.begin() ; 00166 }
size_t Gaudi::Math::scale | ( | ROOT::Math::SVector< T, D > & | m, | |
const T & | value | |||
) | [inline] |
efficient scale all elements of the vector
Gaudi::Vector4 vct = ... ; // multiply all elements by 100: Gaudi::Math::scale ( vct , 100.0 ) ;
m | (input/output) vector to be modified | |
value | (input) scaling coefficient |
Definition at line 188 of file MatrixUtils.h.
00189 { 00190 typedef typename ROOT::Math::SVector<T,D>::iterator iterator ; 00191 for ( iterator it = m.begin() ; m.end() != it ; ++it ) { (*it) *= value ; } 00192 return D ; 00193 }
T Gaudi::Math::max_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find the maximal element in matrix
m | (input) matrix to be studied |
Definition at line 216 of file MatrixUtils.h.
00217 { return *std::max_element ( m.begin() , m.end() ) ; }
T Gaudi::Math::min_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find the minimal element in matrix
m | (input) matrix to be studied |
Definition at line 228 of file MatrixUtils.h.
00229 { return *std::min_element ( m.begin() , m.end() ) ; }
T Gaudi::Math::max_element | ( | const ROOT::Math::SVector< T, D > & | m | ) | [inline] |
find the maximal element in vector
m | (input) vector to be studied |
Definition at line 240 of file MatrixUtils.h.
00241 { return *std::max_element ( m.begin() , m.end() ) ; }
T Gaudi::Math::min_element | ( | const ROOT::Math::SVector< T, D > & | m | ) | [inline] |
find the minimal element in vector
m | (input) vector to be studied |
Definition at line 252 of file MatrixUtils.h.
00253 { return *std::min_element ( m.begin() , m.end() ) ; }
T Gaudi::Math::maxabs_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find the element in matrix with the maximal absolute value
const Gaudi::Matrix4x3 mtrx1 = ... ; const Gaudi::Matrix4x3 mtrx2 = ... ; // find the maximal absolute difference between elements : const double diff = Gaudi::Math::maxabs_element ( mtrx1 - mtrx2 ) ; if ( diff < tolerance ) { std::cout << " matrices are almost identical " << std::endl ; }
m | (input) matrix to be studied |
Definition at line 279 of file MatrixUtils.h.
00280 { return *std::max_element ( m.begin() , m.end() , _AbsCompare<T>() ) ; }
T Gaudi::Math::minabs_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find the element in matrix with the minimal absolute value
m | (input) matrix to be studied |
Definition at line 291 of file MatrixUtils.h.
00292 { return *std::min_element ( m.begin() , m.end() , _AbsCompare<T>() ) ; }
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_max_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m, | |
CMP | cmp | |||
) | [inline] |
find an index of the maximal element in matrix
m | (input) matrix to be studied | |
cmp | comparison criteria |
Definition at line 304 of file MatrixUtils.h.
00305 { 00306 std::pair<unsigned int,unsigned int> result (0,0) ; 00307 T tmp = m(0,0) ; 00308 for ( unsigned int i = 0 ; i < D1 ; ++i ) 00309 { 00310 for ( unsigned int j = 0 ; j < D2 ; ++j ) 00311 { 00312 const T val = m(i,j) ; 00313 if ( !cmp( tmp , val ) ) { continue ; } 00314 tmp = val ; 00315 result.first = i ; 00316 result.second = j ; 00317 } 00318 } 00319 return result ; 00320 }
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_max_element | ( | const ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > & | m, | |
CMP | cmp | |||
) | [inline] |
find an index of the maximal element in symmetric matrix
m | (input) symmetric matrix to be studied | |
cmp | comparison criteria |
Definition at line 332 of file MatrixUtils.h.
00333 { 00334 std::pair<unsigned int,unsigned int> result (0,0) ; 00335 T tmp = m(0,0) ; 00336 for ( unsigned int i = 0 ; i < D ; ++i ) 00337 { 00338 for ( unsigned int j = i ; j < D ; ++j ) 00339 { 00340 const T val = m(i,j) ; 00341 if ( !cmp ( tmp , val ) ) { continue ; } 00342 tmp = val ; 00343 result.first = i ; 00344 result.second = j ; 00345 } 00346 } 00347 return result ; 00348 }
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_max_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find an index of the maximal element in matrix
m | (input) matrix to be studied |
Definition at line 359 of file MatrixUtils.h.
00360 { return ind_max_element ( m , std::less<T>() ) ; } ;
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_min_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m, | |
CMP | cmp | |||
) | [inline] |
find an index of the minimal element in matrix
m | (input) matrix to be studied | |
cmp | comparison criteria |
Definition at line 372 of file MatrixUtils.h.
00373 { 00374 std::pair<unsigned int,unsigned int> result (0,0) ; 00375 T tmp = m(0,0) ; 00376 for ( unsigned int i = 0 ; i < D1 ; ++i ) 00377 { 00378 for ( unsigned int j = 0 ; j < D2 ; ++j ) 00379 { 00380 const T val = m(i,j) ; 00381 if ( !cmp( val , tmp ) ) { continue ; } 00382 tmp = val ; 00383 result.first = i ; 00384 result.second = j ; 00385 } 00386 } 00387 return result ; 00388 }
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_min_element | ( | const ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > & | m, | |
CMP | cmp | |||
) | [inline] |
find an index of the minimal element in symmetric matrix
m | (input) symmetric matrix to be studied | |
cmp | comparison criteria |
Definition at line 400 of file MatrixUtils.h.
00401 { 00402 std::pair<unsigned int,unsigned int> result (0,0) ; 00403 T tmp = m(0,0) ; 00404 for ( unsigned int i = 0 ; i < D ; ++i ) 00405 { 00406 for ( unsigned int j = i ; j < D ; ++j ) 00407 { 00408 const T val = m(i,j) ; 00409 if ( !cmp ( tmp , val ) ) { continue ; } 00410 tmp = val ; 00411 result.first = i ; 00412 result.second = j ; 00413 } 00414 } 00415 return result ; 00416 }
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_min_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find an index of the minimal element in the matrix
const Gaudi::Matrix4x4 mtrx1 = ... ; const Gaudi::SymMatrix5x5 mtrx2 = ... ; typedef std::pair<unsigned int,unsigned int> PAIR ; // get the minimal element in mtrx1: PAIR index1 = Gaudi::Math::ind_max_element ( mtrx1 ) ; // get the minimal element in mtrx2: PAIR index2 = Gaudi::Math::ind_max_element ( mtrx2 ) ;
m | (input) matrix to be studied |
Definition at line 443 of file MatrixUtils.h.
00444 { return ind_min_element( m , std::less<T>() ) ; }
unsigned int Gaudi::Math::ind_max_element | ( | const ROOT::Math::SVector< T, D > & | m, | |
CMP | cmp | |||
) | [inline] |
find an index of the maximal element in the vector
m | (input) vector to be studied | |
cmp | comparison criteria |
Definition at line 456 of file MatrixUtils.h.
00457 { return std::max_element( m.begin() , m.end() , cmp ) - m.begin() ; }
unsigned int Gaudi::Math::ind_min_element | ( | const ROOT::Math::SVector< T, D > & | m, | |
CMP | cmp | |||
) | [inline] |
find an index of the minimal element in the vector
m | (input) vector to be studied | |
cmp | comparison criteria |
Definition at line 469 of file MatrixUtils.h.
00470 { return std::min_element( m.begin() , m.end() , cmp ) - m.begin() ; }
unsigned int Gaudi::Math::ind_max_element | ( | const ROOT::Math::SVector< T, D > & | m | ) | [inline] |
find an index of the maximal element in the vector
m | (input) vector to be studied |
Definition at line 481 of file MatrixUtils.h.
00482 { return std::max_element( m.begin() , m.end() ) - m.begin() ; }
unsigned int Gaudi::Math::ind_min_element | ( | const ROOT::Math::SVector< T, D > & | m | ) | [inline] |
find an index of the minimal element in the vector
m | (input) vector to be studied |
Definition at line 493 of file MatrixUtils.h.
00494 { return std::min_element ( m.begin() , m.end() ) - m.begin() ; }
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_maxabs_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find an index of the element with the maximal absolute value
const Gaudi::Matrix4x4 mtrx1 = ... ; const Gaudi::SymMatrix5x5 mtrx2 = ... ; typedef std::pair<unsigned int,unsigned int> PAIR ; // get the element with the maximal absolute value in mtrx1: PAIR index1 = Gaudi::Math::ind_maxabs_element ( mtrx1 ) ; // get the element with the maximal absolute value in mtrx2: PAIR index2 = Gaudi::Math::ind_maxabs_element ( mtrx2 ) ;
m | (input) matrix to be studied |
Definition at line 522 of file MatrixUtils.h.
00523 { return ind_max_element( m , _AbsCompare<T>() ) ; }
std::pair<unsigned int,unsigned int> Gaudi::Math::ind_minabs_element | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m | ) | [inline] |
find an index of the element with the minimal absolute value
const Gaudi::Matrix4x4 mtrx1 = ... ; const Gaudi::SymMatrix5x5 mtrx2 = ... ; typedef std::pair<unsigned int,unsigned int> PAIR ; // get the element with the minimal absolute value in mtrx1: PAIR index1 = Gaudi::Math::ind_minabs_element ( mtrx1 ) ; // get the element with the minimal absolute value in mtrx2: PAIR index2 = Gaudi::Math::ind_minabs_element ( mtrx2 ) ;
m | (input) matrix to be studied |
Definition at line 551 of file MatrixUtils.h.
00552 { return ind_min_element( m , _AbsCompare<T>() ) ; }
unsigned int Gaudi::Math::ind_maxabs_element | ( | const ROOT::Math::SVector< T, D > & | m | ) | [inline] |
find an index of the element with maximal absolute value
m | (input) vector to be studied |
Definition at line 563 of file MatrixUtils.h.
00564 { return ind_max_element ( m , _AbsCompare<T>() ) ; }
unsigned int Gaudi::Math::ind_minabs_element | ( | const ROOT::Math::SVector< T, D > & | m | ) | [inline] |
find an index of the element with minimal absolute value
m | (input) vector to be studied |
Definition at line 575 of file MatrixUtils.h.
00576 { return ind_min_element ( m , _AbsCompare<T>() ) ; }
T Gaudi::Math::trace | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m | ) | [inline] |
evaluate the trace (sum of diagonal elements) of the square matrix
const Gaudi::Matrix4x4 mtrx1 = ... ; const Gaudi::SymMatrix3x3 mtrx2 = ... ; // evaluate the trace of mtrx1: const double trace1 = Gaudi::Math::trace ( mtrx1 ) ; // evaluate the trace of mtrx2: const double trace2 = Gaudi::Math::trace ( mtrx2 ) ;
m | (input) matrix to be studied |
Definition at line 600 of file MatrixUtils.h.
00601 { 00602 T result = m(0,0) ; 00603 for ( unsigned int i = 1 ; i < D ; ++i ) { result += m(i,i) ; } 00604 return result ; 00605 }
T Gaudi::Math::trace | ( | ROOT::Math::Expr< B, T, D, D, R > & | m | ) | [inline] |
evaluate the trace (sum of diagonal elements) of the square matrix
const Gaudi::Matrix4x4 mtrx1 = ... ; const Gaudi::SymMatrix3x3 mtrx2 = ... ; // evaluate the trace of mtrx1: const double trace1 = Gaudi::Math::trace ( mtrx1 ) ; // evaluate the trace of mtrx2: const double trace2 = Gaudi::Math::trace ( mtrx2 ) ;
m | (input) matrix to be studied |
Definition at line 628 of file MatrixUtils.h.
00629 { 00630 T result = m(0,0) ; 00631 for ( unsigned int i = 1 ; i < D ; ++i ) { result += m(i,i) ; } 00632 return result ; 00633 }
T Gaudi::Math::min_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m, | |
CMP | cmp | |||
) | [inline] |
find the minimal diagonal element
m | (input) matrix to be studied | |
cmp | comparison criteria |
Definition at line 643 of file MatrixUtils.h.
00644 { 00645 T result = m(0,0); 00646 for ( unsigned int i = 1 ; i < D ; ++i ) 00647 { 00648 const T value = m(i,i) ; 00649 if ( cmp ( value , result ) ) { result = value ; } 00650 } 00651 return result ; 00652 }
T Gaudi::Math::max_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m, | |
CMP | cmp | |||
) | [inline] |
find the maximal diagonal element
m | (input) square matrix to be studied | |
cmp | comparison criteria |
Definition at line 662 of file MatrixUtils.h.
00663 { 00664 T result = m(0,0); 00665 for ( unsigned int i = 1 ; i < D ; ++i ) 00666 { 00667 const T value = m(i,i) ; 00668 if ( cmp ( result , value ) ) { result = value ; } 00669 } 00670 return result ; 00671 }
T Gaudi::Math::max_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m | ) | [inline] |
find the maximal diagonal element of square matrix
const Gaudi::Matrix4x4 mtrx1 = ... ; const Gaudi::SymMatrix3x3 mtrx2 = ... ; // find the maximal diagonal element of mtrx1 const double m1 = Gaudi::Math::max_diagonal ( mtrx1 ) ; // find the maximal diagonal element of mtrx2 const double m2 = Gaudi::Math::max_diagonal ( mtrx2 ) ;
m | (input) square matrix to be studied |
Definition at line 696 of file MatrixUtils.h.
00697 { return max_diagonal( m , std::less<T>() ) ; } ;
T Gaudi::Math::min_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m | ) | [inline] |
find the maximal diagonal element of the square matrix
const LHCb::Vertex* v = .. const Gaudi::Matrix3x3& covariance = v->covMatrix() ; // find the minimal diagonal element of covariance matrix: const double m1 = Gaudi::Math::min_diagonal ( covariance ) ; if ( 0 >= 0 ) { std::err << " Invlid covarinace matrix" << " Non-positive elements on diagonal << m1 << std::endl ; }
m | (input) square matrix to be studied |
Definition at line 726 of file MatrixUtils.h.
00727 { return min_diagonal( m , std::less<T>() ) ; } ;
T Gaudi::Math::maxabs_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m | ) | [inline] |
find the diagonal element of square matrix with maximal absolute value
const Gaudi::Matrix4x4 mtrx1 = ... ; const Gaudi::SymMatrix3x3 mtrx2 = ... ; // find the diagonal element of mtrx1 with the maximal absolute value const double m1 = Gaudi::Math::max_diagonal ( mtrx1 ) ; // find the diagonal element of mtrx1 with the maximal absolute value const double m2 = Gaudi::Math::max_diagonal ( mtrx2 ) ;
m | (input) square matrix to be studied |
Definition at line 752 of file MatrixUtils.h.
00753 { return max_diagonal( m , _AbsCompare<T>() ) ; } ;
T Gaudi::Math::minabs_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m | ) | [inline] |
find the diagonal element of the square matrix with the minimal absolute value
const LHCb::Vertex* v = .. const Gaudi::Matrix3x3& covariance = v->covMatrix() ; // find the diagonal element with minimal absolute value const double m1 = Gaudi::Math::min_diagonal ( covariance ) ; if ( 0.001 * Gaudi::Units::micrometer ) { std::err << " Non-realistic element on diagonal << m1 << std::endl ; }
m | (input) square matrix to be studied |
Definition at line 782 of file MatrixUtils.h.
00783 { return min_diagonal( m , _AbsCompare<T>() ) ; } ;
size_t Gaudi::Math::count_if | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m, | |
P | pred | |||
) | [inline] |
count the number of elements in matrix, which satisfy the certain criteria
const Gaudi::Matrix4x4 matrix = ... ; // number of NULL elements: const size_t nulls = Gaudi::Math::count_if ( matrix , std::bind2nd( std::equal_to<double>() , 0.0 ) ) ; // number of elements in excess of 100.0 const size_t large = Gaudi::Math::count_if ( matrix , std::bind2nd( std::greater<double>() , 100.0 ) ) ; // number of elements which are less then 0.01 in absolute value const size_t small = Gaudi::Math::count_if ( matrix , std::bind2nd( _AbsCompare<double>() , 0.01 ) ) ;
m | (input) matrix to be studied | |
pred | (input) predicate to be tested |
Definition at line 818 of file MatrixUtils.h.
00819 { return std::count_if ( m.begin() , m.end() , pred ) ; }
size_t Gaudi::Math::count_if | ( | const ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > & | m, | |
P | pred | |||
) | [inline] |
count the number of elements in matrix, which satisfy the certain criteria
const Gaudi::SymMatrix4x4 matrix = ... ; // number of NULL elements: const size_t nulls = Gaudi::Math::count_if ( matrix , std::bind2nd( std::equal_to<double>() , 0.0 ) ) ; // number of elements in excess of 100.0 const size_t large = Gaudi::Math::count_if ( matrix , std::bind2nd( std::greater<double>() , 100.0 ) ) ; // number of elements which are less then 0.01 in absolute value const size_t small = Gaudi::Math::count_if ( matrix , std::bind2nd( Gaudi::Math::_AbsCompare<double>() , 0.01 ) ) ;
If one needs check the presence of elements ("at least one") a bit more efficient algorithm Gaudi::Math::check_if
should be used
m | (input) symmetric matrix to be studied | |
pred | (input) predicate to be tested |
Definition at line 858 of file MatrixUtils.h.
00859 { 00860 size_t result = 0 ; 00861 for ( unsigned int i = 0 ; i < D ; ++i ) 00862 { 00863 if ( pred ( m ( i , i ) ) ) { result += 1 ; } 00864 for ( unsigned int j = i + 1 ; j < D ; ++j ) 00865 { 00866 if ( pred ( m ( i , j ) ) ) { result +=2 ; } // ATTENTION! 00867 } 00868 } 00869 return result ; 00870 }
size_t Gaudi::Math::count_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m, | |
P | pred | |||
) | [inline] |
count number of diagonal elements in matrix, which satisfy certain criteria
const LHCb::Vertex* v = ... ; const Gaudi::SymMatrix3x3& covariance = v->covMatrix() ; // count number of VERY small (and negative) diagonal elements: const size_t bad = Gaudi::Math::cound_diagonal( covariance , std::bind2nd( std::less<double>() , 0.01 * Gaudi::Units::micrometer ) ; if ( 0 != bad ) { std::cerr << " #bad diagonal elements is " << bad << std::endl ; }
m | (input) square matrix to be studied | |
pred | (input) predicate to be tested |
Definition at line 900 of file MatrixUtils.h.
00901 { 00902 size_t result = 0 ; 00903 for ( unsigned int i = 0 ; i < D ; ++i ) 00904 { if ( pred ( m ( i , i ) ) ) { result += 1 ; } } 00905 return result ; 00906 }
bool Gaudi::Math::check_if | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m, | |
P | pred | |||
) | [inline] |
check the presence of at least one element which satisfy the criteria
const LHCb::Vertex* v = ... ; const Gaudi::SymMatrix3x3& covariance = v->covMatrix() ; // check for "infinities" const bool bad = Gaudi::Math::check_if( covariance , std::bind2nd( std::greater<double>() , 1 * Gaudi::Units::meter ) ; if ( bad ) { std::cerr << " bad elements are detected " << std::endl ; }
In general this algorithm is faster than Gaudi::Math::count_if
m | (input) matrix to be checked | |
pred | (input) predicate tobe tested |
Definition at line 940 of file MatrixUtils.h.
bool Gaudi::Math::check_diagonal | ( | const ROOT::Math::SMatrix< T, D, D, R > & | m, | |
P | pred | |||
) | [inline] |
check the presence of at least one diagonal element which satisfy the criteria
const LHCb::Vertex* v = ... ; const Gaudi::SymMatrix3x3& covariance = v->covMatrix() ; // check for "almost nulls" const bool bad = Gaudi::Math::check_diagonal( covariance , std::bind2nd( std::less<double>() , 0.001 * Gaudi::Units::micrometer ) ; if ( bad ) { std::cerr << " bad diagonal elements are detected " << std::endl ; }
m | (input) square matrix to be checked | |
pred | (input) predicate to be tested |
Definition at line 971 of file MatrixUtils.h.
00972 { 00973 for ( unsigned int i = 0 ; i < D ; ++i ) 00974 { if ( pred ( m ( i , i ) ) ) { return true ; } } 00975 return false ; 00976 }
bool Gaudi::Math::equal_if | ( | const ROOT::Math::SMatrix< T1, D1, D2, R1 > & | m1, | |
const ROOT::Math::SMatrix< T2, D1, D2, R2 > & | m2, | |||
P | pred | |||
) | [inline] |
check the "equality" of the two matrices by checking element-by-element: true == pred( m1(i,j) , m2(i,j) )
It is an efficient way to compare the matrices in the different represenattions, e.g. symmetrical and non symmetrical matrices of the same size. Also the "tolerance" coudl be introduced for equality
const Gaudi::Matrix4x4 m1 = ... ; const Gaudi::SymMatrix4x4 m2 = ... ; // comparison criteria: struct Equal : publuc std::binary_fuction<double,double,bool> { Equal ( const double value ) : m_threshold ( value ) {} ; bool operator() ( const double v1 , const double v2 ) const { return ::fabs( v1 , v2 ) < m_threshold ; } private: double m_threshold ; } ; // "compare" the matrices const bool eq = Gaudi::Math::equal_if ( m1 , m2 , Equal(0.001) ) ;
m1 | (input) the first matrix to be checked | |
m2 | (input) the second matrix to be checked | |
pred | (input) predicate to be tested |
Definition at line 1020 of file MatrixUtils.h.
01022 { 01023 for ( unsigned int i = 0 ; i < D1 ; ++i ) 01024 { 01025 for ( unsigned int j = 0 ; j < D2 ; ++j ) 01026 { 01027 if ( !pred( m1(i,j) , m2(i,j) ) ) { return false ; } // RETURN 01028 } 01029 } 01030 return true ; 01031 }
bool Gaudi::Math::equal_if | ( | const ROOT::Math::SMatrix< T, D1, D2, R > & | m1, | |
const ROOT::Math::SMatrix< T, D1, D2, R > & | m2, | |||
P | pred | |||
) | [inline] |
check the "equality" of the two matrices by checking element-by-element: true == pred( m1(i,j) , m2(i,j) )
The specialization for matrices of the same representation. From the first principles it should be much more efficient.
const Gaudi::Matrix4x4 m1 = ... ; const Gaudi::Matrix4x4 m2 = ... ; // comparison criteria: struct Equal : publuc std::binary_fuction<double,double,bool> { Equal ( const double value ) : m_threshold ( value ) {} ; bool operator() ( const double v1 , const double v2 ) const { return ::fabs( v1 , v2 ) < m_threshold ; } private: double m_threshold ; } ; // "compare" the matrices const bool eq = Gaudi::Math::equal_if ( m1 , m2 , Equal(0.001) ) ;
m1 | (input) the first matrix to be checked | |
m2 | (input) the second matrix to be checked | |
pred | (input) predicate to be tested |
Definition at line 1071 of file MatrixUtils.h.
01073 { return std::equal ( m1.begin() , m1.end() , m2.begin() , pred ) ; }
void Gaudi::Math::update | ( | ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > & | left, | |
const ROOT::Math::SVector< T2, D > & | vect, | |||
const double | scale | |||
) |
update the symmetric matrix according to the rule m += s*v*v^T
left | the symmetric matrix to be updated | |
vect | the vector | |
scale | the scale factor |
Definition at line 1089 of file MatrixUtils.h.
01092 { 01093 for ( unsigned int i = 0 ; i < D ; ++i ) 01094 { 01095 for ( unsigned int j = i ; j < D ; ++j ) 01096 { left ( i , j ) += scale * vect(i) * vect(j) ; } 01097 } 01098 }
void Gaudi::Math::update | ( | ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > & | left, | |
const ROOT::Math::VecExpr< B, T2, D > & | vect, | |||
const double | scale | |||
) |
update the symmetric matrix according to the rule m += s*v*v^T
left | the symmetric matrix to be updated | |
vect | the vector | |
scale | the scale factor |
Definition at line 1110 of file MatrixUtils.h.
01113 { 01114 for ( unsigned int i = 0 ; i < D ; ++i ) 01115 { 01116 for ( unsigned int j = i ; j < D ; ++j ) 01117 { left ( i , j ) += scale * vect(i) * vect(j) ; } 01118 } 01119 }
void Gaudi::Math::update | ( | ROOT::Math::SMatrix< T, D1, D2, R > & | left, | |
const ROOT::Math::SVector< T2, D1 > & | vct1, | |||
const ROOT::Math::SVector< T3, D2 > & | vct2, | |||
const double | scale = 1.0 | |||
) |
update the matrix according to the rule m += s*v1*v2^T
left | the matrix to be updated | |
vct1 | the first vector | |
vct2 | the second vector | |
scale | the scale factor |
Definition at line 1132 of file MatrixUtils.h.
01136 { 01137 for ( unsigned int i = 0 ; i < D1 ; ++i ) 01138 { 01139 for ( unsigned int j = 0 ; j < D2 ; ++j ) 01140 { left ( i , j ) += scale * vct1(i) * vct2(j) ; } 01141 } 01142 }
T Gaudi::Math::mult | ( | const ROOT::Math::SVector< T1, D1 > & | vct1, | |
const ROOT::Math::SMatrix< T, D1, D2, R > & | mtrx, | |||
const ROOT::Math::SVector< T2, D2 > & | vct2 | |||
) |
useful shortcut for product of vector, matrix and vector (v1^T*M*v2)
vct1 | the first vector | |
mtrx | the matrix | |
vct2 | the second vector |
Definition at line 1154 of file MatrixUtils.h.
void Gaudi::Math::update | ( | ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > & | left, | |
const ROOT::Math::SMatrix< T2, D, D, R > & | right, | |||
const double | scale = 1.0 | |||
) |
update the symmetric matrix according to the rule m += scale * ( m + m^T )
left | the matrix to be updated | |
right | the matrix to be "symmetrized" | |
scale | the scale factor to be applied |
Definition at line 1171 of file MatrixUtils.h.
01174 { 01175 for ( unsigned int i = 0 ; i < D ; ++i ) 01176 { 01177 for ( unsigned int j = i ; j < D ; ++j ) 01178 { left ( i , j ) += scale * ( right ( i , j ) + right ( j , i ) ) ; } 01179 } 01180 }
void Gaudi::Math::update | ( | ROOT::Math::SMatrix< T, D, D, ROOT::Math::MatRepSym< T, D > > & | left, | |
const ROOT::Math::Expr< B, T2, D, D, R > & | right, | |||
const double | scale = 1.0 | |||
) |
update the symmetric matrix according to the rule m += scale * ( m + m^T )
left | the matrix to be updated | |
right | the matrix to be "symmetrized" | |
scale | the scale factor to be applied |
Definition at line 1192 of file MatrixUtils.h.
01195 { 01196 for ( unsigned int i = 0 ; i < D ; ++i ) 01197 { 01198 for ( unsigned int j = i ; j < D ; ++j ) 01199 { left ( i , j ) += scale * ( right ( i , j ) + right ( j , i ) ) ; } 01200 } 01201 }
TYPE Gaudi::Math::pow | ( | TYPE | __x, | |
unsigned long | __n | |||
) | [inline] |
Simple utility for efficient "pow".
It works only for positive integer powers.
const double result = Gaudi::Math::pow ( value , 10 ) ;
The actual code is copied from std::__cmath_power bits/cmath.tcc
Definition at line 41 of file Power.h.
00042 { 00043 TYPE __y = __n % 2 ? __x : 1; 00044 00045 while ( __n >>= 1 ) 00046 { 00047 __x = __x * __x; 00048 if ( __n % 2) { __y = __y * __x; } 00049 } 00050 00051 return __y ; 00052 }
unsigned int Gaudi::Math::intersectionLineSphere | ( | const aLine & | line, | |
const double | radius2, | |||
ITERATOR | out | |||
) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with sphere of radius sqrt(radius)
line | line satisfying line.beginPoint() + scalar*line.direction() | |
radius2 | sphere radius squared | |
out | output iterator |
unsigned int Gaudi::Math::intersectionLineCylinder | ( | const aLine & | line, | |
const double | radius2, | |||
ITERATOR | out | |||
) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with cylinder of radius sqrt(radius)
line | line satisfying line.beginPoint() + scalar*line.direction() | |
radius2 | cylinder radius squared | |
out | output iterator |
unsigned int Gaudi::Math::intersectionLinePlaneX | ( | const aLine & | line, | |
const double | X, | |||
ITERATOR | out | |||
) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with plane x=X
line | line satisfying line.beginPoint() + scalar*line.direction() | |
X | x-parameter | |
out | output iterator |
unsigned int Gaudi::Math::intersectionLinePlaneY | ( | const aLine & | line, | |
const double | Y, | |||
ITERATOR | out | |||
) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with plane y=Y
line | line satisfying line.beginPoint() + scalar*line.direction() | |
Y | y-parameter | |
out | output iterator |
unsigned int Gaudi::Math::intersectionLinePlaneZ | ( | const aLine & | line, | |
const double | Z, | |||
ITERATOR | out | |||
) |
find intersection ticks for the line parametrized as beginPoint + direction() * Tick with plane z=Z
line | line satisfying line.beginPoint() + scalar*line.direction() | |
Z | z-parameter | |
out | output iterator |
unsigned int Gaudi::Math::intersectionLinePlanePhi | ( | const aLine & | line, | |
const double | Phi, | |||
ITERATOR | out | |||
) |
find intersection ticks for the line parametrized beginPoint + direction() * Tick with half-plane phi=Phi
line | line satisfying line.beginPoint() + scalar*line.direction() | |
Phi | phi-parameter | |
out | output iterator |
unsigned int Gaudi::Math::intersectionLineCone | ( | const aLine & | line, | |
const double | Theta, | |||
ITERATOR | out | |||
) |
find intersection ticks for the line parametrized beginPoint + direction() * Tick with cone theta=Theta
line | line satisfying line.beginPoint() + scalar*line.direction() | |
Theta | Theta-parameter | |
out | output iterator |