001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021 #ifndef HEP_THREEVECTOR_H
022 #define HEP_THREEVECTOR_H
023
024 #ifdef GNUPRAGMA
025 #pragma interface
026 #endif
027
028 #include "CLHEP/config/CLHEP.h"
029 #include "CLHEP/config/iostream.h"
030
031 #ifdef HEP_NO_INLINE_IN_DECLARATION
032 #define inline
033 #endif
034
035 class HepRotation;
036 class HepEulerAngles;
037 class HepAxisAngle;
038
039
040
041
042
043 class Hep3Vector {
044
045 public:
046
047
048
049 enum { X=0, Y=1, Z=2, NUM_COORDINATES=3, SIZE=NUM_COORDINATES };
050
051
052
053 inline Hep3Vector(double x = 0.0, double y = 0.0, double z = 0.0);
054
055
056 inline Hep3Vector(const Hep3Vector &);
057
058
059 inline ~Hep3Vector();
060
061
062 double operator () (int) const;
063
064
065 inline double operator [] (int) const;
066
067
068 double & operator () (int);
069
070
071 inline double & operator [] (int);
072
073
074 inline double x() const;
075 inline double y() const;
076 inline double z() const;
077
078
079 inline void setX(double);
080 inline void setY(double);
081 inline void setZ(double);
082
083
084 inline void set( double x, double y, double z);
085
086
087 inline double phi() const;
088
089
090 inline double theta() const;
091
092
093 inline double cosTheta() const;
094
095
096 inline double cos2Theta() const;
097
098
099 inline double mag2() const;
100
101
102 inline double mag() const;
103
104
105 inline void setPhi(double);
106
107
108 inline void setTheta(double);
109
110
111 void setMag(double);
112
113
114 inline double perp2() const;
115
116
117 inline double perp() const;
118
119
120 inline void setPerp(double);
121
122
123 void setCylTheta(double);
124
125
126 inline double perp2(const Hep3Vector &) const;
127
128
129 inline double perp(const Hep3Vector &) const;
130
131
132 inline Hep3Vector & operator = (const Hep3Vector &);
133
134
135 inline bool operator == (const Hep3Vector &) const;
136 inline bool operator != (const Hep3Vector &) const;
137
138
139 bool isNear (const Hep3Vector &, double epsilon=tolerance) const;
140
141
142
143 double howNear(const Hep3Vector & v ) const;
144
145
146
147 double deltaR(const Hep3Vector & v) const;
148
149
150 inline Hep3Vector & operator += (const Hep3Vector &);
151
152
153 inline Hep3Vector & operator -= (const Hep3Vector &);
154
155
156 inline Hep3Vector operator - () const;
157
158
159 inline Hep3Vector & operator *= (double);
160
161
162 Hep3Vector & operator /= (double);
163
164
165 inline Hep3Vector unit() const;
166
167
168 inline Hep3Vector orthogonal() const;
169
170
171 inline double dot(const Hep3Vector &) const;
172
173
174 inline Hep3Vector cross(const Hep3Vector &) const;
175
176
177 double angle(const Hep3Vector &) const;
178
179
180 double pseudoRapidity() const;
181
182
183 void setEta ( double p );
184
185
186 void setCylEta ( double p );
187
188
189 Hep3Vector & rotateX(double);
190
191
192 Hep3Vector & rotateY(double);
193
194
195 Hep3Vector & rotateZ(double);
196
197
198 Hep3Vector & rotateUz(const Hep3Vector&);
199
200
201 Hep3Vector & rotate(double, const Hep3Vector &);
202
203
204
205 Hep3Vector & operator *= (const HepRotation &);
206 Hep3Vector & transform(const HepRotation &);
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226 inline void setRThetaPhi (double r, double theta, double phi);
227
228
229 inline void setREtaPhi ( double r, double eta, double phi );
230
231
232 inline void setRhoPhiZ (double rho, double phi, double z);
233
234
235 void setRhoPhiTheta ( double rho, double phi, double theta);
236
237
238 void setRhoPhiEta ( double rho, double phi, double eta);
239
240
241
242
243 inline double getX() const;
244 inline double getY() const;
245 inline double getZ() const;
246
247
248 inline double getR () const;
249 inline double getTheta() const;
250 inline double getPhi () const;
251
252
253 inline double r () const;
254
255
256 inline double rho () const;
257 inline double getRho () const;
258
259
260 double eta () const;
261 double getEta () const;
262
263
264 inline void setR ( double s );
265
266
267 inline void setRho ( double s );
268
269
270
271
272 int compare (const Hep3Vector & v) const;
273 bool operator > (const Hep3Vector & v) const;
274 bool operator < (const Hep3Vector & v) const;
275 bool operator>= (const Hep3Vector & v) const;
276 bool operator<= (const Hep3Vector & v) const;
277
278
279 inline double diff2 (const Hep3Vector & v) const;
280
281
282 static double setTolerance (double tol);
283 static inline double getTolerance ();
284
285
286 bool isParallel (const Hep3Vector & v, double epsilon=tolerance) const;
287
288
289 bool isOrthogonal (const Hep3Vector & v, double epsilon=tolerance) const;
290
291
292 double howParallel (const Hep3Vector & v) const;
293
294
295 double howOrthogonal (const Hep3Vector & v) const;
296
297
298 enum { ToleranceTicks = 100 };
299
300
301
302 double beta () const;
303
304
305
306 double gamma() const;
307
308
309 double coLinearRapidity() const;
310
311
312
313
314
315
316
317 inline double angle() const;
318
319
320 inline double theta(const Hep3Vector & v2) const;
321
322
323 double cosTheta (const Hep3Vector & v2) const;
324 double cos2Theta(const Hep3Vector & v2) const;
325
326
327 inline Hep3Vector project () const;
328 Hep3Vector project (const Hep3Vector & v2) const;
329
330
331 inline Hep3Vector perpPart() const;
332 inline Hep3Vector perpPart (const Hep3Vector & v2) const;
333
334
335 double rapidity () const;
336
337
338 double rapidity (const Hep3Vector & v2) const;
339
340
341
342 double eta(const Hep3Vector & v2) const;
343
344
345
346
347
348
349 double polarAngle (const Hep3Vector & v2) const;
350
351
352 double deltaPhi (const Hep3Vector & v2) const;
353
354
355 double azimAngle (const Hep3Vector & v2) const;
356
357
358 double polarAngle (const Hep3Vector & v2,
359 const Hep3Vector & ref) const;
360
361
362
363 double azimAngle (const Hep3Vector & v2,
364 const Hep3Vector & ref) const;
365
366
367
368
369
370
371
372
373
374 Hep3Vector & rotate (const Hep3Vector & axis, double delta);
375
376
377 Hep3Vector & rotate (const HepAxisAngle & ax);
378
379
380 Hep3Vector & rotate (const HepEulerAngles & e);
381 Hep3Vector & rotate (double phi,
382 double theta,
383 double psi);
384
385
386
387 protected:
388 void setSpherical (double r, double theta, double phi);
389 void setCylindrical (double r, double phi, double z);
390 double negativeInfinity() const;
391
392 protected:
393
394 double dx;
395 double dy;
396 double dz;
397
398
399 static double tolerance;
400
401 };
402
403
404
405 Hep3Vector rotationXOf (const Hep3Vector & vec, double delta);
406 Hep3Vector rotationYOf (const Hep3Vector & vec, double delta);
407 Hep3Vector rotationZOf (const Hep3Vector & vec, double delta);
408
409 Hep3Vector rotationOf (const Hep3Vector & vec,
410 const Hep3Vector & axis, double delta);
411 Hep3Vector rotationOf (const Hep3Vector & vec, const HepAxisAngle & ax);
412
413 Hep3Vector rotationOf (const Hep3Vector & vec,
414 double phi, double theta, double psi);
415 Hep3Vector rotationOf (const Hep3Vector & vec, const HepEulerAngles & e);
416
417
418 HepStd::ostream & operator << (HepStd::ostream &, const Hep3Vector &);
419
420
421 HepStd::istream & operator >> (HepStd::istream &, Hep3Vector &);
422
423
424 extern const Hep3Vector HepXHat, HepYHat, HepZHat;
425
426 #ifdef HEP_SHORT_NAMES
427 typedef Hep3Vector Vector3;
428 typedef Hep3Vector DVector3;
429 typedef Hep3Vector FVector3;
430 static const Hep3Vector & xhat = HepXHat;
431 static const Hep3Vector & yhat = HepYHat;
432 static const Hep3Vector & zhat = HepZHat;
433 #endif
434 typedef Hep3Vector HepThreeVectorD;
435 typedef Hep3Vector HepThreeVectorF;
436
437 Hep3Vector operator / (const Hep3Vector &, double a);
438
439
440 #ifdef HEP_NO_INLINE_IN_DECLARATION
441 #undef inline
442 #endif
443
444 #ifdef HEP_DEBUG_INLINE
445
446
447
448
449
450
451
452
453 Hep3Vector operator + (const Hep3Vector &, const Hep3Vector &);
454
455
456 Hep3Vector operator - (const Hep3Vector &, const Hep3Vector &);
457
458
459 double operator * (const Hep3Vector &, const Hep3Vector &);
460
461
462 Hep3Vector operator * (const Hep3Vector &, double a);
463 Hep3Vector operator * (double a, const Hep3Vector &);
464
465
466 #else
467 #include "CLHEP/Vector/ThreeVector.icc"
468 #endif
469
470 #endif
Send problems or questions to cdfcode@fnal.gov