56int compare(
double v1,
double v2,
const char*
name,
double Scale = 1.0) {
60 double eps = Scale* 2.22044604925031308e-16;
62 double delta =
v2 -
v1;
64 if (delta < 0 ) delta = - delta;
65 if (
v1 == 0 ||
v2 == 0) {
76 if ( delta/
d > eps && delta > eps )
83 int pr = std::cout.precision (18);
90 std::cout <<
"\nDiscrepancy in " <<
name <<
"() : " <<
v1 <<
" != " <<
v2 <<
" discr = " <<
discr
91 <<
" (Allowed discrepancy is " << eps <<
")\n";
92 std::cout.precision (
pr);
99 std::cout <<
"\n************************************************************************\n "
101 <<
"\n************************************************************************\n";
105 std::cout <<
"Test Cartesian-Polar : " ;
110 ok+= compare(
v1.X(),
v2.X(),
"x");
111 ok+= compare(
v1.Y(),
v2.Y(),
"y");
112 ok+= compare(
v1.Z(),
v2.Z(),
"z");
113 ok+= compare(
v1.Phi(),
v2.Phi(),
"phi");
114 ok+= compare(
v1.Theta(),
v2.Theta(),
"theta");
115 ok+= compare(
v1.R(),
v2.R(),
"r");
116 ok+= compare(
v1.Eta(),
v2.Eta(),
"eta");
117 ok+= compare(
v1.Rho(),
v2.Rho(),
"rho");
119 if (ok == 0) std::cout <<
"\t OK " << std::endl;
121 std::cout <<
"Test Cartesian-CylindricalEta : ";
126 ok+= compare(
v1.X(),
v3.X(),
"x");
127 ok+= compare(
v1.Y(),
v3.Y(),
"y");
128 ok+= compare(
v1.Z(),
v3.Z(),
"z");
129 ok+= compare(
v1.Phi(),
v3.Phi(),
"phi");
130 ok+= compare(
v1.Theta(),
v3.Theta(),
"theta");
131 ok+= compare(
v1.R(),
v3.R(),
"r");
132 ok+= compare(
v1.Eta(),
v3.Eta(),
"eta");
133 ok+= compare(
v1.Rho(),
v3.Rho(),
"rho");
135 if (ok == 0) std::cout <<
"\t OK " << std::endl;
137 std::cout <<
"Test Cartesian-Cylindrical : ";
142 ok+= compare(
v1.X(),
v4.X(),
"x");
143 ok+= compare(
v1.Y(),
v4.Y(),
"y");
144 ok+= compare(
v1.Z(),
v4.Z(),
"z");
145 ok+= compare(
v1.Phi(),
v4.Phi(),
"phi");
146 ok+= compare(
v1.Theta(),
v4.Theta(),
"theta");
147 ok+= compare(
v1.R(),
v4.R(),
"r");
148 ok+= compare(
v1.Eta(),
v4.Eta(),
"eta");
149 ok+= compare(
v1.Rho(),
v4.Rho(),
"rho");
151 if (ok == 0) std::cout <<
"\t OK " << std::endl;
153 std::cout <<
"Test Operations : " ;
157 ok+= compare(
Dot,
v1.Mag2(),
"dot" );
159 ok+= compare(
vcross.R(), 0,
"cross" );
163 ok+= compare(
v1.R(),
vscale2.R(),
"scale");
166 ok+= compare(
v2.Phi(),
vu.Phi(),
"unit Phi");
167 ok+= compare(
v2.Theta(),
vu.Theta(),
"unit Theta");
168 ok+= compare(1.0,
vu.R(),
"unit ");
176 ok+= compare(
q4.X(),
q1.X(),
"op X" );
177 ok+= compare(
q4.Y(),
q1.Y(),
"op Y" );
178 ok+= compare(
q4.Z(),
q1.Z(),
"op Z" );
185 ok+= compare(
w1 ==
v1,
static_cast<double>(
true),
"== XYZ");
186 ok+= compare(
w2 ==
v2,
static_cast<double>(
true),
"== Polar");
187 ok+= compare(
w3 ==
v3,
static_cast<double>(
true),
"== RhoEtaPhi");
188 ok+= compare(
w4 ==
v4,
static_cast<double>(
true),
"== RhoZPhi");
190 if (ok == 0) std::cout <<
"\t OK " << std::endl;
193 std::cout <<
"Test Setters : " ;
197 ok+= compare(
q2.X(),
q1.X(),
"setXYZ X" );
198 ok+= compare(
q2.Y(),
q1.Y(),
"setXYZ Y" );
199 ok+= compare(
q2.Z(),
q1.Z(),
"setXYZ Z" );
201 q2.SetCoordinates( 2.0*
q1.Rho(),
q1.Eta(),
q1.Phi() );
203 ok+= compare(
q2.X(),
q1s.X(),
"set X" );
204 ok+= compare(
q2.Y(),
q1s.Y(),
"set Y" );
205 ok+= compare(
q2.Z(),
q1s.Z(),
"set Z" );
207 if (ok == 0) std::cout <<
"\t\t OK " << std::endl;
209 std::cout <<
"Test Linear Algebra conversion: " ;
214 vxyz1.Coordinates().GetCoordinates(
vla1.GetMatrixArray() );
227 if (ok == 0) std::cout <<
"\t\t OK " << std::endl;
233 std::cout <<
"\n************************************************************************\n "
235 <<
"\n************************************************************************\n";
239 std::cout <<
"Test Cartesian-Polar : ";
244 ok+= compare(
p1.x(),
p2.X(),
"x");
245 ok+= compare(
p1.y(),
p2.Y(),
"y");
246 ok+= compare(
p1.z(),
p2.Z(),
"z");
247 ok+= compare(
p1.phi(),
p2.Phi(),
"phi");
248 ok+= compare(
p1.theta(),
p2.Theta(),
"theta");
249 ok+= compare(
p1.r(),
p2.R(),
"r");
250 ok+= compare(
p1.eta(),
p2.Eta(),
"eta");
251 ok+= compare(
p1.rho(),
p2.Rho(),
"rho");
253 if (ok == 0) std::cout <<
"\t OK " << std::endl;
255 std::cout <<
"Test Polar-CylindricalEta : ";
260 ok+= compare(
p2.X(),
p3.X(),
"x");
261 ok+= compare(
p2.Y(),
p3.Y(),
"y");
262 ok+= compare(
p2.Z(),
p3.Z(),
"z",3);
263 ok+= compare(
p2.Phi(),
p3.Phi(),
"phi");
264 ok+= compare(
p2.Theta(),
p3.Theta(),
"theta");
265 ok+= compare(
p2.R(),
p3.R(),
"r");
266 ok+= compare(
p2.Eta(),
p3.Eta(),
"eta");
267 ok+= compare(
p2.Rho(),
p3.Rho(),
"rho");
269 if (ok == 0) std::cout <<
"\t OK " << std::endl;
271 std::cout <<
"Test operations : ";
276 ok+= compare(
Dot, 0.0,
"dot", 10 );
279 ok+= compare(
vcross.R(),
p1.R(),
"cross mag" );
280 ok+= compare(
vcross.Dot(
vperp), 0.0,
"cross dir" );
284 ok+= compare(
p1.R(),
pscale2.R(),
"scale");
287 ok+= compare(
p1 ==
pscale2,
static_cast<double>(
true),
"== Point");
291 q1.SetCoordinates(
p1.Rho(),2.0,
p1.Phi() );
295 if (ok == 0) std::cout <<
"\t OK " << std::endl;
301 std::cout <<
"\n************************************************************************\n "
302 <<
" Lorentz Vector Tests"
303 <<
"\n************************************************************************\n";
307 std::cout <<
"Test XYZT - PtEtaPhiE Vectors: ";
312 ok+= compare(
v1.Px(),
v2.X(),
"x");
313 ok+= compare(
v1.Py(),
v2.Y(),
"y");
314 ok+= compare(
v1.Pz(),
v2.Z(),
"z", 2);
315 ok+= compare(
v1.E(),
v2.T(),
"e");
316 ok+= compare(
v1.Phi(),
v2.Phi(),
"phi");
317 ok+= compare(
v1.Theta(),
v2.Theta(),
"theta");
318 ok+= compare(
v1.Pt(),
v2.Pt(),
"pt");
319 ok+= compare(
v1.M(),
v2.M(),
"mass", 5);
320 ok+= compare(
v1.Et(),
v2.Et(),
"et");
321 ok+= compare(
v1.Mt(),
v2.Mt(),
"mt", 3);
323 if (ok == 0) std::cout <<
"\t OK " << std::endl;
325 std::cout <<
"Test XYZT - PtEtaPhiM Vectors: ";
330 ok+= compare(
v1.Px(),
v3.X(),
"x");
331 ok+= compare(
v1.Py(),
v3.Y(),
"y");
332 ok+= compare(
v1.Pz(),
v3.Z(),
"z", 2);
333 ok+= compare(
v1.E(),
v3.T(),
"e");
334 ok+= compare(
v1.Phi(),
v3.Phi(),
"phi");
335 ok+= compare(
v1.Theta(),
v3.Theta(),
"theta");
336 ok+= compare(
v1.Pt(),
v3.Pt(),
"pt");
337 ok+= compare(
v1.M(),
v3.M(),
"mass", 5);
338 ok+= compare(
v1.Et(),
v3.Et(),
"et");
339 ok+= compare(
v1.Mt(),
v3.Mt(),
"mt", 3);
341 if (ok == 0) std::cout <<
"\t OK " << std::endl;
343 std::cout <<
"Test PtEtaPhiE - PxPyPzM Vect.: ";
348 ok+= compare(
v4.Px(),
v3.X(),
"x");
349 ok+= compare(
v4.Py(),
v3.Y(),
"y");
350 ok+= compare(
v4.Pz(),
v3.Z(),
"z",2);
351 ok+= compare(
v4.E(),
v3.T(),
"e");
352 ok+= compare(
v4.Phi(),
v3.Phi(),
"phi");
353 ok+= compare(
v4.Theta(),
v3.Theta(),
"theta");
354 ok+= compare(
v4.Pt(),
v3.Pt(),
"pt");
355 ok+= compare(
v4.M(),
v3.M(),
"mass",5);
356 ok+= compare(
v4.Et(),
v3.Et(),
"et");
357 ok+= compare(
v4.Mt(),
v3.Mt(),
"mt",3);
359 if (ok == 0) std::cout <<
"\t OK " << std::endl;
361 std::cout <<
"Test operations : ";
365 ok+= compare(
Dot,
v1.M2(),
"dot" , 10 );
369 ok+= compare(
v1.M(),
vscale2.M(),
"scale");
377 ok+= compare(
q4.x(),
q1.X(),
"op X" );
378 ok+= compare(
q4.y(),
q1.Y(),
"op Y" );
379 ok+= compare(
q4.z(),
q1.Z(),
"op Z" );
380 ok+= compare(
q4.t(),
q1.E(),
"op E" );
387 ok+= compare(
w1 ==
v1,
static_cast<double>(
true),
"== PxPyPzE");
388 ok+= compare(
w2 ==
v2,
static_cast<double>(
true),
"== PtEtaPhiE");
389 ok+= compare(
w3 ==
v3,
static_cast<double>(
true),
"== PtEtaPhiM");
390 ok+= compare(
w4 ==
v4,
static_cast<double>(
true),
"== PxPyPzM");
397 ok += compare(
b.R(), beta,
"beta" );
398 ok += compare( gamma, 1./sqrt( 1 - beta*beta ),
"gamma");
400 if (ok == 0) std::cout <<
"\t OK " << std::endl;
403 std::cout <<
"Test Setters : " ;
405 q2.SetXYZT(
q1.Px(),
q1.Py(),
q1.Pz(),
q1.E() );
407 ok+= compare(
q2.X(),
q1.X(),
"setXYZT X" );
408 ok+= compare(
q2.Y(),
q1.Y(),
"setXYZT Y" );
409 ok+= compare(
q2.Z(),
q1.Z(),
"setXYZT Z" ,2);
410 ok+= compare(
q2.T(),
q1.E(),
"setXYZT E" );
412 q2.SetCoordinates( 2.0*
q1.Rho(),
q1.Eta(),
q1.Phi(), 2.0*
q1.E() );
414 ok+= compare(
q2.X(),
q1s.X(),
"set X" );
415 ok+= compare(
q2.Y(),
q1s.Y(),
"set Y" );
416 ok+= compare(
q2.Z(),
q1s.Z(),
"set Z" ,2);
417 ok+= compare(
q2.T(),
q1s.T(),
"set E" );
419 if (ok == 0) std::cout <<
"\t OK " << std::endl;
425 std::cout <<
"\n************************************************************************\n "
426 <<
" Utility Function Tests"
427 <<
"\n************************************************************************\n";
429 std::cout <<
"Test Vector utility functions : ";
437 ok += compare( VectorUtil::DeltaPhi(
v1,
v2), 1.0,
"deltaPhi Vec");
442 ok += compare( VectorUtil::DeltaR(
v1,
v2), sqrt(2.0),
"DeltaR Vec");
445 ok += compare( VectorUtil::CosTheta(
v1,
vperp), 0.0,
"costheta Vec");
448 if (ok == 0) std::cout <<
"\t\t OK " << std::endl;
451 std::cout <<
"Test Point utility functions : ";
459 ok += compare( VectorUtil::DeltaPhi(
p1,
p2), 1.0,
"deltaPhi Point");
463 ok += compare( VectorUtil::DeltaR(
p1,
p2), sqrt(2.0),
"DeltaR Point");
466 ok += compare( VectorUtil::CosTheta(
p1,
pperp), 0.0,
"costheta Point");
469 if (ok == 0) std::cout <<
"\t\t OK " << std::endl;
471 std::cout <<
"LorentzVector utility funct.: ";
478 ok += compare( VectorUtil::DeltaPhi(
q1,
q2), 1.0,
"deltaPhi LVec");
479 ok += compare( VectorUtil::DeltaR(
q1,
q2), sqrt(2.0),
"DeltaR LVec");
482 ok += compare( VectorUtil::InvariantMass(
q1,
q2),
qsum.M(),
"InvMass");
484 if (ok == 0) std::cout <<
"\t\t OK " << std::endl;
490 std::cout <<
"\n************************************************************************\n "
491 <<
" Rotation and Transformation Tests"
492 <<
"\n************************************************************************\n";
494 std::cout <<
"Test Vector Rotations : ";
514 ok+= compare(
v1.X(),
v2.X(),
"x",2);
515 ok+= compare(
v1.Y(),
v2.Y(),
"y",2);
516 ok+= compare(
v1.Z(),
v2.Z(),
"z",2);
518 ok+= compare(
v1.X(),
v3.X(),
"x",2);
519 ok+= compare(
v1.Y(),
v3.Y(),
"y",2);
520 ok+= compare(
v1.Z(),
v3.Z(),
"z",2);
522 ok+= compare(
v1.X(),
v4.X(),
"x",5);
523 ok+= compare(
v1.Y(),
v4.Y(),
"y",5);
524 ok+= compare(
v1.Z(),
v4.Z(),
"z",5);
526 ok+= compare(
v1.X(), v5.X(),
"x",2);
527 ok+= compare(
v1.Y(), v5.Y(),
"y",2);
528 ok+= compare(
v1.Z(), v5.Z(),
"z",2);
540 v6.SetCoordinates(
q2.GetMatrixArray() );
542 ok+= compare(
v1.X(),
v6.X(),
"x");
543 ok+= compare(
v1.Y(),
v6.Y(),
"y");
544 ok+= compare(
v1.Z(),
v6.Z(),
"z");
546 if (ok == 0) std::cout <<
"\t OK " << std::endl;
547 else std::cout << std::endl;
549 std::cout <<
"Test Axial Rotations : ";
595 ok+= compare(
vinv1.X(),
v.X(),
"x",2);
596 ok+= compare(
vinv1.Y(),
v.Y(),
"y");
597 ok+= compare(
vinv1.Z(),
v.Z(),
"z");
599 if (ok == 0) std::cout <<
"\t OK " << std::endl;
600 else std::cout << std::endl;
603 std::cout <<
"Test Rotations by a PI angle : ";
606 double b[4] = { 6,8,10,3.14159265358979323 };
610 ok+= compare(
arPi.Axis().X(),
a1.Axis().X(),
"x");
611 ok+= compare(
arPi.Axis().Y(),
a1.Axis().Y(),
"y");
612 ok+= compare(
arPi.Axis().Z(),
a1.Axis().Z(),
"z");
613 ok+= compare(
arPi.Angle(),
a1.Angle(),
"angle");
617 ok+= compare(
ePi.Phi(),
e1.Phi(),
"phi");
618 ok+= compare(
ePi.Theta(),
e1.Theta(),
"theta");
619 ok+= compare(
ePi.Psi(),
e1.Psi(),
"ps1");
621 if (ok == 0) std::cout <<
"\t\t OK " << std::endl;
622 else std::cout << std::endl;
624 std::cout <<
"Test Inversions : ";
636 ok+= compare(
p.X(),
v.X(),
"x",10);
637 ok+= compare(
p.Y(),
v.Y(),
"y",10);
638 ok+= compare(
p.Z(),
v.Z(),
"z",10);
643 ok+= compare(
p.X(),
v.X(),
"x",10);
644 ok+= compare(
p.Y(),
v.Y(),
"y",10);
645 ok+= compare(
p.Z(),
v.Z(),
"z",10);
649 ok+= compare(
p.X(),
v.X(),
"x",1
E9);
650 ok+= compare(
p.Y(),
v.Y(),
"y",1
E9);
651 ok+= compare(
p.Z(),
v.Z(),
"z",1
E9);
655 ok+= compare(
p.X(),
v.X(),
"x",10);
656 ok+= compare(
p.Y(),
v.Y(),
"y",10);
657 ok+= compare(
p.Z(),
v.Z(),
"z",10);
665 ok+= compare(
p.X(),
v.X(),
"x",10);
666 ok+= compare(
p.Y(),
v.Y(),
"y",10);
667 ok+= compare(
p.Z(),
v.Z(),
"z",10);
669 if (ok == 0) std::cout <<
"\t OK " << std::endl;
670 else std::cout << std::endl;
673 std::cout <<
"Test rectify : ";
682 ok+= compare(
v.R(),
vrr.R(),
"R",1.E9);
684 if (ok == 0) std::cout <<
"\t\t OK " << std::endl;
685 else std::cout << std::endl;
687 std::cout <<
"Test Transform3D : ";
697 ok+= compare(
pd.X(),
vd.X(),
"x");
698 ok+= compare(
pd.Y(),
vd.Y(),
"y");
699 ok+= compare(
pd.Z(),
vd.Z(),
"z");
703 t.GetComponents(
tdata);
712 ok+= compare(
pd.X(),
qt(0),
"x");
713 ok+= compare(
pd.Y(),
qt(1),
"y");
714 ok+= compare(
pd.Z(),
qt(2),
"z");
722 ok+= compare(
p.X(),
v.X(),
"x",10);
723 ok+= compare(
p.Y(),
v.Y(),
"y",10);
724 ok+= compare(
p.Z(),
v.Z(),
"z",10);
731 ok+= compare(
p.X(),
v.X(),
"x",10);
732 ok+= compare(
p.Y(),
v.Y(),
"y",10);
733 ok+= compare(
p.Z(),
v.Z(),
"z",10);
741 ok+= compare(
tc ==
tb*
ta,
static_cast<double>(
true),
"== Rot*Tra");
742 ok+= compare(
td ==
ta*
tb,
static_cast<double>(
true),
"== Rot*Tra");
745 if (ok == 0) std::cout <<
"\t OK " << std::endl;
746 else std::cout << std::endl;
748 std::cout <<
"Test Plane3D : ";
760 ok+= compare(
n.Dot(
p2-
p1), 0.0,
"n.v12",10);
761 ok+= compare(
n.Dot(
p3-
p1), 0.0,
"n.v13",10);
762 ok+= compare(
n.Dot(
p3-
p2), 0.0,
"n.v23",10);
775 ok+= compare(
n1.X(),
n2.X(),
"a",10);
776 ok+= compare(
n1.Y(),
n2.Y(),
"b",10);
777 ok+= compare(
n1.Z(),
n2.Z(),
"c",10);
778 ok+= compare(
plane1.HesseDistance(),
plane2.HesseDistance(),
"d",10);
781 ok += compare(
plane1.Distance(
pt1), 0.0,
"distance",10);
783 if (ok == 0) std::cout <<
"\t OK " << std::endl;
784 else std::cout << std::endl;
786 std::cout <<
"Test LorentzRotation : ";
808 ok+= compare(
lv1==
lv2,
true,
"V0==V2");
809 ok+= compare(
lv1==
lv2,
true,
"V1==V2");
820 ok+= compare(
lv1.X(),
qlr(0),
"x");
821 ok+= compare(
lv1.Y(),
qlr(1),
"y");
822 ok+= compare(
lv1.Z(),
qlr(2),
"z");
823 ok+= compare(
lv1.E(),
qlr(3),
"t");
828 ok+= compare(
lv0.X(),
lv.X(),
"x");
829 ok+= compare(
lv0.Y(),
lv.Y(),
"y");
830 ok+= compare(
lv0.Z(),
lv.Z(),
"z");
831 ok+= compare(
lv0.E(),
lv.E(),
"t");
833 if (ok == 0) std::cout <<
"\t OK " << std::endl;
834 else std::cout << std::endl;
837 std::cout <<
"Test Boost : ";
849 ok+= compare(
lvb.X(),
lvb2.X(),
"x");
850 ok+= compare(
lvb.Y(),
lvb2.Y(),
"y");
851 ok+= compare(
lvb.Z(),
lvb2.Z(),
"z");
852 ok+= compare(
lvb.E(),
lvb2.E(),
"t");
853 ok+= compare(
lvb.M(),
lv.M(),
"m",50);
858 ok+= compare(
lv0.X(),
lv.X(),
"x",5);
859 ok+= compare(
lv0.Y(),
lv.Y(),
"y",5);
860 ok+= compare(
lv0.Z(),
lv.Z(),
"z",3);
861 ok+= compare(
lv0.E(),
lv.E(),
"t",3);
868 ok+= compare(
lvr.X(), 0.0,
"x",10);
869 ok+= compare(
lvr.Y(), 0.0,
"y",10);
870 ok+= compare(
lvr.Z(), 0.0,
"z",10);
871 ok+= compare(
lvr.M(),
lv.M(),
"m",10);
873 if (ok == 0) std::cout <<
"\t OK " << std::endl;
874 else std::cout << std::endl;
887 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()