rotationApplication.cxx

Go to the documentation of this file.
00001 /**********************************************************************
00002   *                                                                    *
00003   * Copyright (c) 2005 , FNAL LCG ROOT MathLib Team                    *
00004   *                                                                    *
00005   *                                                                    *
00006   **********************************************************************/
00007 
00008 // RotationApplication.cpp
00009 //
00010 // Created by:  M. Fischler, Aug 10, 2005
00011 //
00012 // Tests that each Rotation produces correct results when applied to 
00013 // each form of vector in each oordinate system, and incidently that products
00014 // of rotations work properly.
00015 //
00016 // The strategy is to build up sequences of rotations about the X, Y, and Z 
00017 // axes, such that we can easily determine the correct vector answer.
00018 //
00019 // =================================================================
00020 
00021 #include "Math/GenVector/DisplacementVector3D.h"
00022 #include "Math/GenVector/PositionVector3D.h"
00023 #include "Math/GenVector/Cartesian3D.h"
00024 #include "Math/GenVector/Polar3D.h"
00025 #include "Math/GenVector/CylindricalEta3D.h"
00026 #include "Math/GenVector/LorentzVector.h"
00027 #include "Math/GenVector/Rotation3D.h"
00028 #include "Math/GenVector/AxisAngle.h"
00029 #include "Math/GenVector/EulerAngles.h"
00030 #include "Math/GenVector/Quaternion.h"
00031 #include "Math/GenVector/RotationZYX.h"
00032 #include "Math/GenVector/RotationX.h"
00033 #include "Math/GenVector/RotationY.h"
00034 #include "Math/GenVector/RotationZ.h"
00035 
00036 #include "Math/GenVector/VectorUtil.h"
00037 
00038 #include "Math/Vector3Dfwd.h"
00039 
00040 #include "CoordinateTraits.h"
00041 #include "RotationTraits.h"
00042 
00043 #include <iostream>
00044 #include <limits>
00045 #include <cmath>
00046 #include <vector>
00047 
00048 using std::sin;
00049 using std::cos;
00050 
00051 //#define TRACE2
00052 //#define TRACE1
00053 //#define DEBUG
00054 
00055 using namespace ROOT::Math;
00056 
00057 #ifndef __CINT__
00058 
00059 template <typename T1, typename T2 > 
00060 struct Precision { 
00061   enum { result = std::numeric_limits<T1>::digits <= std::numeric_limits<T2>::digits   }; 
00062 }; 
00063 
00064 template <typename T1, typename T2, bool>
00065 struct LessPreciseType {
00066   typedef T1 type;
00067 };
00068 template <typename T1, typename T2>
00069 struct LessPreciseType<T1, T2, false> {
00070   typedef T2 type;
00071 };
00072 
00073 
00074 const double machEpsilon = pow (2.0, -52.0);
00075 
00076 template <typename Scalar1, typename Scalar2>
00077 int
00078 closeEnough (Scalar1 s1, Scalar2 s2, std::string const & coord, double ticks) {
00079   int ret = 0;
00080   int pr = std::cout.precision(18);
00081   Scalar1 eps1 = std::numeric_limits<Scalar1>::epsilon();
00082   Scalar2 eps2 = std::numeric_limits<Scalar2>::epsilon();
00083   typedef typename LessPreciseType<Scalar1, Scalar2,Precision<Scalar1,Scalar2>::result>::type Scalar;
00084   Scalar epsilon = (eps1 >= eps2) ? eps1 : eps2;
00085   Scalar ss1 (s1);
00086   Scalar ss2 (s2);
00087   Scalar diff = ss1 - ss2;
00088   if (diff < 0) diff = -diff;
00089   if ( diff > ticks*epsilon ) {
00090     ret=3;
00091     std::cout << "\n\n????????\n\nAbsolute discrepancy in " << coord << "(): "
00092               << ss1 << " != " << ss2 << "\n"
00093               << "   (Allowed discrepancy is " << ticks
00094               << " ticks = " << ticks*epsilon
00095               << ")\nDifference is " << diff/epsilon << " ticks\n";
00096   }
00097   std::cout.precision (pr);
00098   return ret;
00099 }
00100 
00101 template <class V1, class V2>
00102 int compare3D (const V1 & v1, const V2 & v2, double ticks) {
00103   int ret =0;
00104   typedef typename V1::CoordinateType CoordType1;
00105   typedef typename V2::CoordinateType CoordType2;
00106 
00107   ret |= closeEnough ( v1.x(),     v2.x(),     "x"     ,ticks);
00108   ret |= closeEnough ( v1.y(),     v2.y(),     "y"     ,ticks);
00109   ret |= closeEnough ( v1.z(),     v2.z(),     "z"     ,ticks);
00110  
00111   if (ret != 0) {
00112     std::cout << "Discrepancy detected (see above) is between:\n  "
00113               << CoordinateTraits<CoordType1>::name() << " and\n  "
00114               << CoordinateTraits<CoordType2>::name() << "\n"
00115               << "with v = (" << v1.x() << ", " << v1.y() << ", " << v1.z()
00116               << ")\nv1 is " << v1 
00117               << "\nv2 is " << v2 << "\n\n";
00118   }
00119 
00120   return ret;
00121 }
00122 
00123 template <class V> struct correctedTicks {
00124   double operator()(double ticks, const V& /*v */ , const XYZVector & /* ans */) 
00125   { 
00126     return ticks; 
00127   }
00128 };
00129 
00130 double correctTicks (double ticks,double z,double r) {
00131   double e = ticks*std::fabs( z*z / (r*r-z*z) );
00132   if (e < ticks) return ticks;
00133   return e;
00134 }
00135 
00136 template<> struct
00137 correctedTicks< DisplacementVector3D < CylindricalEta3D<double> > > {
00138   double operator()(double ticks, 
00139         const DisplacementVector3D< CylindricalEta3D<double> >& v,
00140         const XYZVector & ans) {
00141   double t1 = correctTicks (ticks,   v.z(),   v.r());
00142   double t2 = correctTicks (ticks, ans.z(), ans.r());
00143   return t1 > t2 ? t1 : t2;
00144   }
00145 };
00146   
00147 template<> struct
00148 correctedTicks< PositionVector3D < CylindricalEta3D<double> > > {
00149   double operator()(double ticks, 
00150         const PositionVector3D< CylindricalEta3D<double> >& v,
00151         const XYZVector & ans) {
00152   double t1 = correctTicks (ticks,   v.z(),   v.r());
00153   double t2 = correctTicks (ticks, ans.z(), ans.r());
00154   return t1 > t2 ? t1 : t2;
00155   }
00156 };
00157   
00158 template <class R, class V>
00159 int testApplication(const R& r,const V& v,const XYZVector &answer,double t) {
00160 
00161   typedef typename V::CoordinateType CoordType;
00162 
00163   int ret = 0;
00164   correctedTicks<V> ct;
00165   double ticks = ct(t, v, answer);
00166   #ifdef DEBUG
00167   std::cout <<">>>>> Testing application of " 
00168             << RotationTraits<R>::name() << " " << r << "\non " 
00169             << CoordinateTraits<typename V::CoordinateType>::name() << 
00170             v << " ticks = " << ticks; 
00171   #endif
00172         #ifdef TRACE2
00173         std::cout << "  about to do V rv = r(v) - \n";
00174         #endif
00175   V rv = r(v);
00176         #ifdef TRACE2
00177         std::cout << "ok ";
00178         #endif
00179         // comparison here should be == but need to use 10 ticks to be sure for 32 bits machines
00180         // when results are flushed in memory and approximated
00181         if ( compare3D(rv, r*v, 10 ) != 0) { 
00182      std::cout << "Inconsistency between R(v) and R*v for R = " 
00183                << RotationTraits<R>::name() << " " << r 
00184                << "\nacting on "  << CoordinateTraits<CoordType>::name() << v << "\n";
00185      ret |= 9;
00186   }
00187         #ifdef TRACE2
00188         std::cout << "+ also did rv != r*v ";
00189         #endif
00190   if ( closeEnough(v.r(), rv.r(), "r", ticks) != 0 ) {
00191     std::cout << "Radius change  between R(v) and R*v for R = "
00192               << RotationTraits<R>::name() << " " << r 
00193               << "\nacting on "   
00194               << CoordinateTraits<CoordType>::name()
00195               << v << "\n";
00196     ret |= 17;
00197   }  
00198         #ifdef TRACE2
00199         std::cout << "\n---- about to do compare3D ----";
00200         #endif
00201   ret |= compare3D (rv, answer, ticks);
00202         #ifdef TRACE2
00203         std::cout << " done \n";
00204         #endif
00205   #ifdef DEBUG
00206   if (ret == 0) std::cout << " OK\n";
00207   #endif 
00208   return ret;
00209 }
00210 
00211 
00212 XYZVector rxv ( double phi, XYZVector v ) {
00213   double c = cos(phi);
00214   double s = sin(phi);
00215   return XYZVector ( v.x(), c*v.y()-s*v.z(), s*v.y()+c*v.z() );
00216 }
00217 
00218 XYZVector ryv ( double phi, XYZVector v ) {
00219   double c = cos(phi);
00220   double s = sin(phi);
00221   return XYZVector ( c*v.x()+s*v.z(), v.y(), -s*v.x()+c*v.z() );
00222 }
00223 
00224 XYZVector rzv ( double phi, XYZVector v ) {
00225   double c = cos(phi);
00226   double s = sin(phi);
00227   return XYZVector ( c*v.x()-s*v.y(), s*v.x()+c*v.y(), v.z() );
00228 }
00229 
00230 enum XYZ { X, Y, Z } ;
00231 
00232 struct TestRotation {
00233   std::vector<XYZ> xyz;
00234   std::vector<double> phi;
00235   TestRotation (std::vector<XYZ> const & xyz_, std::vector<double> const & phi_)
00236         : xyz(xyz_), phi(phi_) {}
00237 };
00238 
00239 
00240 Rotation3D rrr (TestRotation const & t) {
00241         #ifdef TRACE1
00242         std::cout << "---- rrr ----";
00243         #endif
00244   Rotation3D r;
00245   for (unsigned int i=0; i<t.xyz.size(); ++i) {
00246     switch ( t.xyz[i] ) {
00247       case X:  
00248         r = r*RotationX(t.phi[i]);
00249         break;
00250       case Y:
00251         r = r*RotationY(t.phi[i]);
00252         break;
00253       case Z:
00254         r = r*RotationZ(t.phi[i]);
00255         break;
00256     }
00257   }
00258         #ifdef TRACE1
00259         std::cout << " done\n";
00260         #endif 
00261   return r;
00262 }
00263 
00264 XYZVector ans ( TestRotation const & t, XYZVector const & v_in) {
00265   XYZVector v(v_in);
00266   for (int i=t.xyz.size()-1; i >= 0; --i) {
00267     switch ( t.xyz[i] ) {
00268       case X:  
00269         v = rxv ( t.phi[i],v );
00270         break;
00271       case Y:
00272         v = ryv ( t.phi[i],v );
00273         break;
00274       case Z:
00275         v = rzv ( t.phi[i],v );
00276         break;
00277     }
00278   }
00279   return v;
00280 }
00281 
00282 const double pi = 3.1415926535897932385;
00283 
00284 std::vector<TestRotation> 
00285 makeTestRotations () {
00286         #ifdef TRACE1
00287         std::cout << "---- makeTestRotations ----";
00288         #endif
00289   std::vector<TestRotation> t;  
00290   std::vector<XYZ>    xyz;
00291   std::vector<double> phi;
00292   
00293 
00294 
00295   xyz.clear();      phi.clear();
00296   xyz.push_back(X); phi.push_back( pi/2 );
00297   t.push_back(TestRotation(xyz,phi));
00298  
00299   xyz.clear();      phi.clear();
00300   xyz.push_back(Y); phi.push_back( pi/2 );
00301   t.push_back(TestRotation(xyz,phi));
00302  
00303   xyz.clear();      phi.clear();
00304   xyz.push_back(Z); phi.push_back( pi/2 );
00305   t.push_back(TestRotation(xyz,phi));
00306 
00307   xyz.clear();      phi.clear();
00308   xyz.push_back(X); phi.push_back( -pi/6 );
00309   t.push_back(TestRotation(xyz,phi));
00310 
00311   xyz.clear();      phi.clear();
00312   xyz.push_back(Y); phi.push_back( pi/6 );
00313   t.push_back(TestRotation(xyz,phi));
00314  
00315   xyz.clear();      phi.clear();
00316   xyz.push_back(Z); phi.push_back( pi/3 );
00317   t.push_back(TestRotation(xyz,phi));
00318 
00319   xyz.clear();      phi.clear();
00320   xyz.push_back(X); phi.push_back( -pi/6 );
00321   xyz.push_back(Y); phi.push_back(  pi/3 );
00322   t.push_back(TestRotation(xyz,phi));
00323 
00324   xyz.clear();      phi.clear();
00325   xyz.push_back(X); phi.push_back( -pi/6 );
00326   xyz.push_back(Y); phi.push_back(  pi/4 );
00327   xyz.push_back(Z); phi.push_back( -pi/5 );
00328   t.push_back(TestRotation(xyz,phi));
00329 
00330   xyz.clear();      phi.clear();
00331   xyz.push_back(Y); phi.push_back( pi );
00332   xyz.push_back(X); phi.push_back( -pi/2 );
00333   xyz.push_back(Z); phi.push_back( -pi/1.5 );
00334   xyz.push_back(Y); phi.push_back( -pi/3 );
00335   t.push_back(TestRotation(xyz,phi));
00336 
00337   xyz.clear();      phi.clear();
00338   xyz.push_back(Z); phi.push_back(  1.3 );
00339   xyz.push_back(Y); phi.push_back( -1.1 );
00340   xyz.push_back(X); phi.push_back(  0.4 );
00341   xyz.push_back(Y); phi.push_back(  0.7 );
00342   t.push_back(TestRotation(xyz,phi));
00343 
00344   xyz.clear();      phi.clear();
00345   xyz.push_back(X); phi.push_back(  1.3 );
00346   xyz.push_back(Z); phi.push_back( -1.1 );
00347   xyz.push_back(Y); phi.push_back(  0.4 );
00348   xyz.push_back(Z); phi.push_back(  0.7 );
00349   t.push_back(TestRotation(xyz,phi));
00350 
00351   xyz.clear();      phi.clear();
00352   xyz.push_back(Y); phi.push_back(  1.3 );
00353   xyz.push_back(X); phi.push_back( -1.1 );
00354   xyz.push_back(Z); phi.push_back(  0.4 );
00355   xyz.push_back(X); phi.push_back(  0.7 );
00356   t.push_back(TestRotation(xyz,phi));
00357 
00358   xyz.clear();      phi.clear();
00359   xyz.push_back(Z); phi.push_back(  .03 );
00360   xyz.push_back(Y); phi.push_back( -.05 );
00361   xyz.push_back(X); phi.push_back(  0.04 );
00362   xyz.push_back(Y); phi.push_back(  0.07 );
00363   xyz.push_back(Z); phi.push_back( -0.02 );
00364   t.push_back(TestRotation(xyz,phi));
00365 
00366         #ifdef TRACE1
00367         std::cout << " done\n";
00368         #endif
00369   return t;
00370 }
00371 
00372 std::vector<XYZVector> makeTestVectors () {
00373         #ifdef TRACE1
00374         std::cout << "---- makeTestVectors ----";
00375         #endif
00376   std::vector<XYZVector> vs;
00377   vs.push_back(XYZVector ( 1, 0, 0 ));
00378   vs.push_back(XYZVector ( 0, 1, 0 ));
00379   vs.push_back(XYZVector ( 0, 0, 1 ));
00380   vs.push_back(XYZVector ( -1, 0, 0 ));
00381   vs.push_back(XYZVector ( 0, -1, 0 ));
00382   vs.push_back(XYZVector ( 0, 0, -1 ));
00383   vs.push_back(XYZVector ( 1, 2, 3 ));
00384   vs.push_back(XYZVector ( 2, -1, 3 ));
00385   vs.push_back(XYZVector ( -3, 1, -2 ));
00386   vs.push_back(XYZVector ( 0, .00001, -2 ));
00387 
00388         #ifdef TRACE1
00389         std::cout << " done\n";
00390         #endif
00391   return vs;
00392 }
00393 
00394 template <class R, class V>
00395 int doTest (TestRotation const & testRotation, XYZVector const & testVector,
00396                 double ticks) {
00397         #ifdef TRACE1
00398         std::cout << "---- doTest ----";
00399         #endif
00400   int ret = 0;
00401   R r ( rrr(testRotation) );
00402   V v(testVector);
00403   XYZVector rv = ans (testRotation, testVector);
00404   ret |= testApplication (r, v, rv, ticks);  
00405         #ifdef TRACE1
00406         std::cout << " done\n";
00407         #endif
00408 
00409         if (ret == 0) std::cout << ".";
00410 
00411   return ret;
00412 }
00413 
00414 template <class R, class C>
00415 int doTestL (TestRotation const & testRotation, XYZVector const & testVector,
00416                 double ticks) {
00417         #ifdef TRACE1
00418         std::cout << "---- doTestL ----";
00419         #endif
00420   int ret = 0;
00421   R r ( rrr(testRotation) );
00422   LorentzVector<C> v;
00423   double x = testVector.X();
00424   double y = testVector.Y();
00425   double z = testVector.Z();
00426   double t = std::sqrt (x*x + y*y + z*z + 1);
00427   v.SetXYZT ( x, y, z, t );  
00428   XYZVector rv = ans (testRotation, testVector);
00429   ret |= testApplication (r, v, rv, ticks); 
00430   LorentzVector<C> rv2 = r(v);
00431   ret |= closeEnough (t, rv2.E(), "t", ticks); 
00432         #ifdef TRACE1
00433         std::cout << " done\n";
00434         #endif
00435   return ret;
00436 }
00437 
00438 struct ForeignVector {
00439   typedef Cartesian3D<> CoordinateType;
00440   XYZVector v;
00441   template <class V> 
00442   explicit ForeignVector (V const & v_) : v(v_) {}
00443   ForeignVector (double xx, double yy, double zz) : v(xx,yy,zz) {}
00444   double x() const { return v.x(); }
00445   double y() const { return v.y(); }
00446   double z() const { return v.z(); }
00447   double r() const { return v.r(); }
00448   bool operator==(ForeignVector const & rhs) {return v == rhs.v;}
00449   bool operator!=(ForeignVector const & rhs) {return v != rhs.v;}
00450 };
00451 std::ostream & operator<< (std::ostream& os, const ForeignVector& v) {
00452   return os << v.v;
00453 }
00454 
00455 
00456 template <class R>
00457 int doTestOfR (TestRotation const & testRotation, XYZVector const & testVector){
00458         #ifdef TRACE1
00459         std::cout << "---- doTestofR ----\n";
00460         #endif
00461   int ret = 0;
00462   const double ticks = 100;  // move from 32 to 100 
00463    #ifdef DEBUG
00464   std::cout << ">>>>> DisplacementVector3D< Cartesian3D<double> \n";
00465   #endif
00466   ret |= doTest <R, DisplacementVector3D< Cartesian3D<double> > >
00467                 (testRotation,testVector,ticks);
00468   #ifdef DEBUG
00469   std::cout << ">>>>> DisplacementVector3D< Polar3D<double> \n";
00470   #endif
00471   ret |= doTest <R, DisplacementVector3D< Polar3D<double> > >
00472                 (testRotation,testVector,ticks);
00473   #ifdef DEBUG
00474   std::cout << ">>>>> DisplacementVector3D< CylindricalEta3D<double> \n";
00475   #endif
00476   ret |= doTest <R, DisplacementVector3D< CylindricalEta3D<double> > >
00477                 (testRotation,testVector,ticks);
00478   #ifdef DEBUG
00479   std::cout << ">>>>> PositionVector3D< Cartesian3D<double> \n";
00480   #endif
00481   ret |= doTest <R, PositionVector3D< Cartesian3D<double> > >
00482                 (testRotation,testVector,ticks);
00483   #ifdef DEBUG
00484   std::cout << ">>>>> PositionVector3D< Polar3D<double> \n";
00485   #endif
00486   ret |= doTest <R, PositionVector3D< Polar3D<double> > >
00487                 (testRotation,testVector,ticks);
00488   #ifdef DEBUG
00489   std::cout << ">>>>> PositionVector3D< CylindricalEta3D<double> \n";
00490   #endif
00491   ret |= doTest <R, PositionVector3D< CylindricalEta3D<double> > >
00492                 (testRotation,testVector,ticks);
00493   #ifdef DEBUG
00494   std::cout << ">>>>> ForeignVector\n";
00495   #endif
00496   ret |= doTest <R, ForeignVector >
00497                 (testRotation,testVector,ticks);
00498   #ifdef DEBUG
00499   std::cout << ">>>>> LorentzVector<PxPyPzE4D<double> >\n";
00500   #endif
00501   ret |= doTestL <R, PxPyPzE4D<double> >
00502                 (testRotation,testVector,ticks);
00503         #ifdef TRACE1
00504         std::cout << " ---- doTestofR ---- done\n";
00505         #endif
00506 
00507         if (ret == 0) std::cout << ".";
00508 
00509   // TODO - other 4D coordinates
00510 
00511   return ret;
00512 }
00513 
00514 
00515 int exerciseTestCase (TestRotation const & testRotation, 
00516                       XYZVector const & testVector)      
00517 {
00518 
00519   std::cout << ">>>>> Rotation Tests of " << testVector << "\t\t: " ; 
00520 
00521         #ifdef TRACE1
00522         std::cout << "---- exerciseTestCase ----";
00523         #endif
00524   int ret = 0;
00525   ret |= doTestOfR <Rotation3D>  (testRotation,testVector);
00526   ret |= doTestOfR <AxisAngle>   (testRotation,testVector);
00527   ret |= doTestOfR <EulerAngles> (testRotation,testVector);
00528   ret |= doTestOfR <Quaternion>  (testRotation,testVector);
00529   ret |= doTestOfR <RotationZYX> (testRotation,testVector);
00530         #ifdef TRACE1
00531         std::cout << " done\n";
00532         #endif
00533 
00534   if (ret == 0) 
00535     std::cout << "\t OK\n"; 
00536   else {
00537     std::cout << "\t Failed!\n "; 
00538     std::cerr << "\n>>>>> Rotation Tests of " << testVector << "\t\t:\t FAILED \n";
00539   }
00540 
00541   return ret;
00542 }
00543 
00544 // ===== Axial test section =============
00545 
00546 template <class R, class V>
00547 int doTestA (XYZVector const & testVector, double ticks) {
00548         #ifdef TRACE1
00549         std::cout << "---- doTestA ----";
00550         #endif
00551   int ret = 0;
00552   V v(testVector);
00553   XYZVector rv;
00554   for (double angle = -4.0;  angle < 4.0; angle += .15) {
00555     RotationX rx (angle);
00556     rv = rxv (angle, testVector);
00557     ret |= testApplication (rx, v, rv, ticks);  
00558     RotationY ry (angle);
00559     rv = ryv (angle, testVector);
00560     ret |= testApplication (ry, v, rv, ticks);  
00561     RotationZ rz (angle);
00562     rv = rzv (angle, testVector);
00563     ret |= testApplication (rz, v, rv, ticks);  
00564   }
00565         #ifdef TRACE1
00566         std::cout << " done\n";
00567         #endif
00568         if (ret == 0) std::cout << ".";
00569   return ret;
00570 }
00571 
00572 template <class R, class C>
00573 int doTestLA (XYZVector const & testVector, double ticks) {
00574         #ifdef TRACE1
00575         std::cout << "---- doTestLA ----";
00576         #endif
00577   int ret = 0;
00578   LorentzVector<C> v;
00579   double x = testVector.X();
00580   double y = testVector.Y();
00581   double z = testVector.Z();
00582   double t = std::sqrt (x*x + y*y + z*z + 1);
00583   v.SetXYZT ( x, y, z, t );  
00584   XYZVector rv;
00585   for (double angle = -4.0;  angle < 4.0; angle += .15) {
00586     //std::cout << "\n============ angle is " << angle << "\n";
00587     RotationX rx (angle);
00588     rv = rxv (angle, testVector);
00589     ret |= testApplication (rx, v, rv, ticks);  
00590     RotationY ry (angle);
00591     rv = ryv (angle, testVector);
00592     ret |= testApplication (ry, v, rv, ticks);  
00593     RotationZ rz (angle);
00594     rv = rzv (angle, testVector);
00595     ret |= testApplication (rz, v, rv, ticks);  
00596   }
00597         #ifdef TRACE1
00598         std::cout << " done\n";
00599         #endif
00600 
00601         if (ret == 0) std::cout << ".";
00602   return ret;
00603 }
00604 
00605 template <class R>
00606 int doTestOfAxial (XYZVector const & testVector){
00607         #ifdef TRACE1
00608         std::cout << "---- doTestOfAxial ----\n";
00609         #endif
00610   int ret = 0;
00611   const double ticks = 32;
00612   #ifdef DEBUG
00613   std::cout << ">>>>> DisplacementVector3D< Cartesian3D<double> \n";
00614   #endif
00615   ret |= doTestA <R, DisplacementVector3D< Cartesian3D<double> > >
00616                 (testVector,ticks);
00617   #ifdef DEBUG
00618   std::cout << ">>>>> DisplacementVector3D< Polar3D<double> \n";
00619   #endif
00620   ret |= doTestA <R, DisplacementVector3D< Polar3D<double> > >
00621                 (testVector,ticks);
00622   #ifdef DEBUG
00623   std::cout << ">>>>> DisplacementVector3D< CylindricalEta3D<double> \n";
00624   #endif
00625   ret |= doTestA <R, DisplacementVector3D< CylindricalEta3D<double> > >
00626                 (testVector,ticks);
00627   #ifdef DEBUG
00628   std::cout << ">>>>> PositionVector3D< Cartesian3D<double> \n";
00629   #endif
00630   ret |= doTestA <R, PositionVector3D< Cartesian3D<double> > >
00631                 (testVector,ticks);
00632   #ifdef DEBUG
00633   std::cout << ">>>>> PositionVector3D< Polar3D<double> \n";
00634   #endif
00635   ret |= doTestA <R, PositionVector3D< Polar3D<double> > > (testVector,ticks);
00636   #ifdef DEBUG
00637   std::cout << ">>>>> PositionVector3D< CylindricalEta3D<double> \n";
00638   #endif
00639   ret |= doTestA <R, PositionVector3D< CylindricalEta3D<double> > >
00640                 (testVector,ticks);
00641   #ifdef DEBUG
00642   std::cout << ">>>>> ForeignVector\n";
00643   #endif
00644   ret |= doTestA <R, ForeignVector > (testVector,ticks);
00645   #ifdef DEBUG
00646   std::cout << ">>>>> LorentzVector<PxPyPzE4D<double> >\n";
00647   #endif
00648   ret |= doTestLA <R, PxPyPzE4D<double> > (testVector,ticks);
00649         #ifdef TRACE1
00650         std::cout << " ---- doTestofR ---- done\n";
00651         #endif
00652   // TODO - other 4D coordinates
00653 
00654         if (ret == 0) std::cout << ".";
00655 
00656    return ret;
00657 }
00658 
00659 int exerciseAxialTest (XYZVector const & testVector)      
00660 {
00661 
00662         #ifdef TRACE1
00663         std::cout << "---- exerciseAxialTest ----";
00664         #endif
00665 
00666         std::cout << ">>>>> Axial Rotation Tests of " << testVector << "\t\t: "; 
00667 
00668   int ret = 0;
00669   ret |= doTestOfAxial <RotationX> (testVector);
00670   ret |= doTestOfAxial <RotationY> (testVector);
00671   ret |= doTestOfAxial <RotationZ> (testVector);
00672         #ifdef TRACE1
00673         std::cout << " done\n";
00674         #endif
00675 
00676   if (ret == 0) 
00677     std::cout << "\t OK\n"; 
00678   else {
00679     std::cout << "\t Failed!\n "; 
00680     std::cerr << "\n>>>>> Axial Rotation Tests of " << testVector << "\t\t:\t FAILED \n";
00681   }
00682 
00683   return ret;
00684 }
00685 
00686 
00687 #endif // endif on __CINT__
00688 
00689 // ======================================
00690 
00691 
00692 int rotationApplication () {
00693   int ret = 0;
00694   std::vector<TestRotation> testRotations = makeTestRotations();
00695   std::vector<XYZVector>    testVectors   = makeTestVectors();
00696   for ( std::vector<TestRotation>::const_iterator n =  testRotations.begin();
00697         n !=  testRotations.end(); ++n ) {
00698     for ( std::vector<XYZVector>::const_iterator m =  testVectors.begin();
00699         m !=  testVectors.end(); ++m ) {
00700       ret |= exerciseTestCase (*n, *m);
00701     }
00702   }
00703   for ( std::vector<XYZVector>::const_iterator vp =  testVectors.begin();
00704         vp !=  testVectors.end(); ++vp ) {
00705     ret |= exerciseAxialTest (*vp);
00706   }
00707 
00708   return ret;
00709 }
00710 
00711 int main() { 
00712    int ret =  rotationApplication();
00713    if (ret)  std::cerr << "test FAILED !!! " << std::endl; 
00714    else   std::cout << "test OK " << std::endl;
00715    return ret; 
00716 }

Generated on Tue Jul 5 14:33:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1