The results are compared and check at the numerical precision levels. Some small discrepancy can appear when the macro is executed on different architectures where it has been calibrated (Power PC G5) The macro is divided in 4 parts:
************************************************************************
Vector 3D Test
************************************************************************
Test Cartesian-Polar : ........ OK
Test Cartesian-CylindricalEta : ........ OK
Test Cartesian-Cylindrical : ........ OK
Test Operations : ............. OK
Test Setters : ...... OK
Test Linear Algebra conversion: . OK
************************************************************************
Point 3D Tests
************************************************************************
Test Cartesian-Polar : ........ OK
Test Polar-CylindricalEta : ........ OK
Test operations : ..... OK
************************************************************************
Lorentz Vector Tests
************************************************************************
Test XYZT - PtEtaPhiE Vectors: .......... OK
Test XYZT - PtEtaPhiM Vectors: .......... OK
Test PtEtaPhiE - PxPyPzM Vect.: .......... OK
Test operations : ............ OK
Test Setters : ........ OK
************************************************************************
Utility Function Tests
************************************************************************
Test Vector utility functions : .... OK
Test Point utility functions : .... OK
LorentzVector utility funct.: ... OK
************************************************************************
Rotation and Transformation Tests
************************************************************************
Test Vector Rotations : ............... OK
Test Axial Rotations : ............... OK
Test Rotations by a PI angle : ....... OK
Test Inversions : ............... OK
Test rectify : . OK
Test Transform3D : .............. OK
Test Plane3D : ........ OK
Test LorentzRotation : .......... OK
Test Boost : ............. OK
Number of tests 224 failed = 0
int ok = 0;
int compare(
double v1,
double v2,
const char*
name,
double Scale = 1.0) {
double eps = Scale* 2.22044604925031308e-16;
if (delta < 0 ) delta = - delta;
if (
v1 == 0 ||
v2 == 0) {
if (delta > eps ) {
}
}
else {
if ( delta/
d > eps && delta > eps )
}
std::cout << ".";
else {
int pr = std::cout.precision (18);
else
std::cout <<
"\nDiscrepancy in " <<
name <<
"() : " <<
v1 <<
" != " <<
v2 <<
" discr = " <<
discr
<< " (Allowed discrepancy is " << eps << ")\n";
std::cout.precision (
pr);
}
}
std::cout << "\n************************************************************************\n "
<< " Vector 3D Test"
<< "\n************************************************************************\n";
std::cout << "Test Cartesian-Polar : " ;
ok = 0;
ok+= compare(
v1.X(),
v2.X(),
"x");
ok+= compare(
v1.Y(),
v2.Y(),
"y");
ok+= compare(
v1.Z(),
v2.Z(),
"z");
ok+= compare(
v1.Phi(),
v2.Phi(),
"phi");
ok+= compare(
v1.Theta(),
v2.Theta(),
"theta");
ok+= compare(
v1.R(),
v2.R(),
"r");
ok+= compare(
v1.Eta(),
v2.Eta(),
"eta");
ok+= compare(
v1.Rho(),
v2.Rho(),
"rho");
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test Cartesian-CylindricalEta : ";
ok = 0;
ok+= compare(
v1.X(),
v3.X(),
"x");
ok+= compare(
v1.Y(),
v3.Y(),
"y");
ok+= compare(
v1.Z(),
v3.Z(),
"z");
ok+= compare(
v1.Phi(),
v3.Phi(),
"phi");
ok+= compare(
v1.Theta(),
v3.Theta(),
"theta");
ok+= compare(
v1.R(),
v3.R(),
"r");
ok+= compare(
v1.Eta(),
v3.Eta(),
"eta");
ok+= compare(
v1.Rho(),
v3.Rho(),
"rho");
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test Cartesian-Cylindrical : ";
ok = 0;
ok+= compare(
v1.X(),
v4.X(),
"x");
ok+= compare(
v1.Y(),
v4.Y(),
"y");
ok+= compare(
v1.Z(),
v4.Z(),
"z");
ok+= compare(
v1.Phi(),
v4.Phi(),
"phi");
ok+= compare(
v1.Theta(),
v4.Theta(),
"theta");
ok+= compare(
v1.R(),
v4.R(),
"r");
ok+= compare(
v1.Eta(),
v4.Eta(),
"eta");
ok+= compare(
v1.Rho(),
v4.Rho(),
"rho");
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test Operations : " ;
ok = 0;
ok+= compare(
Dot,
v1.Mag2(),
"dot" );
ok+= compare(
vcross.R(), 0,
"cross" );
ok+= compare(
v2.Phi(),
vu.Phi(),
"unit Phi");
ok+= compare(
v2.Theta(),
vu.Theta(),
"unit Theta");
ok+= compare(1.0,
vu.R(),
"unit ");
ok+= compare(
q4.X(),
q1.X(),
"op X" );
ok+= compare(
q4.Y(),
q1.Y(),
"op Y" );
ok+= compare(
q4.Z(),
q1.Z(),
"op Z" );
ok+= compare(
w1 ==
v1,
static_cast<double>(
true),
"== XYZ");
ok+= compare(
w2 ==
v2,
static_cast<double>(
true),
"== Polar");
ok+= compare(
w3 ==
v3,
static_cast<double>(
true),
"== RhoEtaPhi");
ok+= compare(
w4 ==
v4,
static_cast<double>(
true),
"== RhoZPhi");
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test Setters : " ;
ok+= compare(
q2.X(),
q1.X(),
"setXYZ X" );
ok+= compare(
q2.Y(),
q1.Y(),
"setXYZ Y" );
ok+= compare(
q2.Z(),
q1.Z(),
"setXYZ Z" );
q2.SetCoordinates( 2.0*
q1.Rho(),
q1.Eta(),
q1.Phi() );
ok+= compare(
q2.X(),
q1s.X(),
"set X" );
ok+= compare(
q2.Y(),
q1s.Y(),
"set Y" );
ok+= compare(
q2.Z(),
q1s.Z(),
"set Z" );
if (ok == 0) std::cout << "\t\t OK " << std::endl;
std::cout << "Test Linear Algebra conversion: " ;
vxyz1.Coordinates().GetCoordinates(
vla1.GetMatrixArray() );
ok = 0;
if (ok == 0) std::cout << "\t\t OK " << std::endl;
return ok;
}
std::cout << "\n************************************************************************\n "
<< " Point 3D Tests"
<< "\n************************************************************************\n";
std::cout << "Test Cartesian-Polar : ";
ok = 0;
ok+= compare(
p1.x(),
p2.X(),
"x");
ok+= compare(
p1.y(),
p2.Y(),
"y");
ok+= compare(
p1.z(),
p2.Z(),
"z");
ok+= compare(
p1.phi(),
p2.Phi(),
"phi");
ok+= compare(
p1.theta(),
p2.Theta(),
"theta");
ok+= compare(
p1.r(),
p2.R(),
"r");
ok+= compare(
p1.eta(),
p2.Eta(),
"eta");
ok+= compare(
p1.rho(),
p2.Rho(),
"rho");
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test Polar-CylindricalEta : ";
ok = 0;
ok+= compare(
p2.X(),
p3.X(),
"x");
ok+= compare(
p2.Y(),
p3.Y(),
"y");
ok+= compare(
p2.Z(),
p3.Z(),
"z",3);
ok+= compare(
p2.Phi(),
p3.Phi(),
"phi");
ok+= compare(
p2.Theta(),
p3.Theta(),
"theta");
ok+= compare(
p2.R(),
p3.R(),
"r");
ok+= compare(
p2.Eta(),
p3.Eta(),
"eta");
ok+= compare(
p2.Rho(),
p3.Rho(),
"rho");
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test operations : ";
ok+= compare(
Dot, 0.0,
"dot", 10 );
ok+= compare(
vcross.R(),
p1.R(),
"cross mag" );
ok+= compare(
p1 ==
pscale2,
static_cast<double>(
true),
"== Point");
q1.SetCoordinates(
p1.Rho(),2.0,
p1.Phi() );
if (ok == 0) std::cout << "\t OK " << std::endl;
return ok;
}
std::cout << "\n************************************************************************\n "
<< " Lorentz Vector Tests"
<< "\n************************************************************************\n";
std::cout << "Test XYZT - PtEtaPhiE Vectors: ";
ok = 0;
ok+= compare(
v1.Px(),
v2.X(),
"x");
ok+= compare(
v1.Py(),
v2.Y(),
"y");
ok+= compare(
v1.Pz(),
v2.Z(),
"z", 2);
ok+= compare(
v1.E(),
v2.T(),
"e");
ok+= compare(
v1.Phi(),
v2.Phi(),
"phi");
ok+= compare(
v1.Theta(),
v2.Theta(),
"theta");
ok+= compare(
v1.Pt(),
v2.Pt(),
"pt");
ok+= compare(
v1.M(),
v2.M(),
"mass", 5);
ok+= compare(
v1.Et(),
v2.Et(),
"et");
ok+= compare(
v1.Mt(),
v2.Mt(),
"mt", 3);
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test XYZT - PtEtaPhiM Vectors: ";
ok = 0;
ok+= compare(
v1.Px(),
v3.X(),
"x");
ok+= compare(
v1.Py(),
v3.Y(),
"y");
ok+= compare(
v1.Pz(),
v3.Z(),
"z", 2);
ok+= compare(
v1.E(),
v3.T(),
"e");
ok+= compare(
v1.Phi(),
v3.Phi(),
"phi");
ok+= compare(
v1.Theta(),
v3.Theta(),
"theta");
ok+= compare(
v1.Pt(),
v3.Pt(),
"pt");
ok+= compare(
v1.M(),
v3.M(),
"mass", 5);
ok+= compare(
v1.Et(),
v3.Et(),
"et");
ok+= compare(
v1.Mt(),
v3.Mt(),
"mt", 3);
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test PtEtaPhiE - PxPyPzM Vect.: ";
ok = 0;
ok+= compare(
v4.Px(),
v3.X(),
"x");
ok+= compare(
v4.Py(),
v3.Y(),
"y");
ok+= compare(
v4.Pz(),
v3.Z(),
"z",2);
ok+= compare(
v4.E(),
v3.T(),
"e");
ok+= compare(
v4.Phi(),
v3.Phi(),
"phi");
ok+= compare(
v4.Theta(),
v3.Theta(),
"theta");
ok+= compare(
v4.Pt(),
v3.Pt(),
"pt");
ok+= compare(
v4.M(),
v3.M(),
"mass",5);
ok+= compare(
v4.Et(),
v3.Et(),
"et");
ok+= compare(
v4.Mt(),
v3.Mt(),
"mt",3);
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test operations : ";
ok = 0;
ok+= compare(
Dot,
v1.M2(),
"dot" , 10 );
ok+= compare(
q4.x(),
q1.X(),
"op X" );
ok+= compare(
q4.y(),
q1.Y(),
"op Y" );
ok+= compare(
q4.z(),
q1.Z(),
"op Z" );
ok+= compare(
q4.t(),
q1.E(),
"op E" );
ok+= compare(
w1 ==
v1,
static_cast<double>(
true),
"== PxPyPzE");
ok+= compare(
w2 ==
v2,
static_cast<double>(
true),
"== PtEtaPhiE");
ok+= compare(
w3 ==
v3,
static_cast<double>(
true),
"== PtEtaPhiM");
ok+= compare(
w4 ==
v4,
static_cast<double>(
true),
"== PxPyPzM");
ok += compare(
b.R(), beta,
"beta" );
ok += compare( gamma, 1./sqrt( 1 - beta*beta ), "gamma");
if (ok == 0) std::cout << "\t OK " << std::endl;
std::cout << "Test Setters : " ;
ok+= compare(
q2.X(),
q1.X(),
"setXYZT X" );
ok+= compare(
q2.Y(),
q1.Y(),
"setXYZT Y" );
ok+= compare(
q2.Z(),
q1.Z(),
"setXYZT Z" ,2);
ok+= compare(
q2.T(),
q1.E(),
"setXYZT E" );
q2.SetCoordinates( 2.0*
q1.Rho(),
q1.Eta(),
q1.Phi(), 2.0*
q1.E() );
ok+= compare(
q2.X(),
q1s.X(),
"set X" );
ok+= compare(
q2.Y(),
q1s.Y(),
"set Y" );
ok+= compare(
q2.Z(),
q1s.Z(),
"set Z" ,2);
ok+= compare(
q2.T(),
q1s.T(),
"set E" );
if (ok == 0) std::cout << "\t OK " << std::endl;
return ok;
}
std::cout << "\n************************************************************************\n "
<< " Utility Function Tests"
<< "\n************************************************************************\n";
std::cout << "Test Vector utility functions : ";
ok = 0;
ok += compare( VectorUtil::DeltaPhi(
v1,
v2), 1.0,
"deltaPhi Vec");
ok += compare( VectorUtil::DeltaR(
v1,
v2), sqrt(2.0),
"DeltaR Vec");
ok += compare( VectorUtil::CosTheta(
v1,
vperp), 0.0,
"costheta Vec");
if (ok == 0) std::cout << "\t\t OK " << std::endl;
std::cout << "Test Point utility functions : ";
ok = 0;
ok += compare( VectorUtil::DeltaPhi(
p1,
p2), 1.0,
"deltaPhi Point");
ok += compare( VectorUtil::DeltaR(
p1,
p2), sqrt(2.0),
"DeltaR Point");
ok += compare( VectorUtil::CosTheta(
p1,
pperp), 0.0,
"costheta Point");
if (ok == 0) std::cout << "\t\t OK " << std::endl;
std::cout << "LorentzVector utility funct.: ";
ok = 0;
ok += compare( VectorUtil::DeltaPhi(
q1,
q2), 1.0,
"deltaPhi LVec");
ok += compare( VectorUtil::DeltaR(
q1,
q2), sqrt(2.0),
"DeltaR LVec");
ok += compare( VectorUtil::InvariantMass(
q1,
q2),
qsum.M(),
"InvMass");
if (ok == 0) std::cout << "\t\t OK " << std::endl;
return ok;
}
std::cout << "\n************************************************************************\n "
<< " Rotation and Transformation Tests"
<< "\n************************************************************************\n";
std::cout << "Test Vector Rotations : ";
ok = 0;
ok+= compare(
v1.X(),
v2.X(),
"x",2);
ok+= compare(
v1.Y(),
v2.Y(),
"y",2);
ok+= compare(
v1.Z(),
v2.Z(),
"z",2);
ok+= compare(
v1.X(),
v3.X(),
"x",2);
ok+= compare(
v1.Y(),
v3.Y(),
"y",2);
ok+= compare(
v1.Z(),
v3.Z(),
"z",2);
ok+= compare(
v1.X(),
v4.X(),
"x",5);
ok+= compare(
v1.Y(),
v4.Y(),
"y",5);
ok+= compare(
v1.Z(),
v4.Z(),
"z",5);
ok+= compare(
v1.X(), v5.X(),
"x",2);
ok+= compare(
v1.Y(), v5.Y(),
"y",2);
ok+= compare(
v1.Z(), v5.Z(),
"z",2);
v6.SetCoordinates(
q2.GetMatrixArray() );
ok+= compare(
v1.X(),
v6.X(),
"x");
ok+= compare(
v1.Y(),
v6.Y(),
"y");
ok+= compare(
v1.Z(),
v6.Z(),
"z");
if (ok == 0) std::cout << "\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test Axial Rotations : ";
ok = 0;
ok+= compare(
vinv1.X(),
v.X(),
"x",2);
ok+= compare(
vinv1.Y(),
v.Y(),
"y");
ok+= compare(
vinv1.Z(),
v.Z(),
"z");
if (ok == 0) std::cout << "\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test Rotations by a PI angle : ";
ok = 0;
double b[4] = { 6,8,10,3.14159265358979323 };
ok+= compare(
arPi.Axis().X(),
a1.Axis().X(),
"x");
ok+= compare(
arPi.Axis().Y(),
a1.Axis().Y(),
"y");
ok+= compare(
arPi.Axis().Z(),
a1.Axis().Z(),
"z");
ok+= compare(
arPi.Angle(),
a1.Angle(),
"angle");
ok+= compare(
ePi.Phi(),
e1.Phi(),
"phi");
ok+= compare(
ePi.Theta(),
e1.Theta(),
"theta");
ok+= compare(
ePi.Psi(),
e1.Psi(),
"ps1");
if (ok == 0) std::cout << "\t\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test Inversions : ";
ok = 0;
ok+= compare(
p.X(),
v.X(),
"x",10);
ok+= compare(
p.Y(),
v.Y(),
"y",10);
ok+= compare(
p.Z(),
v.Z(),
"z",10);
ok+= compare(
p.X(),
v.X(),
"x",10);
ok+= compare(
p.Y(),
v.Y(),
"y",10);
ok+= compare(
p.Z(),
v.Z(),
"z",10);
ok+= compare(
p.X(),
v.X(),
"x",1
E9);
ok+= compare(
p.Y(),
v.Y(),
"y",1
E9);
ok+= compare(
p.Z(),
v.Z(),
"z",1
E9);
ok+= compare(
p.X(),
v.X(),
"x",10);
ok+= compare(
p.Y(),
v.Y(),
"y",10);
ok+= compare(
p.Z(),
v.Z(),
"z",10);
ok+= compare(
p.X(),
v.X(),
"x",10);
ok+= compare(
p.Y(),
v.Y(),
"y",10);
ok+= compare(
p.Z(),
v.Z(),
"z",10);
if (ok == 0) std::cout << "\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test rectify : ";
ok = 0;
ok+= compare(
v.R(),
vrr.R(),
"R",1.E9);
if (ok == 0) std::cout << "\t\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test Transform3D : ";
ok = 0;
ok+= compare(
pd.X(),
vd.X(),
"x");
ok+= compare(
pd.Y(),
vd.Y(),
"y");
ok+= compare(
pd.Z(),
vd.Z(),
"z");
ok+= compare(
pd.X(),
qt(0),
"x");
ok+= compare(
pd.Y(),
qt(1),
"y");
ok+= compare(
pd.Z(),
qt(2),
"z");
ok+= compare(
p.X(),
v.X(),
"x",10);
ok+= compare(
p.Y(),
v.Y(),
"y",10);
ok+= compare(
p.Z(),
v.Z(),
"z",10);
ok+= compare(
p.X(),
v.X(),
"x",10);
ok+= compare(
p.Y(),
v.Y(),
"y",10);
ok+= compare(
p.Z(),
v.Z(),
"z",10);
ok+= compare(
tc ==
tb*
ta,
static_cast<double>(
true),
"== Rot*Tra");
ok+= compare(
td ==
ta*
tb,
static_cast<double>(
true),
"== Rot*Tra");
if (ok == 0) std::cout << "\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test Plane3D : ";
ok = 0;
ok+= compare(
n.Dot(
p2-
p1), 0.0,
"n.v12",10);
ok+= compare(
n.Dot(
p3-
p1), 0.0,
"n.v13",10);
ok+= compare(
n.Dot(
p3-
p2), 0.0,
"n.v23",10);
ok+= compare(
n1.X(),
n2.X(),
"a",10);
ok+= compare(
n1.Y(),
n2.Y(),
"b",10);
ok+= compare(
n1.Z(),
n2.Z(),
"c",10);
ok+= compare(
plane1.HesseDistance(),
plane2.HesseDistance(),
"d",10);
ok += compare(
plane1.Distance(
pt1), 0.0,
"distance",10);
if (ok == 0) std::cout << "\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test LorentzRotation : ";
ok = 0;
ok+= compare(
lv1==
lv2,
true,
"V0==V2");
ok+= compare(
lv1==
lv2,
true,
"V1==V2");
ok+= compare(
lv1.X(),
qlr(0),
"x");
ok+= compare(
lv1.Y(),
qlr(1),
"y");
ok+= compare(
lv1.Z(),
qlr(2),
"z");
ok+= compare(
lv1.E(),
qlr(3),
"t");
ok+= compare(
lv0.X(),
lv.X(),
"x");
ok+= compare(
lv0.Y(),
lv.Y(),
"y");
ok+= compare(
lv0.Z(),
lv.Z(),
"z");
ok+= compare(
lv0.E(),
lv.E(),
"t");
if (ok == 0) std::cout << "\t OK " << std::endl;
else std::cout << std::endl;
std::cout << "Test Boost : ";
ok = 0;
ok+= compare(
lvb.X(),
lvb2.X(),
"x");
ok+= compare(
lvb.Y(),
lvb2.Y(),
"y");
ok+= compare(
lvb.Z(),
lvb2.Z(),
"z");
ok+= compare(
lvb.E(),
lvb2.E(),
"t");
ok+= compare(
lvb.M(),
lv.M(),
"m",50);
ok+= compare(
lv0.X(),
lv.X(),
"x",5);
ok+= compare(
lv0.Y(),
lv.Y(),
"y",5);
ok+= compare(
lv0.Z(),
lv.Z(),
"z",3);
ok+= compare(
lv0.E(),
lv.E(),
"t",3);
ok+= compare(
lvr.X(), 0.0,
"x",10);
ok+= compare(
lvr.Y(), 0.0,
"y",10);
ok+= compare(
lvr.Z(), 0.0,
"z",10);
ok+= compare(
lvr.M(),
lv.M(),
"m",10);
if (ok == 0) std::cout << "\t OK " << std::endl;
else std::cout << std::endl;
return ok;
}
std::cout <<
"\n\nNumber of tests " <<
ntest <<
" failed = " <<
nfail << std::endl;
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
AxisAngle class describing rotation represented with direction axis (3D Vector) and an angle of rotat...
Lorentz boost class with the (4D) transformation represented internally by a 4x4 orthosymplectic matr...
EulerAngles class describing rotation as three angles (Euler Angles).
Class describing a geometrical plane in 3 dimensions.
Lorentz transformation class with the (4D) transformation represented by a 4x4 orthosymplectic matrix...
Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Rotation class with the (3D) rotation represented by angles describing first a rotation of an angle p...
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
double beta(double x, double y)
Calculates the beta function.
constexpr Double_t PiOver2()