Logo ROOT   6.07/09
Reference Guide
rotationApplication.cxx
Go to the documentation of this file.
1 /**********************************************************************
2  * *
3  * Copyright (c) 2005 , FNAL LCG ROOT MathLib Team *
4  * *
5  * *
6  **********************************************************************/
7 
8 // RotationApplication.cpp
9 //
10 // Created by: M. Fischler, Aug 10, 2005
11 //
12 // Tests that each Rotation produces correct results when applied to
13 // each form of vector in each oordinate system, and incidently that products
14 // of rotations work properly.
15 //
16 // The strategy is to build up sequences of rotations about the X, Y, and Z
17 // axes, such that we can easily determine the correct vector answer.
18 //
19 // =================================================================
20 
24 #include "Math/GenVector/Polar3D.h"
35 
37 
38 #include "Math/Vector3Dfwd.h"
39 
40 #include "CoordinateTraits.h"
41 #include "RotationTraits.h"
42 
43 #include <iostream>
44 #include <limits>
45 #include <cmath>
46 #include <vector>
47 
48 using std::sin;
49 using std::cos;
50 
51 //#define TRACE2
52 //#define TRACE1
53 //#define DEBUG
54 
55 using namespace ROOT::Math;
56 
57 #ifndef __CINT__
58 
59 template <typename T1, typename T2 >
60 struct Precision {
61  enum { result = std::numeric_limits<T1>::digits <= std::numeric_limits<T2>::digits };
62 };
63 
64 template <typename T1, typename T2, bool>
65 struct LessPreciseType {
66  typedef T1 type;
67 };
68 template <typename T1, typename T2>
69 struct LessPreciseType<T1, T2, false> {
70  typedef T2 type;
71 };
72 
73 
74 const double machEpsilon = pow (2.0, -52.0);
75 
76 template <typename Scalar1, typename Scalar2>
77 int
78 closeEnough (Scalar1 s1, Scalar2 s2, std::string const & coord, double ticks) {
79  int ret = 0;
80  int pr = std::cout.precision(18);
84  Scalar epsilon = (eps1 >= eps2) ? eps1 : eps2;
85  Scalar ss1 (s1);
86  Scalar ss2 (s2);
87  Scalar diff = ss1 - ss2;
88  if (diff < 0) diff = -diff;
89  if ( diff > ticks*epsilon ) {
90  ret=3;
91  std::cout << "\n\n????????\n\nAbsolute discrepancy in " << coord << "(): "
92  << ss1 << " != " << ss2 << "\n"
93  << " (Allowed discrepancy is " << ticks
94  << " ticks = " << ticks*epsilon
95  << ")\nDifference is " << diff/epsilon << " ticks\n";
96  }
97  std::cout.precision (pr);
98  return ret;
99 }
100 
101 template <class V1, class V2>
102 int compare3D (const V1 & v1, const V2 & v2, double ticks) {
103  int ret =0;
104  typedef typename V1::CoordinateType CoordType1;
105  typedef typename V2::CoordinateType CoordType2;
106 
107  ret |= closeEnough ( v1.x(), v2.x(), "x" ,ticks);
108  ret |= closeEnough ( v1.y(), v2.y(), "y" ,ticks);
109  ret |= closeEnough ( v1.z(), v2.z(), "z" ,ticks);
110 
111  if (ret != 0) {
112  std::cout << "Discrepancy detected (see above) is between:\n "
113  << CoordinateTraits<CoordType1>::name() << " and\n "
115  << "with v = (" << v1.x() << ", " << v1.y() << ", " << v1.z()
116  << ")\nv1 is " << v1
117  << "\nv2 is " << v2 << "\n\n";
118  }
119 
120  return ret;
121 }
122 
123 template <class V> struct correctedTicks {
124  double operator()(double ticks, const V& /*v */ , const XYZVector & /* ans */)
125  {
126  return ticks;
127  }
128 };
129 
130 double correctTicks (double ticks,double z,double r) {
131  double e = ticks*std::fabs( z*z / (r*r-z*z) );
132  if (e < ticks) return ticks;
133  return e;
134 }
135 
136 template<> struct
137 correctedTicks< DisplacementVector3D < CylindricalEta3D<double> > > {
138  double operator()(double ticks,
140  const XYZVector & ans) {
141  double t1 = correctTicks (ticks, v.z(), v.r());
142  double t2 = correctTicks (ticks, ans.z(), ans.r());
143  return t1 > t2 ? t1 : t2;
144  }
145 };
146 
147 template<> struct
148 correctedTicks< PositionVector3D < CylindricalEta3D<double> > > {
149  double operator()(double ticks,
151  const XYZVector & ans) {
152  double t1 = correctTicks (ticks, v.z(), v.r());
153  double t2 = correctTicks (ticks, ans.z(), ans.r());
154  return t1 > t2 ? t1 : t2;
155  }
156 };
157 
158 template <class R, class V>
159 int testApplication(const R& r,const V& v,const XYZVector &answer,double t) {
160 
161  typedef typename V::CoordinateType CoordType;
162 
163  int ret = 0;
164  correctedTicks<V> ct;
165  double ticks = ct(t, v, answer);
166 #ifdef DEBUG
167  std::cout <<">>>>> Testing application of "
168  << RotationTraits<R>::name() << " " << r << "\non "
170  v << " ticks = " << ticks;
171 #endif
172 #ifdef TRACE2
173  std::cout << " about to do V rv = r(v) - \n";
174 #endif
175  V rv = r(v);
176 #ifdef TRACE2
177  std::cout << "ok ";
178 #endif
179  // comparison here should be == but need to use 10 ticks to be sure for 32 bits machines
180  // when results are flushed in memory and approximated
181  if ( compare3D(rv, r*v, 10 ) != 0) {
182  std::cout << "Inconsistency between R(v) and R*v for R = "
183  << RotationTraits<R>::name() << " " << r
184  << "\nacting on " << CoordinateTraits<CoordType>::name() << v << "\n";
185  ret |= 9;
186  }
187 #ifdef TRACE2
188  std::cout << "+ also did rv != r*v ";
189 #endif
190  if ( closeEnough(v.r(), rv.r(), "r", ticks) != 0 ) {
191  std::cout << "Radius change between R(v) and R*v for R = "
192  << RotationTraits<R>::name() << " " << r
193  << "\nacting on "
195  << v << "\n";
196  ret |= 17;
197  }
198 #ifdef TRACE2
199  std::cout << "\n---- about to do compare3D ----";
200 #endif
201  ret |= compare3D (rv, answer, ticks);
202 #ifdef TRACE2
203  std::cout << " done \n";
204 #endif
205 #ifdef DEBUG
206  if (ret == 0) std::cout << " OK\n";
207 #endif
208  return ret;
209 }
210 
211 
212 XYZVector rxv ( double phi, XYZVector v ) {
213  double c = cos(phi);
214  double s = sin(phi);
215  return XYZVector ( v.x(), c*v.y()-s*v.z(), s*v.y()+c*v.z() );
216 }
217 
218 XYZVector ryv ( double phi, XYZVector v ) {
219  double c = cos(phi);
220  double s = sin(phi);
221  return XYZVector ( c*v.x()+s*v.z(), v.y(), -s*v.x()+c*v.z() );
222 }
223 
224 XYZVector rzv ( double phi, XYZVector v ) {
225  double c = cos(phi);
226  double s = sin(phi);
227  return XYZVector ( c*v.x()-s*v.y(), s*v.x()+c*v.y(), v.z() );
228 }
229 
230 enum XYZ { X, Y, Z } ;
231 
232 struct TestRotation {
233  std::vector<XYZ> xyz;
234  std::vector<double> phi;
235  TestRotation (std::vector<XYZ> const & xyz_, std::vector<double> const & phi_)
236  : xyz(xyz_), phi(phi_) {}
237 };
238 
239 
240 Rotation3D rrr (TestRotation const & t) {
241 #ifdef TRACE1
242  std::cout << "---- rrr ----";
243 #endif
244  Rotation3D r;
245  for (unsigned int i=0; i<t.xyz.size(); ++i) {
246  switch ( t.xyz[i] ) {
247  case X:
248  r = r*RotationX(t.phi[i]);
249  break;
250  case Y:
251  r = r*RotationY(t.phi[i]);
252  break;
253  case Z:
254  r = r*RotationZ(t.phi[i]);
255  break;
256  }
257  }
258 #ifdef TRACE1
259  std::cout << " done\n";
260 #endif
261  return r;
262 }
263 
264 XYZVector ans ( TestRotation const & t, XYZVector const & v_in) {
265  XYZVector v(v_in);
266  for (int i=t.xyz.size()-1; i >= 0; --i) {
267  switch ( t.xyz[i] ) {
268  case X:
269  v = rxv ( t.phi[i],v );
270  break;
271  case Y:
272  v = ryv ( t.phi[i],v );
273  break;
274  case Z:
275  v = rzv ( t.phi[i],v );
276  break;
277  }
278  }
279  return v;
280 }
281 
282 const double pi = 3.1415926535897932385;
283 
284 std::vector<TestRotation>
286 #ifdef TRACE1
287  std::cout << "---- makeTestRotations ----";
288 #endif
289  std::vector<TestRotation> t;
290  std::vector<XYZ> xyz;
291  std::vector<double> phi;
292 
293 
294 
295  xyz.clear(); phi.clear();
296  xyz.push_back(X); phi.push_back( pi/2 );
297  t.push_back(TestRotation(xyz,phi));
298 
299  xyz.clear(); phi.clear();
300  xyz.push_back(Y); phi.push_back( pi/2 );
301  t.push_back(TestRotation(xyz,phi));
302 
303  xyz.clear(); phi.clear();
304  xyz.push_back(Z); phi.push_back( pi/2 );
305  t.push_back(TestRotation(xyz,phi));
306 
307  xyz.clear(); phi.clear();
308  xyz.push_back(X); phi.push_back( -pi/6 );
309  t.push_back(TestRotation(xyz,phi));
310 
311  xyz.clear(); phi.clear();
312  xyz.push_back(Y); phi.push_back( pi/6 );
313  t.push_back(TestRotation(xyz,phi));
314 
315  xyz.clear(); phi.clear();
316  xyz.push_back(Z); phi.push_back( pi/3 );
317  t.push_back(TestRotation(xyz,phi));
318 
319  xyz.clear(); phi.clear();
320  xyz.push_back(X); phi.push_back( -pi/6 );
321  xyz.push_back(Y); phi.push_back( pi/3 );
322  t.push_back(TestRotation(xyz,phi));
323 
324  xyz.clear(); phi.clear();
325  xyz.push_back(X); phi.push_back( -pi/6 );
326  xyz.push_back(Y); phi.push_back( pi/4 );
327  xyz.push_back(Z); phi.push_back( -pi/5 );
328  t.push_back(TestRotation(xyz,phi));
329 
330  xyz.clear(); phi.clear();
331  xyz.push_back(Y); phi.push_back( pi );
332  xyz.push_back(X); phi.push_back( -pi/2 );
333  xyz.push_back(Z); phi.push_back( -pi/1.5 );
334  xyz.push_back(Y); phi.push_back( -pi/3 );
335  t.push_back(TestRotation(xyz,phi));
336 
337  xyz.clear(); phi.clear();
338  xyz.push_back(Z); phi.push_back( 1.3 );
339  xyz.push_back(Y); phi.push_back( -1.1 );
340  xyz.push_back(X); phi.push_back( 0.4 );
341  xyz.push_back(Y); phi.push_back( 0.7 );
342  t.push_back(TestRotation(xyz,phi));
343 
344  xyz.clear(); phi.clear();
345  xyz.push_back(X); phi.push_back( 1.3 );
346  xyz.push_back(Z); phi.push_back( -1.1 );
347  xyz.push_back(Y); phi.push_back( 0.4 );
348  xyz.push_back(Z); phi.push_back( 0.7 );
349  t.push_back(TestRotation(xyz,phi));
350 
351  xyz.clear(); phi.clear();
352  xyz.push_back(Y); phi.push_back( 1.3 );
353  xyz.push_back(X); phi.push_back( -1.1 );
354  xyz.push_back(Z); phi.push_back( 0.4 );
355  xyz.push_back(X); phi.push_back( 0.7 );
356  t.push_back(TestRotation(xyz,phi));
357 
358  xyz.clear(); phi.clear();
359  xyz.push_back(Z); phi.push_back( .03 );
360  xyz.push_back(Y); phi.push_back( -.05 );
361  xyz.push_back(X); phi.push_back( 0.04 );
362  xyz.push_back(Y); phi.push_back( 0.07 );
363  xyz.push_back(Z); phi.push_back( -0.02 );
364  t.push_back(TestRotation(xyz,phi));
365 
366 #ifdef TRACE1
367  std::cout << " done\n";
368 #endif
369  return t;
370 }
371 
372 std::vector<XYZVector> makeTestVectors () {
373 #ifdef TRACE1
374  std::cout << "---- makeTestVectors ----";
375 #endif
376  std::vector<XYZVector> vs;
377  vs.push_back(XYZVector ( 1, 0, 0 ));
378  vs.push_back(XYZVector ( 0, 1, 0 ));
379  vs.push_back(XYZVector ( 0, 0, 1 ));
380  vs.push_back(XYZVector ( -1, 0, 0 ));
381  vs.push_back(XYZVector ( 0, -1, 0 ));
382  vs.push_back(XYZVector ( 0, 0, -1 ));
383  vs.push_back(XYZVector ( 1, 2, 3 ));
384  vs.push_back(XYZVector ( 2, -1, 3 ));
385  vs.push_back(XYZVector ( -3, 1, -2 ));
386  vs.push_back(XYZVector ( 0, .00001, -2 ));
387 
388 #ifdef TRACE1
389  std::cout << " done\n";
390 #endif
391  return vs;
392 }
393 
394 template <class R, class V>
395 int doTest (TestRotation const & testRotation, XYZVector const & testVector,
396  double ticks) {
397 #ifdef TRACE1
398  std::cout << "---- doTest ----";
399 #endif
400  int ret = 0;
401  R r ( rrr(testRotation) );
402  V v(testVector);
403  XYZVector rv = ans (testRotation, testVector);
404  ret |= testApplication (r, v, rv, ticks);
405 #ifdef TRACE1
406  std::cout << " done\n";
407 #endif
408 
409  if (ret == 0) std::cout << ".";
410 
411  return ret;
412 }
413 
414 template <class R, class C>
415 int doTestL (TestRotation const & testRotation, XYZVector const & testVector,
416  double ticks) {
417 #ifdef TRACE1
418  std::cout << "---- doTestL ----";
419 #endif
420  int ret = 0;
421  R r ( rrr(testRotation) );
423  double x = testVector.X();
424  double y = testVector.Y();
425  double z = testVector.Z();
426  double t = std::sqrt (x*x + y*y + z*z + 1);
427  v.SetXYZT ( x, y, z, t );
428  XYZVector rv = ans (testRotation, testVector);
429  ret |= testApplication (r, v, rv, ticks);
430  LorentzVector<C> rv2 = r(v);
431  ret |= closeEnough (t, rv2.E(), "t", ticks);
432 #ifdef TRACE1
433  std::cout << " done\n";
434 #endif
435  return ret;
436 }
437 
438 struct ForeignVector {
439  typedef Cartesian3D<> CoordinateType;
440  XYZVector v;
441  template <class V>
442  explicit ForeignVector (V const & v_) : v(v_) {}
443  ForeignVector (double xx, double yy, double zz) : v(xx,yy,zz) {}
444  double x() const { return v.x(); }
445  double y() const { return v.y(); }
446  double z() const { return v.z(); }
447  double r() const { return v.r(); }
448  bool operator==(ForeignVector const & rhs) {return v == rhs.v;}
449  bool operator!=(ForeignVector const & rhs) {return v != rhs.v;}
450 };
451 std::ostream & operator<< (std::ostream& os, const ForeignVector& v) {
452  return os << v.v;
453 }
454 
455 
456 template <class R>
457 int doTestOfR (TestRotation const & testRotation, XYZVector const & testVector){
458 #ifdef TRACE1
459  std::cout << "---- doTestofR ----\n";
460 #endif
461  int ret = 0;
462  const double ticks = 100; // move from 32 to 100
463 #ifdef DEBUG
464  std::cout << ">>>>> DisplacementVector3D< Cartesian3D<double> \n";
465 #endif
466  ret |= doTest <R, DisplacementVector3D< Cartesian3D<double> > >
467  (testRotation,testVector,ticks);
468 #ifdef DEBUG
469  std::cout << ">>>>> DisplacementVector3D< Polar3D<double> \n";
470 #endif
471  ret |= doTest <R, DisplacementVector3D< Polar3D<double> > >
472  (testRotation,testVector,ticks);
473 #ifdef DEBUG
474  std::cout << ">>>>> DisplacementVector3D< CylindricalEta3D<double> \n";
475 #endif
476  ret |= doTest <R, DisplacementVector3D< CylindricalEta3D<double> > >
477  (testRotation,testVector,ticks);
478 #ifdef DEBUG
479  std::cout << ">>>>> PositionVector3D< Cartesian3D<double> \n";
480 #endif
481  ret |= doTest <R, PositionVector3D< Cartesian3D<double> > >
482  (testRotation,testVector,ticks);
483 #ifdef DEBUG
484  std::cout << ">>>>> PositionVector3D< Polar3D<double> \n";
485 #endif
486  ret |= doTest <R, PositionVector3D< Polar3D<double> > >
487  (testRotation,testVector,ticks);
488 #ifdef DEBUG
489  std::cout << ">>>>> PositionVector3D< CylindricalEta3D<double> \n";
490 #endif
491  ret |= doTest <R, PositionVector3D< CylindricalEta3D<double> > >
492  (testRotation,testVector,ticks);
493 #ifdef DEBUG
494  std::cout << ">>>>> ForeignVector\n";
495 #endif
496  ret |= doTest <R, ForeignVector >
497  (testRotation,testVector,ticks);
498 #ifdef DEBUG
499  std::cout << ">>>>> LorentzVector<PxPyPzE4D<double> >\n";
500 #endif
501  ret |= doTestL <R, PxPyPzE4D<double> >
502  (testRotation,testVector,ticks);
503 #ifdef TRACE1
504  std::cout << " ---- doTestofR ---- done\n";
505 #endif
506 
507  if (ret == 0) std::cout << ".";
508 
509  // TODO - other 4D coordinates
510 
511  return ret;
512 }
513 
514 
515 int exerciseTestCase (TestRotation const & testRotation,
516  XYZVector const & testVector)
517 {
518 
519  std::cout << ">>>>> Rotation Tests of " << testVector << "\t\t: " ;
520 
521 #ifdef TRACE1
522  std::cout << "---- exerciseTestCase ----";
523 #endif
524  int ret = 0;
525  ret |= doTestOfR <Rotation3D> (testRotation,testVector);
526  ret |= doTestOfR <AxisAngle> (testRotation,testVector);
527  ret |= doTestOfR <EulerAngles> (testRotation,testVector);
528  ret |= doTestOfR <Quaternion> (testRotation,testVector);
529  ret |= doTestOfR <RotationZYX> (testRotation,testVector);
530 #ifdef TRACE1
531  std::cout << " done\n";
532 #endif
533 
534  if (ret == 0)
535  std::cout << "\t OK\n";
536  else {
537  std::cout << "\t Failed!\n ";
538  std::cerr << "\n>>>>> Rotation Tests of " << testVector << "\t\t:\t FAILED \n";
539  }
540 
541  return ret;
542 }
543 
544 // ===== Axial test section =============
545 
546 template <class R, class V>
547 int doTestA (XYZVector const & testVector, double ticks) {
548 #ifdef TRACE1
549  std::cout << "---- doTestA ----";
550 #endif
551  int ret = 0;
552  V v(testVector);
553  XYZVector rv;
554  for (double angle = -4.0; angle < 4.0; angle += .15) {
555  RotationX rx (angle);
556  rv = rxv (angle, testVector);
557  ret |= testApplication (rx, v, rv, ticks);
558  RotationY ry (angle);
559  rv = ryv (angle, testVector);
560  ret |= testApplication (ry, v, rv, ticks);
561  RotationZ rz (angle);
562  rv = rzv (angle, testVector);
563  ret |= testApplication (rz, v, rv, ticks);
564  }
565 #ifdef TRACE1
566  std::cout << " done\n";
567 #endif
568  if (ret == 0) std::cout << ".";
569  return ret;
570 }
571 
572 template <class R, class C>
573 int doTestLA (XYZVector const & testVector, double ticks) {
574 #ifdef TRACE1
575  std::cout << "---- doTestLA ----";
576 #endif
577  int ret = 0;
579  double x = testVector.X();
580  double y = testVector.Y();
581  double z = testVector.Z();
582  double t = std::sqrt (x*x + y*y + z*z + 1);
583  v.SetXYZT ( x, y, z, t );
584  XYZVector rv;
585  for (double angle = -4.0; angle < 4.0; angle += .15) {
586  //std::cout << "\n============ angle is " << angle << "\n";
587  RotationX rx (angle);
588  rv = rxv (angle, testVector);
589  ret |= testApplication (rx, v, rv, ticks);
590  RotationY ry (angle);
591  rv = ryv (angle, testVector);
592  ret |= testApplication (ry, v, rv, ticks);
593  RotationZ rz (angle);
594  rv = rzv (angle, testVector);
595  ret |= testApplication (rz, v, rv, ticks);
596  }
597 #ifdef TRACE1
598  std::cout << " done\n";
599 #endif
600 
601  if (ret == 0) std::cout << ".";
602  return ret;
603 }
604 
605 template <class R>
606 int doTestOfAxial (XYZVector const & testVector){
607 #ifdef TRACE1
608  std::cout << "---- doTestOfAxial ----\n";
609 #endif
610  int ret = 0;
611  const double ticks = 32;
612 #ifdef DEBUG
613  std::cout << ">>>>> DisplacementVector3D< Cartesian3D<double> \n";
614 #endif
615  ret |= doTestA <R, DisplacementVector3D< Cartesian3D<double> > >
616  (testVector,ticks);
617 #ifdef DEBUG
618  std::cout << ">>>>> DisplacementVector3D< Polar3D<double> \n";
619 #endif
620  ret |= doTestA <R, DisplacementVector3D< Polar3D<double> > >
621  (testVector,ticks);
622 #ifdef DEBUG
623  std::cout << ">>>>> DisplacementVector3D< CylindricalEta3D<double> \n";
624 #endif
625  ret |= doTestA <R, DisplacementVector3D< CylindricalEta3D<double> > >
626  (testVector,ticks);
627 #ifdef DEBUG
628  std::cout << ">>>>> PositionVector3D< Cartesian3D<double> \n";
629 #endif
630  ret |= doTestA <R, PositionVector3D< Cartesian3D<double> > >
631  (testVector,ticks);
632 #ifdef DEBUG
633  std::cout << ">>>>> PositionVector3D< Polar3D<double> \n";
634 #endif
635  ret |= doTestA <R, PositionVector3D< Polar3D<double> > > (testVector,ticks);
636 #ifdef DEBUG
637  std::cout << ">>>>> PositionVector3D< CylindricalEta3D<double> \n";
638 #endif
639  ret |= doTestA <R, PositionVector3D< CylindricalEta3D<double> > >
640  (testVector,ticks);
641 #ifdef DEBUG
642  std::cout << ">>>>> ForeignVector\n";
643 #endif
644  ret |= doTestA <R, ForeignVector > (testVector,ticks);
645 #ifdef DEBUG
646  std::cout << ">>>>> LorentzVector<PxPyPzE4D<double> >\n";
647 #endif
648  ret |= doTestLA <R, PxPyPzE4D<double> > (testVector,ticks);
649 #ifdef TRACE1
650  std::cout << " ---- doTestofR ---- done\n";
651 #endif
652  // TODO - other 4D coordinates
653 
654  if (ret == 0) std::cout << ".";
655 
656  return ret;
657 }
658 
659 int exerciseAxialTest (XYZVector const & testVector)
660 {
661 
662 #ifdef TRACE1
663  std::cout << "---- exerciseAxialTest ----";
664 #endif
665 
666  std::cout << ">>>>> Axial Rotation Tests of " << testVector << "\t\t: ";
667 
668  int ret = 0;
669  ret |= doTestOfAxial <RotationX> (testVector);
670  ret |= doTestOfAxial <RotationY> (testVector);
671  ret |= doTestOfAxial <RotationZ> (testVector);
672 #ifdef TRACE1
673  std::cout << " done\n";
674 #endif
675 
676  if (ret == 0)
677  std::cout << "\t OK\n";
678  else {
679  std::cout << "\t Failed!\n ";
680  std::cerr << "\n>>>>> Axial Rotation Tests of " << testVector << "\t\t:\t FAILED \n";
681  }
682 
683  return ret;
684 }
685 
686 
687 #endif // endif on __CINT__
688 
689 // ======================================
690 
691 
692 int rotationApplication (bool forceRun = false) {
693  int ret = 0;
694 
695  bool skipTests = false;
696 #if defined(__i386__)
697  // do not run by default tests on 32 bit architecture
698  // since extended precision will make it difficult
699  skipTests = true;
700 #endif
701 
702  if (skipTests && !forceRun) {
703  std::cout << "Skip the tests - it is probably a 32 bit arch - return 0" << std::endl;
704  return 0;
705  }
706 
707  std::vector<TestRotation> testRotations = makeTestRotations();
708  std::vector<XYZVector> testVectors = makeTestVectors();
709  for ( std::vector<TestRotation>::const_iterator n = testRotations.begin();
710  n != testRotations.end(); ++n ) {
711  for ( std::vector<XYZVector>::const_iterator m = testVectors.begin();
712  m != testVectors.end(); ++m ) {
713  ret |= exerciseTestCase (*n, *m);
714  }
715  }
716  for ( std::vector<XYZVector>::const_iterator vp = testVectors.begin();
717  vp != testVectors.end(); ++vp ) {
718  ret |= exerciseAxialTest (*vp);
719  }
720 
721  return ret;
722 }
723 
724 int main() {
725  int ret = rotationApplication(true);
726  if (ret) std::cerr << "test FAILED !!! " << std::endl;
727  else std::cout << "test OK " << std::endl;
728  return ret;
729 }
int testApplication(const R &r, const V &v, const XYZVector &answer, double t)
Scalar E() const
return 4-th component (time, or energy for a 4-momentum vector)
XYZVector ans(TestRotation const &t, XYZVector const &v_in)
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Definition: LorentzVector.h:54
int doTest(TestRotation const &testRotation, XYZVector const &testVector, double ticks)
const double pi
return c
Rotation class representing a 3D rotation about the Z axis by the angle of rotation.
Definition: RotationZ.h:43
Scalar Y() const
Cartesian Y, converting if necessary from internal coordinate system.
Class describing a cylindrical coordinate system based on eta (pseudorapidity) instead of z...
Class describing a generic position vector (point) in 3 dimensions.
int doTestA(XYZVector const &testVector, double ticks)
int doTestLA(XYZVector const &testVector, double ticks)
Class describing a 3D cartesian coordinate system (x, y, z coordinates)
Definition: Cartesian3D.h:51
LorentzVector< CoordSystem > & SetXYZT(Scalar xx, Scalar yy, Scalar zz, Scalar tt)
set the values of the vector from the cartesian components (x,y,z,t) (if the vector is held in anothe...
TLatex * t1
Definition: textangle.C:20
double cos(double)
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition: AxisAngle.cxx:91
Rotation3D rrr(TestRotation const &t)
double sqrt(double)
Double_t x[n]
Definition: legend1.C:17
Rotation class representing a 3D rotation about the Y axis by the angle of rotation.
Definition: RotationY.h:43
Scalar X() const
Cartesian X, converting if necessary from internal coordinate system.
double pow(double, double)
int doTestOfR(TestRotation const &testRotation, XYZVector const &testVector)
double correctTicks(double ticks, double z, double r)
Bool_t operator!=(const TDatime &d1, const TDatime &d2)
Definition: TDatime.h:103
static const std::string name()
double sin(double)
int doTestOfAxial(XYZVector const &testVector)
Class describing a generic displacement vector in 3 dimensions.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
TRandom2 r(17)
SVector< double, 2 > v
Definition: Dict.h:5
int rotationApplication(bool forceRun=false)
int exerciseTestCase(TestRotation const &testRotation, XYZVector const &testVector)
static const std::string name()
Rotation class representing a 3D rotation about the X axis by the angle of rotation.
Definition: RotationX.h:43
std::vector< TestRotation > makeTestRotations()
Rotation class with the (3D) rotation represented by a 3x3 orthogonal matrix.
Definition: Rotation3D.h:65
TMarker * m
Definition: textangle.C:8
int exerciseAxialTest(XYZVector const &testVector)
REAL epsilon
Definition: triangle.c:617
int compare3D(const V1 &v1, const V2 &v2, double ticks)
XYZVector rzv(double phi, XYZVector v)
RooCmdArg Precision(Double_t prec)
int doTestL(TestRotation const &testRotation, XYZVector const &testVector, double ticks)
int main()
XYZVector ryv(double phi, XYZVector v)
Scalar Z() const
Cartesian Z, converting if necessary from internal coordinate system.
int type
Definition: TGX11.cxx:120
#define T2
Definition: md5.inl:146
Double_t y[n]
Definition: legend1.C:17
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
XYZVector rxv(double phi, XYZVector v)
DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > XYZVector
3D Vector based on the cartesian coordinates x,y,z in double precision
Definition: Vector3Dfwd.h:34
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
#define T1
Definition: md5.inl:145
Bool_t operator==(const TDatime &d1, const TDatime &d2)
Definition: TDatime.h:101
const double machEpsilon
int closeEnough(Scalar1 s1, Scalar2 s2, std::string const &coord, double ticks)
std::vector< XYZVector > makeTestVectors()
double result[121]
Plane3D::Scalar Scalar
Definition: Plane3D.cxx:29
const Int_t n
Definition: legend1.C:16
TRandom3 R
a TMatrixD.
Definition: testIO.cxx:28