stress2D.cxx

Go to the documentation of this file.
00001 // @(#)root/test:$Id: stress2D.cxx 22516 2008-03-07 15:14:26Z moneta $
00002 // Author: Lorenzo Moneta   06/2005 
00003 ///////////////////////////////////////////////////////////////////////////////////
00004 //
00005 //  MathCore Benchmark test suite
00006 //  ==============================
00007 //
00008 //  This program performs tests of ROOT::Math 4D LorentzVectors comparing with TLorentzVector
00009 //  The time performing various vector operations on a collection of vectors is measured. 
00010 //  The benchmarked operations are: 
00011 //      - vector construction from 4 values
00012 //      - construction using a setter method
00013 //      - simple addition of all the vector pairs in the collection 
00014 //      - calculation of deltaR = phi**2 + eta**2 of all vector pairs in the collection            
00015 //      -  two simple analysis: 
00016 //         - the first requires some cut (on pt and eta) and on the invariant mass 
00017 //           of the selected pairs
00018 //         - the second requires just some cut in pt, eta and delta R on all the 
00019 //           vector pair
00020 //      - conversion between XYZTVectors to PtRhoEtaPhi based vectors
00021 //
00022 //   The two analysis demostrates, especially in the second case, the advantage of using 
00023 //   vector based on cylindrical coordinate, given the fact that the time spent in the conversion is 
00024 //   much less than the time spent in the analysis routine. 
00025 //
00026 //   To run the program do: 
00027 //   stressVector          : run standard test with collection of 1000 vectors
00028 //   stressVector  10000   : run with a collection of 10000 vectors
00029 //
00030 ///////////////////////////////////////////////////////////////////////////////////
00031 
00032 
00033 
00034 #include <vector>
00035 #include <iostream>
00036 #include <algorithm>
00037 
00038 #include <assert.h>
00039 #include <map>
00040 
00041 #include "TStopwatch.h"
00042 
00043 #include "TRandom3.h"
00044 #include "TVector2.h"
00045 
00046 #include "Math/Vector2D.h"
00047 #include "Math/Point2D.h"
00048 #include "Math/SVector.h"
00049 
00050 #include <cmath>
00051 
00052 #include "limits"
00053 
00054 #ifdef HAVE_CLHEP
00055 #include "CLHEP/Vector/TwoVector.h"
00056 #endif
00057 
00058 
00059 //#define DEBUG
00060 
00061 using namespace ROOT::Math;
00062 
00063 
00064 
00065 
00066 class VectorTest { 
00067 
00068 private: 
00069 
00070 // global data variables 
00071   std::vector<double> dataX; 
00072   std::vector<double> dataY;  
00073 
00074   size_t nGen;
00075   size_t n2Loop ;
00076 
00077 
00078 public: 
00079   
00080   VectorTest(int n1, int n2) : 
00081     nGen(n1),
00082     n2Loop(n2)
00083   {}
00084     
00085 
00086   
00087 
00088   void print(TStopwatch & time, std::string s) { 
00089     int pr = std::cout.precision(8);
00090     std::cout << s << "\t" << " time = " << time.RealTime() << "\t(sec)\t" 
00091       //    << time.CpuTime() 
00092               << std::endl;
00093     std::cout.precision(pr);
00094   }
00095 
00096     
00097   int check(std::string name, double s1, double s2, double s3, double scale=1) {
00098     double eps = 10*scale*std::numeric_limits<double>::epsilon();
00099     if (  std::fabs(s1-s2) < eps*std::fabs(s1) && std::fabs(s1-s3)  < eps*std::fabs(s1) ) return 0; 
00100     int pr = std::cout.precision(16);
00101     std::cout << s1 << "\t" << s2 <<"\t" << s3 << "\n";
00102     std::cout << "Rel Diff 1-2:\t" <<  (s1-s2)/std::fabs(s1) << " Diff 1-3:\t" <<  (s1-s3)/std::fabs(s1) << std::endl;
00103     std::cout << "Test " << name << " failed !!\n\n"; 
00104     std::cout.precision(pr);
00105     return -1; 
00106   }
00107 
00108 
00109   void genData() { 
00110     int n = nGen;
00111 
00112   // generate 2 d data 
00113     TRandom3 rdm;
00114     for (int i = 0; i < n ; ++ i) { 
00115  
00116       double phi = rdm.Rndm()*3.1415926535897931; 
00117       double r   = rdm.Exp(10.);
00118     // fill vectors 
00119     
00120       Polar2DVector q( r, phi); 
00121       dataX.push_back( q.x() ); 
00122       dataY.push_back( q.y() ); 
00123 
00124     }
00125   }
00126 
00127 
00128 
00129   template <class V> 
00130   void testCreate( std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00131     
00132     int n = dataX.size(); 
00133     dataV.resize(n); 
00134     tim.Start();
00135     for (int i = 0; i < n; ++i) { 
00136       dataV[i] = new V( dataX[i], dataY[i] ); 
00137     }
00138     tim.Stop();
00139     t += tim.RealTime();
00140     print(tim,s);
00141   }
00142 
00143 
00144   template <class V> 
00145   void testCreate2( std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00146     
00147     int n = dataX.size(); 
00148     dataV.resize(n); 
00149     tim.Start();
00150     for (int i = 0; i < n; ++i) { 
00151       dataV[i] = new V(); 
00152       dataV[i]->SetXY(dataX[i], dataY[i] );
00153     }
00154     tim.Stop();
00155     print(tim,s);
00156     t += tim.RealTime();
00157   }
00158   void testCreate2( std::vector<TVector2 *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00159     
00160     int n = dataX.size(); 
00161     dataV.resize(n); 
00162     tim.Start();
00163     for (int i = 0; i < n; ++i) { 
00164       dataV[i] = new TVector2(); 
00165       dataV[i]->Set(dataX[i], dataY[i] );
00166     }
00167     tim.Stop();
00168     print(tim,s);
00169     t += tim.RealTime();
00170   }
00171 #ifdef HAVE_CLHEP
00172   void testCreate2( std::vector<Hep2Vector *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00173     
00174     int n = dataX.size(); 
00175     dataV.resize(n); 
00176     tim.Start();
00177     for (int i = 0; i < n; ++i) { 
00178       dataV[i] = new Hep2Vector(); 
00179       dataV[i]->set(dataX[i], dataY[i] );
00180     }
00181     tim.Stop();
00182     print(tim,s);
00183     t += tim.RealTime();
00184   }
00185 #endif
00186 
00187 
00188   template <class V> 
00189   void clear(  std::vector<V *> & dataV ) { 
00190     for (unsigned int i = 0; i < dataV.size(); ++i) { 
00191       V * p = dataV[i]; 
00192       delete p; 
00193     }
00194     dataV.clear(); 
00195   
00196 }
00197 
00198 template<class V> 
00199 inline double addXY(const V & v) { 
00200    return v.X() + v.Y(); 
00201 }
00202 inline double addXY(const SVector<double,2> & v) { 
00203    return v(0) + v(1); 
00204 }
00205 template<class V> 
00206 inline double getSum(const V & v1, const V & v2) { 
00207    return v1.X()+v1.Y() + v2.X() + v2.Y(); 
00208 }
00209 
00210 inline double getSum(const SVector<double,2> & v1, const SVector<double,2> & v2 ) { 
00211    return v1(0)+v1(1) + v2(0)+v2(1);
00212 }
00213 
00214 template<class V> 
00215 inline double dotProd(const V & v1, const V & v2) { 
00216    return v1 * v2; 
00217 }
00218 
00219 inline double dotProd(const XYVector & v1, const XYVector & v2) { 
00220    return v1.Dot(v2); 
00221 }
00222 
00223 inline double dotProd(const SVector<double,2> & v1, const SVector<double,2> & v2 ) { 
00224    return Dot(v1,v2); 
00225 }
00226 
00227 
00228 #ifdef HAVE_CLHEP
00229 inline double addXY(const Hep2Vector & v) { 
00230    return v.x() + v.y(); 
00231 }
00232 inline double getSum(const Hep2Vector & v1, const Hep2Vector & v2 ) { 
00233    return v1.x() + v1.y() + v2.x() + v2.y(); 
00234 }
00235 #endif
00236 
00237 template <class V>
00238 double testAddition( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00239   unsigned int n = dataV.size();
00240   double tot = 0;
00241   V v0 = *(dataV[0]);
00242   tim.Start(); 
00243   for (unsigned int i = 0; i < n; ++i) { 
00244     V  & v1 = *(dataV[i]); 
00245     V v3 = v1 + v0;
00246     tot += addXY(v3);
00247   }
00248   tim.Stop();
00249   print(tim,s);
00250   t += tim.RealTime();
00251   return tot; 
00252 }  
00253 
00254 template <class V>
00255 double testAddition2( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00256   unsigned int n = dataV.size();
00257   double tot = 0;
00258   V v0 = *(dataV[0]);
00259   tim.Start(); 
00260   for (unsigned int i = 0; i < n; ++i) { 
00261     const V  & v1 = *(dataV[i]); 
00262     v0 += v1;
00263     tot += addXY(v0);
00264   }
00265   tim.Stop();
00266   print(tim,s);
00267   t += tim.RealTime();
00268   return tot; 
00269 }  
00270 
00271 template <class V>
00272 double testAddition3( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00273    //unsigned int n = std::min(n2Loop, dataV.size() );
00274   unsigned int n = dataV.size();
00275   double tot = 0;
00276   V v0 = *(dataV[0]);
00277   tim.Start(); 
00278   for (unsigned int i = 0; i < n; ++i) { 
00279     V  & v1 = *(dataV[i]); 
00280 //     for (unsigned int j = i +1; j < n; ++j) {
00281 //       V & v2 = *(dataV[j]); 
00282 //       tot += getSum(v1,v2);
00283 //     }
00284     tot += getSum(v1,v0);
00285   }
00286   tim.Stop();
00287   print(tim,s);
00288   t += tim.RealTime();
00289   return tot; 
00290 }  
00291 
00292 
00293 template <class V>
00294 double testDotProduct( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00295    //unsigned int n = std::min(n2Loop, dataV.size() );
00296   double tot = 0;
00297   unsigned int n = dataV.size();
00298   V v0 = *(dataV[0]);
00299   tim.Start(); 
00300   for (unsigned int i = 0; i < n; ++i) { 
00301     V  & v1 = *(dataV[i]); 
00302 //     for (unsigned int j = i +1; j < n; ++j) {
00303 //       V & v2 = *(dataV[j]); 
00304 //       tot += dotProd(v1,v2);
00305 //     }
00306     tot += dotProd(v1,v0);
00307   }
00308   tim.Stop();
00309   print(tim,s);
00310   t += tim.RealTime();
00311   return tot; 
00312 }  
00313 
00314 
00315 template <class V>
00316 double testScale( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00317   unsigned int n = dataV.size();
00318   double tot = 0;
00319   tim.Start(); 
00320   for (unsigned int i = 0; i < n; ++i) { 
00321     V  & v1 = *(dataV[i]); 
00322     // scale
00323     V v2 = 2.0*v1;
00324     tot += addXY(v2);
00325   }
00326   tim.Stop();
00327   print(tim,s);
00328   t += tim.RealTime();
00329   return tot; 
00330 }  
00331 
00332 template <class V>
00333 double testScale2( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00334    //unsigned int n = std::min(n2Loop, dataV.size() );
00335    unsigned int n = dataV.size();
00336   double tot = 0;
00337   tim.Start(); 
00338   for (unsigned int i = 0; i < n; ++i) { 
00339     V  & v1 = *(dataV[i]); 
00340     // scale
00341     v1 *= 2.0;
00342     tot += addXY(v1);
00343   }
00344   tim.Stop();
00345   print(tim,s);
00346   t += tim.RealTime();
00347   return tot; 
00348 }  
00349 
00350 template <class V>
00351 double testOperations( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00352    //unsigned int n = std::min(n2Loop, dataV.size() );
00353    // test operations like in CMS
00354    unsigned int n = dataV.size();
00355    double tot = 0;
00356    V v0a = *(dataV[0]);
00357    V v0b = *(dataV[n-1]);
00358    tim.Start(); 
00359    for (unsigned int i = 0; i < n; ++i) { 
00360       V  & v1 = *(dataV[i]); 
00361       //V v2(v1 - dotProd(v1,v0a)*v0b );
00362       double a =  dotProd(v1,v0a); 
00363       V v2(v1 - a*v0b );
00364       tot += addXY(v2);
00365   }
00366   tim.Stop();
00367   print(tim,s);
00368   t += tim.RealTime();
00369   return tot; 
00370 }  
00371 
00372 
00373 template<class V> 
00374 inline double dPhi(V & v1, V& v2) { 
00375    return std::abs(v1.Phi() - v2.Phi() ); 
00376 }
00377 
00378 #ifdef HAVE_CLHEP
00379 inline double dPhi(Hep2Vector & v1, Hep2Vector & v2) { 
00380    return std::abs(v1.phi() - v2.phi() );
00381 }
00382 #endif
00383 
00384 
00385 template <class V>
00386 double testDeltaPhi( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00387   unsigned int n = std::min(n2Loop, dataV.size() );
00388   tim.Start(); 
00389   double tot = 0;
00390   for (unsigned int i = 0; i < n; ++i) { 
00391     V  & v1 = *(dataV[i]); 
00392     for (unsigned int j = i +1; j < n; ++j) {
00393       V & v2 = *(dataV[j]); 
00394       double delta = dPhi(v1,v2);
00395       tot += delta;
00396     }
00397   }
00398   tim.Stop();
00399   print(tim,s);
00400   t += tim.RealTime();
00401   return tot;
00402 }  
00403 
00404 
00405 // template <class V>
00406 // int testAnalysis( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00407 //   int nsel = 0;  
00408 //   int nsel2 = 0; 
00409 //   double deltaMax = 1.;
00410 //   double ptMin = 1.;
00411 //   double etaMax = 3.;
00412   
00413 //   unsigned int n = std::min(n2Loop, dataV.size() );
00414 //   tim.Start(); 
00415 //   for (unsigned int i = 0; i < n; ++i) { 
00416 //     V  & v1 = *(dataV[i]); 
00417 //     if (cutPtEta(v1,ptMin, etaMax) ) { 
00418 //       double delta; 
00419 //       for (unsigned int j = i +1; j < n; ++j) {
00420 //      V & v2 = *(dataV[j]); 
00421 //      delta = VectorUtil::DeltaR(v1,v2);
00422 //      if (delta < deltaMax) { 
00423 //        V v3 = v1 + v2; 
00424 //        nsel++;
00425 //        if ( cutPtEtaAndMass(v3)) 
00426 //          nsel2++; 
00427 //      }
00428         
00429 //       }
00430 //     }
00431 //   }
00432 //   tim.Stop();
00433 //   print(tim,s);
00434 //   //std::cout << nsel << "\n"; 
00435 //   t += tim.RealTime();
00436 //   return nsel2; 
00437 // }  
00438 
00439 
00440 
00441 // template <class V>
00442 // int testAnalysis2( const std::vector<V *> & dataV, TStopwatch & tim, double& t,  std::string s) { 
00443 //   int nsel = 0; 
00444 //   double ptMin = 1.;
00445 //   double etaMax = 3.;
00446 //   unsigned int n = std::min(n2Loop, dataV.size() );
00447 //   tim.Start();
00448 //   //seal::SealTimer t(tim.name(), true, std::cout); 
00449 //   for (unsigned int i = 0; i < n; ++i) { 
00450 //     V  & v1 = *(dataV[i]); 
00451 //     if ( cutPtEta(v1, ptMin, etaMax) ) { 
00452 //       for (unsigned int j = i +1; j < n; ++j) {
00453 //      V & v2 = *(dataV[j]); 
00454 //      if ( VectorUtil::DeltaR(v1,v2) < 0.5) nsel++;
00455 //       }
00456 //     }
00457 //   }
00458 //   tim.Stop();
00459 //   print(tim,s);
00460 //   t += tim.RealTime();
00461 //   return nsel; 
00462 // }  
00463 
00464 
00465 
00466   template <class V1, class V2> 
00467   void testConversion( std::vector<V1 *> & dataV1, std::vector<V2 *> & dataV2, TStopwatch & tim, double& t,  std::string s) { 
00468     
00469     int n = dataX.size(); 
00470     dataV2.resize(n); 
00471     tim.Start();
00472     for (int i = 0; i < n; ++i) { 
00473       dataV2[i] = new V2( *dataV1[i] ); 
00474     }
00475     tim.Stop();
00476     print(tim,s);
00477     t += tim.RealTime();
00478   }
00479 
00480 
00481 
00482   // rotation 
00483   template <class V, class R> 
00484   double testRotation( std::vector<V *> & dataV, double rotAngle, TStopwatch & tim, double& t,  std::string s) { 
00485     
00486     unsigned int n = std::min(n2Loop, dataV.size() );
00487     tim.Start();
00488     double sum = 0;
00489     for (unsigned int i = 0; i < n; ++i) { 
00490       V  & v1 = *(dataV[i]);
00491       V v2 = v1;
00492       v2.Rotate(rotAngle);
00493       sum += addXY(v2);
00494     }
00495     tim.Stop();
00496     print(tim,s);
00497     t += tim.RealTime();
00498     return sum;
00499   }
00500 
00501 
00502 
00503 };
00504 
00505 
00506 
00507 int main(int argc,const char *argv[]) { 
00508 
00509   int ngen = 1000000;
00510   if (argc > 1)  ngen = atoi(argv[1]);
00511   int nloop2 = int(std::sqrt(2.0*ngen)+0.5);
00512   if (argc > 2)  nloop2 = atoi(argv[2]);
00513 
00514   std::cout << "Test with Ngen = " << ngen << " n2loop = " << nloop2 << std::endl;
00515 
00516 
00517   TStopwatch t;
00518 
00519   VectorTest a(ngen,nloop2);
00520 
00521   a.genData(); 
00522 
00523   int niter = 1;
00524   for (int i = 0; i < niter; ++i) { 
00525 
00526 #ifdef DEBUG
00527       std::cout << "iteration " << i << std::endl;
00528 #endif
00529     
00530       double t1 = 0;
00531       double t2 = 0;
00532       double t3 = 0;
00533       double t4 = 0;
00534       double t5 = 0;
00535       double t6 = 0;
00536 
00537       std::vector<TVector2 *> v1;
00538       std::vector<XYVector *> v2;
00539       std::vector<Polar2DVector *> v3;
00540       std::vector<XYPoint *> v4;
00541       std::vector<Polar2DPoint *> v5;
00542       std::vector<SVector<double,2> *> v6;
00543 
00544       a.testCreate     (v1, t, t1,    "creation TVector2          " ); 
00545       a.testCreate     (v2, t, t2,    "creation XYVector          " ); 
00546       a.testCreate     (v3, t, t3,    "creation Polar2DVector     " ); 
00547       a.testCreate     (v4, t, t4,    "creation XYPoint           " ); 
00548       a.testCreate     (v5, t, t5,    "creation Polar2DPoint      " ); 
00549       a.testCreate     (v6, t, t6,    "creation SVector<2>        " ); 
00550 #ifdef HAVE_CLHEP
00551       double t7 = 0;
00552       std::vector<Hep2Vector *> v7;
00553       a.testCreate     (v7, t, t7,        "creation Hep2Vector        " ); 
00554 #endif
00555 
00556       
00557       a.clear(v3);
00558       a.clear(v4);
00559       a.clear(v5);
00560 
00561 #ifdef HAVE_CLHEP
00562       a.clear(v7);
00563 #endif
00564 
00565       std::cout << "\n";
00566       a.testConversion  (v2, v3, t, t3,   "Conversion XY->Polar      " ); 
00567       a.testConversion  (v2, v4, t, t4,   "Conversion XYVec->XYPoint " ); 
00568       a.testConversion  (v2, v5, t, t5,   "Conversion XYVec->PolarP  " ); 
00569 
00570       a.clear(v1);
00571       a.clear(v2);
00572       a.clear(v3); 
00573       a.clear(v4);
00574       a.clear(v5);
00575       std::cout << "\n";
00576 
00577       a.testCreate2     (v1, t, t1,   "creationSet TVector2       " ); 
00578       a.testCreate2     (v2, t, t2,   "creationSet  XYVector      " ); 
00579       a.testCreate2     (v3, t, t3,   "creationSet  Polar2DVector " ); 
00580       a.testCreate2     (v4, t, t4,   "creationSet  XYPoint       " ); 
00581       a.testCreate2     (v5, t, t5,   "creationSet  Polar2DPoint  " ); 
00582 //      a.testCreate2     (v6, t, t6,   "creationSet  Polar2DPoint  " ); 
00583 #ifdef HAVE_CLHEP
00584       a.testCreate2    (v7, t, t7,    "creationSet Hep2Vector     " ); 
00585 #endif
00586 
00587       std::cout << "\n";
00588 
00589       double s1,s2,s3,s4,s5,s6;
00590       s1=a.testAddition   (v1, t, t1, "Addition TVector2          " );  
00591       s2=a.testAddition   (v2, t, t2, "Addition XYVector          "  ); 
00592       s3=a.testAddition   (v3, t, t3, "Addition Polar2DVector     " );       
00593       s6=a.testAddition   (v6, t, t6, "Addition SVector<2>        " );       
00594       a.check("Addition test1",s1,s2,s3);
00595       a.check("Addition test2",s1,s2,s6);
00596 #ifdef HAVE_CLHEP
00597       double s7; 
00598       s7=a.testAddition   (v7, t, t7, "Addition Hep2Vector        " );  
00599       a.check("Addition",s7,s1,s2);
00600 #endif
00601 
00602       double s0 = s2;
00603       std::cout << "\n";
00604 
00605       s1=a.testAddition2   (v1, t, t1, "Addition2 TVector2         " );  
00606       s2=a.testAddition2   (v2, t, t2, "Addition2 XYVector         "  ); 
00607       s3=a.testAddition2   (v3, t, t3, "Addition2 Polar2DVector    " );       
00608       s6=a.testAddition2   (v6, t, t6, "Addition2 SVector<2>       " );       
00609       a.check("Addition2 test1",s1,s2,s3,100);
00610       a.check("Addition2 test2",s1,s2,s6);
00611 #ifdef HAVE_CLHEP
00612       s7=a.testAddition2  (v7, t, t7,  "Addition2 Hep2Vector       " );  
00613       a.check("Addition2 CLHEP",s7,s1,s2);
00614 #endif
00615 
00616       std::cout << "\n";
00617 
00618       s1=a.testAddition3   (v1, t, t1, "Addition3 TVector2         " );  
00619       s2=a.testAddition3   (v2, t, t2, "Addition3 XYVector         "  ); 
00620       s3=a.testAddition3   (v3, t, t3, "Addition3 Polar2DVector    " );       
00621       s6=a.testAddition3   (v6, t, t6, "Addition3 SVector<2>       " );       
00622       a.check("Addition3 test1",s1,s2,s3);
00623       a.check("Addition3 test2",s6,s0,s2);
00624 #ifdef HAVE_CLHEP
00625       s7=a.testAddition3  (v7, t, t7,  "Addition3 Hep2Vector       " );  
00626       a.check("Addition3 CLHEP",s7,s1,s2);
00627 #endif
00628 
00629       std::cout << "\n";
00630 
00631       s1=a.testDotProduct   (v1, t, t1, "DotProduct TVector2        " );  
00632       s2=a.testDotProduct   (v2, t, t2, "DotProduct XYVector        "  ); 
00633 //      s3=a.testDotProduct   (v3, t, t3, "DotProduct Polar2DVector   " );       
00634       s6=a.testDotProduct   (v6, t, t6, "DotProduct SVector<2>      " );       
00635       a.check("DotProduct test1",s1,s2,s6);
00636 //      a.check("DotProduct test2",s6,s1,s2);
00637 #ifdef HAVE_CLHEP
00638       s7=a.testDotProduct   (v7, t, t7, "DotProduct Hep2Vector      " );  
00639       a.check("DotProduct CLHEP",s7,s1,s2);
00640 #endif
00641 
00642 
00643       std::cout << "\n";
00644 
00645       s1=a.testDeltaPhi   (v1, t, t1,  "DeltaPhi   TVector2        " );  
00646       s2=a.testDeltaPhi   (v2, t, t2,  "DeltaPhi   XYVector        " ); 
00647       s3=a.testDeltaPhi   (v3, t, t3,  "DeltaPhi   Polar2DVector   " ); 
00648       s4=a.testDeltaPhi   (v4, t, t4,  "DeltaPhi   XYPoint         "  );  
00649       s5=a.testDeltaPhi   (v5, t, t5,  "DeltaPhi   Polar2DPoint    " ); 
00650 #ifdef WIN32
00651       //windows is bad here 
00652       a.check("DeltaPhi",s1,s2,s3,10);      
00653       a.check("DeltaPhi",s2,s4,s5,10);      
00654 #else
00655       a.check("DeltaPhi",s1,s2,s3);      
00656       a.check("DeltaPhi",s2,s4,s5);      
00657 #endif
00658 #ifdef HAVE_CLHEP
00659       s7=a.testDeltaPhi   (v7, t, t7,  "DeltaPhi   HEP2Vector      " );  
00660       a.check("DeltaPhi",s7,s1,s2);      
00661 #endif 
00662 
00663       std::cout << "\n";
00664       s1=a.testScale   (v1, t, t1, "Scale of TVector2          " );  
00665       s2=a.testScale   (v2, t, t2, "Scale of XYVector          "  ); 
00666       s3=a.testScale   (v3, t, t3, "Scale of Polar2DVector     " ); 
00667       s4=a.testScale   (v4, t, t4, "Scale of XYPoint           "  ); 
00668       s5=a.testScale   (v5, t, t5, "Scale of Polar2DPoint      " ); 
00669       a.check("Scaling",s1,s2,s3);
00670       a.check("Scaling",s2,s4,s5, 10);
00671       s6=a.testScale   (v6, t, t6, "Scale of SVector<2>        " );       
00672       a.check("Scaling SV",s6,s1,s2);
00673 
00674 #ifdef HAVE_CLHEP
00675       s7=a.testScale   (v7, t, t7, "Scale of HEP2Vector        " );  
00676       a.check("Scaling CLHEP",s7,s2,s3);
00677 #endif 
00678 
00679       std::cout << "\n";
00680       s1=a.testScale2   (v1, t, t1, "Scale2 of TVector2          " );  
00681       s2=a.testScale2   (v2, t, t2, "Scale2 of XYVector          "  ); 
00682       s3=a.testScale2   (v3, t, t3, "Scale2 of Polar2DVector     " ); 
00683       s4=a.testScale2   (v4, t, t4, "Scale2 of XYPoint           "  ); 
00684       s5=a.testScale2   (v5, t, t5, "Scale2 of Polar2DPoint      " ); 
00685       a.check("Scaling2",s1,s2,s3);
00686       a.check("Scaling2",s2,s4,s5, 10);
00687       s6=a.testScale2   (v6, t, t6, "Scale2 of SVector<2>        " );       
00688       a.check("Scaling2 SV",s6,s1,s2);
00689 
00690 #ifdef HAVE_CLHEP
00691       s7=a.testScale2   (v7, t, t7, "Scale2 of HEP2Vector        " );  
00692       a.check("Scaling CLHEP",s7,s2,s3);
00693 #endif 
00694 
00695       std::cout << "\n";
00696 
00697       s1=a.testOperations   (v1, t, t1, "Operations of TVector2      " );  
00698       s2=a.testOperations   (v2, t, t2, "Operations of XYVector      "  ); 
00699       s6=a.testOperations   (v6, t, t6, "Operations of SVector<2>    " );  
00700       a.check("Operations testSV",s6,s1,s2);
00701 #ifdef HAVE_CLHEP
00702       s7=a.testOperations   (v7, t, t7, "Operations of HEP2Vector    " );  
00703       a.check("Operations CLHEP",s7,s1,s2);
00704 #endif 
00705 
00706 
00707 
00708 #ifdef LATER
00709 
00710       int n1, n2, n3,n4,n5; 
00711       n1 = a.testAnalysis (v1, t, t1, "Analysis1 TVector2         " ); 
00712       n2 = a.testAnalysis (v2, t, t2, "Analysis1 XYVector         " ); 
00713       n3 = a.testAnalysis (v3, t, t3, "Analysis1 Polar2DVector    " ); 
00714       n4 = a.testAnalysis (v4, t, t4, "Analysis1 XYPoint          "  );  
00715       n5 = a.testAnalysis (v5, t, t5, "Analysis1 Polar2DPoint     " ); 
00716       a.check("Analysis1",n1,n2,n3);      
00717       a.check("Analysis1",n2,n4,n5);      
00718 #ifdef HAVE_CLHEP
00719       int n6;
00720       n6 = a.testAnalysis (v7, t, t7, "Analysis1 HEP2Vector       " ); 
00721       a.check("Analysis2 CLHEP",n6,n1,n2);      
00722 #endif 
00723 
00724 
00725       n1 = a.testAnalysis2 (v1, t, t1, "Analysis2 TVector2        " ); 
00726       n2 = a.testAnalysis2 (v2, t, t2, "Analysis2 XYVector        " ); 
00727       n3 = a.testAnalysis2 (v3, t, t3, "Analysis2 Polar2DVector   " ); 
00728       n4 = a.testAnalysis2 (v4, t, t4, "Analysis2 XYPoint         "  );  
00729       n5 = a.testAnalysis2 (v5, t, t5, "Analysis2 Polar2DPoint    " ); 
00730       a.check("Analysis2",n1,n2,n3);      
00731       a.check("Analysis2",n2,n4,n5);      
00732 #ifdef HAVE_CLHEP
00733       n6 = a.testAnalysis2 (v7, t, t7, "Analysis2 HEP2Vector      " ); 
00734       a.check("Analysis2 CLHEP",n6,n1,n2);      
00735 #endif 
00736 
00737 
00738       n1 = a.testAnalysis3 (v1, t, t1, "Analysis3 TVector2    " ); 
00739       n2 = a.testAnalysis3 (v2, t, t2, "Analysis3 XYVector        " ); 
00740       n3 = a.testAnalysis3 (v3, t, t3, "Analysis3 Polar2DVector   " ); 
00741       n4 = a.testAnalysis3 (v4, t, t4, "Analysis3 XYPoint   "  );  
00742       n5 = a.testAnalysis3 (v5, t, t5, "Analysis3 Polar2DPoint     " ); 
00743       a.check("Analysis3",n1,n2,n3);      
00744       a.check("Analysis3",n2,n4,n5);      
00745 #ifdef HAVE_CLHEP
00746       n6 = a.testAnalysis3 (v7, t, t7,"Analysis3 HEP2Vector        " ); 
00747       a.check("Analysis3 CLHEP",n6,n1,n2);      
00748 #endif 
00749 
00750 #endif
00751 
00752 
00753       // clean all at the end
00754       a.clear(v1); 
00755       a.clear(v2);
00756       a.clear(v3);
00757 
00758       std::cout << std::endl;
00759       std::cout << "Total Time for  TVector2        = " << t1 << "\t(sec)" << std::endl;
00760       std::cout << "Total Time for  XYVector        = " << t2 << "\t(sec)" << std::endl;
00761       std::cout << "Total Time for  Polar2DVector   = " << t3 << "\t(sec)" << std::endl;
00762 #ifdef HAVE_CLHEP
00763       std::cout << "Total Time for  Hep2Vector      = " << t7 << "\t(sec)" << std::endl;
00764 #endif 
00765    }
00766 
00767   //tr.dump(); 
00768 
00769 }
00770 
00771 
00772 

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