CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

testSubscripts.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: testSubscripts.cc,v 1.2 2003/08/13 20:00:14 garren Exp $
3 // ---------------------------------------------------------------------------
4 //
5 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
6 //
7 // This is a small program for testing of subscriping in the Vector module.
8 //
9 
10 #include <assert.h>
11 #include "CLHEP/Units/GlobalSystemOfUnits.h" // to see shadowing problems
12 #include "CLHEP/Vector/ThreeVector.h"
13 #include "CLHEP/Vector/Rotation.h"
14 #include "CLHEP/Vector/LorentzVector.h"
15 #include "CLHEP/Vector/LorentzRotation.h"
16 
17 using namespace CLHEP;
18 
19 typedef Hep3Vector Vec3;
21 
22 class Rot3 : public HepRotation {
23 public:
24  void setMatrix(double xx1, double xy1, double xz1,
25  double yx1, double yy1, double yz1,
26  double zx1, double zy1, double zz1) {
27  rxx = xx1; rxy = xy1; rxz = xz1;
28  ryx = yx1; ryy = yy1; ryz = yz1;
29  rzx = zx1; rzy = zy1; rzz = zz1;
30  }
31 };
32 
33 class Rot4 : public HepLorentzRotation {
34 public:
35  void setMatrix(double xx1, double xy1, double xz1, double xt1,
36  double yx1, double yy1, double yz1, double yt1,
37  double zx1, double zy1, double zz1, double zt1,
38  double tx1, double ty1, double tz1, double tt1) {
39  mxx = xx1; mxy = xy1; mxz = xz1; mxt = xt1;
40  myx = yx1; myy = yy1; myz = yz1; myt = yt1;
41  mzx = zx1; mzy = zy1; mzz = zz1; mzt = zt1;
42  mtx = tx1; mty = ty1; mtz = tz1; mtt = tt1;
43  }
44 };
45 
46 int main() {
47 
48  // Test ThreeVector subscripting
49 
50  Vec3 V3;
51  const Vec3 ConstV3(1.,2.,3.);
52 
53  V3[0] = ConstV3[0];
54  V3[1] = ConstV3[1];
55  V3[2] = ConstV3[2];
56  assert(V3 == ConstV3);
57 
58  V3(0) = ConstV3(2);
59  V3(1) = ConstV3(1);
60  V3(2) = ConstV3(0);
61  assert(V3 == Hep3Vector(3.,2.,1.));
62 
63  // Test LorentzVector subscripting
64 
65  Vec4 V4;
66  const Vec4 ConstV4(1.,2.,3.,4);
67 
68  V4[0] = ConstV4[0];
69  V4[1] = ConstV4[1];
70  V4[2] = ConstV4[2];
71  V4[3] = ConstV4[3];
72  assert(V4 == ConstV4);
73 
74  V4(0) = ConstV4(3);
75  V4(1) = ConstV4(2);
76  V4(2) = ConstV4(1);
77  V4(3) = ConstV4(0);
78  assert(V4 == HepLorentzVector(4.,3.,2.,1.));
79 
80  // Test Rotation subscripting
81 
82  int i, j, k;
83  Rot3 R3;
84 
85  R3.setMatrix(1.,2.,3.,4.,5.,6.,7.,8.,9.);
86 
87  k = 1;
88  for(i=0; i<3; i++) {
89  for(j=0; j<3; j++) {
90  assert(R3(i,j) == double(k));
91  assert(R3[i][j] == double(k));
92  k++;
93  }
94  }
95 
96  // Test LorentzRotation subscripting
97 
98  Rot4 R4;
99  R4.setMatrix(1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.);
100 
101  k = 1;
102  for(i=0; i<4; i++) {
103  for(j=0; j<4; j++) {
104  assert(R4(i,j) == double(k));
105  assert(R4[i][j] == double(k));
106  k++;
107  }
108  }
109 
110  return 0;
111 }
Rot3
Definition: testSubscripts.cc:22
main
int main()
Definition: testSubscripts.cc:46
CLHEP::HepRotation
Definition: Geometry/CLHEP/Vector/Rotation.h:48
CLHEP::HepLorentzRotation
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:54
CLHEP
Definition: ClhepVersion.h:13
Hep3Vector
Issues Concerning the PhysicsVectors CLHEP Vector Merge The merge of ZOOM PhysicsVdectors and the CLHEP Vector package is completed The purpose of this document is to list the major issues that affected the merge of these and where relevant describe the resolutions More detailed documents describe more minor issues General Approach As agreed at the June CLHEP the approach is to combine the features of each ZOOM class with the corresponding CLHEP class expanding the interface to create a single lingua franca of what a Hep3Vector(for example) means. We are not forming SpaceVector as an class derived from Hep3Vector and enhancing it in that way. Another rule imposed by the agreement is to avoid using the Exceptions package(even though that will later go into CLHEP for other uses). A desirable goal is to avoid cluttering the interface and enlarging the code linked in when ordinary CLHEP Vector functionallity is used. To this end
CLHEP::Hep3Vector
Definition: Geometry/CLHEP/Vector/ThreeVector.h:41
j
long j
Definition: JamesRandomSeeding.txt:28
i
long i
Definition: JamesRandomSeeding.txt:27
CLHEP::HepLorentzVector
Definition: Geometry/CLHEP/Vector/LorentzVector.h:72
Rot4
Definition: testSubscripts.cc:33
k
long k
Definition: JamesRandomSeeding.txt:29
Vec4
HepLorentzVector Vec4
Definition: testSubscripts.cc:20
Rot4::setMatrix
void setMatrix(double xx1, double xy1, double xz1, double xt1, double yx1, double yy1, double yz1, double yt1, double zx1, double zy1, double zz1, double zt1, double tx1, double ty1, double tz1, double tt1)
Definition: testSubscripts.cc:35
Vec3
Hep3Vector Vec3
Definition: testSubscripts.cc:19
Rot3::setMatrix
void setMatrix(double xx1, double xy1, double xz1, double yx1, double yy1, double yz1, double zx1, double zy1, double zz1)
Definition: testSubscripts.cc:24