HepMC Reference Documentation

HepMC

testSimpleVector.cc

Go to the documentation of this file.
00001 //
00002 // First pass - simply exercise all the vector methods
00003 //
00004 #include <iostream>
00005 
00006 #include "HepMC/SimpleVector.h"
00007 
00008 int main() 
00009 {
00010   // ThreeVector
00011   HepMC::ThreeVector vector3;
00012   HepMC::ThreeVector v3(1.1,2.2,3.3);
00013   HepMC::ThreeVector vx(1.34);
00014   
00015   HepMC::ThreeVector v3copy( v3 );
00016    
00017   int numbad = 0;
00018  
00019   double x = v3.x();
00020   double y = v3.y();
00021   double z = v3.z();
00022   double p2 = v3.perp2();
00023   double pt = v3.perp();
00024   double l = v3.mag();
00025   double r = v3.r();
00026   double th = v3.theta();
00027   double ph = v3.phi();
00028 
00029   vx.set(1., 2., 3.);
00030   vx.setX(1.1);
00031   vx.setY(2.3);
00032   vx.setZ(4.4);
00033   vx.setPhi(0.12);
00034   vx.setTheta(0.54);
00035   
00036   vector3 = v3;
00037 
00038   if( v3 == vector3 ) {
00039   } else {
00040      ++numbad;
00041      std::cout << "vectors v3 and vector3 are different" << std::endl;
00042   }
00043   if( v3 != v3copy ) {
00044      ++numbad;
00045      std::cout << "vectors v3 and v3copy are different" << std::endl;
00046   }
00047  
00048   // FourVector
00049   HepMC::FourVector vector;
00050   HepMC::FourVector v4(1.1,2.2,3.3,4.4);
00051   HepMC::FourVector vt(1.34);
00052   
00053   HepMC::FourVector vectorcopy( v4 );
00054   vector = v4;
00055   
00056   double px = v4.px();
00057   double py = v4.py();
00058   double pz = v4.pz();
00059   double e  = v4.e();
00060    x = vectorcopy.x();
00061    y = vectorcopy.y();
00062    z = vectorcopy.z();
00063   double t = vectorcopy.t();
00064   
00065    p2 = v4.perp2();
00066    pt = v4.perp();
00067    l = v4.mag();
00068    th = v4.theta();
00069    ph = v4.phi();
00070    r = v4.rho();
00071   double masssq1 = v4.m2();
00072   double mass1 = v4.m();
00073   double pr1 = v4.pseudoRapidity();
00074   double eta1 = v4.eta();
00075   double masssq2 = vector.m2();
00076   double mass2 = vector.m();
00077   double pr2 = vector.pseudoRapidity();
00078   double eta2 = vector.eta();
00079 
00080   vt.set(1., 2., 3., 5.5);
00081   vt.setX(1.1);
00082   vt.setY(2.3);
00083   vt.setZ(4.4);
00084   vt.setT(6.5);
00085   vt.setPx(3.1);
00086   vt.setPy(2.2);
00087   vt.setPz(-1.1);
00088   vt.setE(5.4);
00089 
00090   if( px != x ) { 
00091      std::cout << "different X values: " << px << " " << x << std::endl;
00092      ++numbad;
00093   }
00094   if( py != y ) { 
00095      std::cout << "different Y values: " << py << " " << y << std::endl;
00096      ++numbad;
00097   }
00098   if( pz != z ) { 
00099      std::cout << "different Z values: " << pz << " " << z << std::endl;
00100      ++numbad;
00101   }
00102   if( e != t ) { 
00103      std::cout << "different E values: " << e << " " << t << std::endl;
00104      ++numbad;
00105   }
00106   if( masssq1 != masssq2 ) { 
00107      std::cout << "different mass sq values: " << masssq1 << " " << masssq2 << std::endl;
00108      ++numbad;
00109   }
00110   if( mass1 != mass2 ) { 
00111      std::cout << "different mass values: " << mass1 << " " << mass2 << std::endl;
00112      ++numbad;
00113   }
00114   if( pr1 != pr2 ) { 
00115      std::cout << "different pr values: " << pr1 << " " << pr2 << std::endl;
00116      ++numbad;
00117   }
00118   if( eta1 != eta2 ) { 
00119      std::cout << "different eta values: " << eta1 << " " << eta2 << std::endl;
00120      ++numbad;
00121   }
00122   if( v4 == vector ) {
00123   } else {
00124      std::cout << "vectors v and vector are different" << std::endl;
00125      ++numbad;
00126   }
00127   if( v4 != vectorcopy ) {
00128      std::cout << "vectors v and vectorcopy are different" << std::endl;
00129      ++numbad;
00130   }
00131 
00132   return numbad;
00133 }

Generated on Wed Mar 12 13:08:09 2008 for HepMC by  doxygen 1.5.1-3