source: trunk/examples/advanced/Tiara/source/CLHEPWrapper/include/CLHEP.i@ 1350

Last change on this file since 1350 was 807, checked in by garnier, 17 years ago

update

File size: 10.2 KB
Line 
1# $Id: CLHEP.i,v 1.5 2005/12/15 14:23:31 ahoward Exp $
2# -------------------------------------------------------------------
3# GEANT4 tag $Name: $
4# -------------------------------------------------------------------
5
6
7%module CLHEP
8%{
9#include <CLHEP/Vector/ThreeVector.h>
10#include <CLHEP/Units/SystemOfUnits.h>
11%}
12
13%include CLHEP/Units/SystemOfUnits.h
14
15namespace CLHEP {
16
17class Hep3Vector {
18
19public:
20
21// Basic properties and operations on 3-vectors:
22
23 enum { X=0, Y=1, Z=2, NUM_COORDINATES=3, SIZE=NUM_COORDINATES };
24 // Safe indexing of the coordinates when using with matrices, arrays, etc.
25 // (BaBar)
26
27 inline Hep3Vector(double x = 0.0, double y = 0.0, double z = 0.0);
28 // The constructor.
29
30 inline double x() const;
31 inline double y() const;
32 inline double z() const;
33 // The components in cartesian coordinate system. Same as getX() etc.
34
35 inline void setX(double);
36 inline void setY(double);
37 inline void setZ(double);
38 // Set the components in cartesian coordinate system.
39
40 inline double phi() const;
41 // The azimuth angle.
42
43 inline double theta() const;
44 // The polar angle.
45
46 inline double cosTheta() const;
47 // Cosine of the polar angle.
48
49 inline double cos2Theta() const;
50 // Cosine squared of the polar angle - faster than cosTheta(). (ZOOM)
51
52 inline double mag2() const;
53 // The magnitude squared (r^2 in spherical coordinate system).
54
55 inline double mag() const;
56 // The magnitude (r in spherical coordinate system).
57
58 inline void setPhi(double);
59 // Set phi keeping mag and theta constant (BaBar).
60
61 inline void setTheta(double);
62 // Set theta keeping mag and phi constant (BaBar).
63
64 void setMag(double);
65 // Set magnitude keeping theta and phi constant (BaBar).
66
67 inline double perp2() const;
68 // The transverse component squared (rho^2 in cylindrical coordinate system).
69
70 inline double perp() const;
71 // The transverse component (rho in cylindrical coordinate system).
72
73 inline void setPerp(double);
74 // Set the transverse component keeping phi and z constant.
75
76 void setCylTheta(double);
77 // Set theta while keeping transvers component and phi fixed
78
79 inline double perp2(const Hep3Vector &) const;
80 // The transverse component w.r.t. given axis squared.
81
82 inline double perp(const Hep3Vector &) const;
83 // The transverse component w.r.t. given axis.
84
85 inline bool operator == (const Hep3Vector &) const;
86 inline bool operator != (const Hep3Vector &) const;
87 // Comparisons (Geant4).
88
89 inline Hep3Vector & operator += (const Hep3Vector &);
90 // Addition.
91
92 inline Hep3Vector & operator -= (const Hep3Vector &);
93 // Subtraction.
94
95 inline Hep3Vector operator - () const;
96 // Unary minus.
97
98 inline Hep3Vector & operator *= (double);
99 // Scaling with real numbers.
100
101 Hep3Vector & operator /= (double);
102 // Division by (non-zero) real number.
103
104 inline Hep3Vector unit() const;
105 // Vector parallel to this, but of length 1.
106
107 inline Hep3Vector orthogonal() const;
108 // Vector orthogonal to this (Geant4).
109
110 inline double dot(const Hep3Vector &) const;
111 // double product.
112
113 inline Hep3Vector cross(const Hep3Vector &) const;
114 // Cross product.
115
116 double angle(const Hep3Vector &) const;
117 // The angle w.r.t. another 3-vector.
118
119 double pseudoRapidity() const;
120 // Returns the pseudo-rapidity, i.e. -ln(tan(theta/2))
121
122 void setEta ( double p );
123 // Set pseudo-rapidity, keeping magnitude and phi fixed. (ZOOM)
124
125 void setCylEta ( double p );
126 // Set pseudo-rapidity, keeping transverse component and phi fixed. (ZOOM)
127
128 Hep3Vector & rotateX(double);
129 // Rotates the Hep3Vector around the x-axis.
130
131 Hep3Vector & rotateY(double);
132 // Rotates the Hep3Vector around the y-axis.
133
134 Hep3Vector & rotateZ(double);
135 // Rotates the Hep3Vector around the z-axis.
136
137 Hep3Vector & rotateUz(const Hep3Vector&);
138 // Rotates reference frame from Uz to newUz (unit vector) (Geant4).
139
140 Hep3Vector & rotate(double, const Hep3Vector &);
141 // Rotates around the axis specified by another Hep3Vector.
142 // (Uses methods of HepRotation, forcing linking in of Rotation.cc.)
143
144 Hep3Vector & operator *= (const CLHEP::HepRotation &);
145 Hep3Vector & transform(const CLHEP::HepRotation &);
146 // Transformation with a Rotation matrix.
147
148
149
150// = = = = = = = = = = = = = = = = = = = = = = = =
151//
152// Esoteric properties and operations on 3-vectors:
153//
154// 1 - Set vectors in various coordinate systems
155// 2 - Synonyms for accessing coordinates and properties
156// 3 - Comparisions (dictionary, near-ness, and geometric)
157// 4 - Intrinsic properties
158// 5 - Properties releative to z axis and arbitrary directions
159// 6 - Polar and azimuthal angle decomposition and deltaPhi
160// 7 - Rotations
161//
162// = = = = = = = = = = = = = = = = = = = = = = = =
163
164// 1 - Set vectors in various coordinate systems
165
166 inline void setRThetaPhi (double r, double theta, double phi);
167 // Set in spherical coordinates: Angles are measured in RADIANS
168
169 inline void setREtaPhi ( double r, double eta, double phi );
170 // Set in spherical coordinates, but specify peudorapidiy to determine theta.
171
172 inline void setRhoPhiZ (double rho, double phi, double z);
173 // Set in cylindrical coordinates: Phi angle is measured in RADIANS
174
175 void setRhoPhiTheta ( double rho, double phi, double theta);
176 // Set in cylindrical coordinates, but specify theta to determine z.
177
178 void setRhoPhiEta ( double rho, double phi, double eta);
179 // Set in cylindrical coordinates, but specify pseudorapidity to determine z.
180
181// 2 - Synonyms for accessing coordinates and properties
182
183 inline double getX() const;
184 inline double getY() const;
185 inline double getZ() const;
186 // x(), y(), and z()
187
188 inline double getR () const;
189 inline double getTheta() const;
190 inline double getPhi () const;
191 // mag(), theta(), and phi()
192
193 inline double r () const;
194 // mag()
195
196 inline double rho () const;
197 inline double getRho () const;
198 // perp()
199
200 double eta () const;
201 double getEta () const;
202 // pseudoRapidity()
203
204 inline void setR ( double s );
205 // setMag()
206
207 inline void setRho ( double s );
208 // setPerp()
209
210// 3 - Comparisions (dictionary, near-ness, and geometric)
211
212 int compare (const Hep3Vector & v) const;
213 bool operator > (const Hep3Vector & v) const;
214 bool operator < (const Hep3Vector & v) const;
215 bool operator>= (const Hep3Vector & v) const;
216 bool operator<= (const Hep3Vector & v) const;
217 // dictionary ordering according to z, then y, then x component
218
219 inline double diff2 (const Hep3Vector & v) const;
220 // |v1-v2|**2
221
222 static double setTolerance (double tol);
223 static inline double getTolerance ();
224 // Set the tolerance used in isNear() for Hep3Vectors
225
226 bool isParallel (const Hep3Vector & v, double epsilon) const;
227 // Are the vectors parallel, within the given tolerance?
228
229 bool isOrthogonal (const Hep3Vector & v, double epsilon) const;
230 // Are the vectors orthogonal, within the given tolerance?
231
232 double howParallel (const Hep3Vector & v) const;
233 // | v1.cross(v2) / v1.dot(v2) |, to a maximum of 1.
234
235 double howOrthogonal (const Hep3Vector & v) const;
236 // | v1.dot(v2) / v1.cross(v2) |, to a maximum of 1.
237
238 enum { ToleranceTicks = 100 };
239
240// 4 - Intrinsic properties
241
242 double beta () const;
243 // relativistic beta (considering v as a velocity vector with c=1)
244 // Same as mag() but will object if >= 1
245
246 double gamma() const;
247 // relativistic gamma (considering v as a velocity vector with c=1)
248
249 double coLinearRapidity() const;
250 // inverse tanh (beta)
251
252// 5 - Properties relative to Z axis and to an arbitrary direction
253
254 // Note that the non-esoteric CLHEP provides
255 // theta(), cosTheta(), cos2Theta, and angle(const Hep3Vector&)
256
257 inline double angle() const;
258 // angle against the Z axis -- synonym for theta()
259
260 inline double theta(const Hep3Vector & v2) const;
261 // synonym for angle(v2)
262
263 double cosTheta (const Hep3Vector & v2) const;
264 double cos2Theta(const Hep3Vector & v2) const;
265 // cos and cos^2 of the angle between two vectors
266
267 inline Hep3Vector project () const;
268 Hep3Vector project (const Hep3Vector & v2) const;
269 // projection of a vector along a direction.
270
271 inline Hep3Vector perpPart() const;
272 inline Hep3Vector perpPart (const Hep3Vector & v2) const;
273 // vector minus its projection along a direction.
274
275 double rapidity () const;
276 // inverse tanh(v.z())
277
278 double rapidity (const Hep3Vector & v2) const;
279 // rapidity with respect to specified direction:
280 // inverse tanh (v.dot(u)) where u is a unit in the direction of v2
281
282 double eta(const Hep3Vector & v2) const;
283 // - ln tan of the angle beween the vector and the ref direction.
284
285// 6 - Polar and azimuthal angle decomposition and deltaPhi
286
287 // Decomposition of an angle within reference defined by a direction:
288
289 double polarAngle (const Hep3Vector & v2) const;
290 // The reference direction is Z: the polarAngle is abs(v.theta()-v2.theta()).
291
292 double deltaPhi (const Hep3Vector & v2) const;
293 // v.phi()-v2.phi(), brought into the range (-PI,PI]
294
295 double azimAngle (const Hep3Vector & v2) const;
296 // The reference direction is Z: the azimAngle is the same as deltaPhi
297
298 double polarAngle (const Hep3Vector & v2,
299 const Hep3Vector & ref) const;
300 // For arbitrary reference direction,
301 // polarAngle is abs(v.angle(ref) - v2.angle(ref)).
302
303 double azimAngle (const Hep3Vector & v2,
304 const Hep3Vector & ref) const;
305 // To compute azimangle, project v and v2 into the plane normal to
306 // the reference direction. Then in that plane take the angle going
307 // clockwise around the direction from projection of v to that of v2.
308
309// 7 - Rotations
310
311// These mehtods **DO NOT** use anything in the HepRotation class.
312// Thus, use of v.rotate(axis,delta) does not force linking in Rotation.cc.
313
314 Hep3Vector & rotate (const Hep3Vector & axis, double delta);
315 // Synonym for rotate (delta, axis)
316
317 Hep3Vector & rotate (const CLHEP::HepAxisAngle & ax);
318 // HepAxisAngle is a struct holding an axis direction and an angle.
319
320 Hep3Vector & rotate (const CLHEP::HepEulerAngles & e);
321 Hep3Vector & rotate (double phi,
322 double theta,
323 double psi);
324 // Rotate via Euler Angles. Our Euler Angles conventions are
325 // those of Goldstein Classical Mechanics page 107.
326
327};
328
329} // namespace CLHEP
330
331
332%inline %{
333 typedef CLHEP::Hep3Vector G4ThreeVector;
334%}
335
Note: See TracBrowser for help on using the repository browser.