File indexing completed on 2025-01-18 09:54:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef HEP_THREEVECTOR_H
0021 #define HEP_THREEVECTOR_H
0022
0023 #include <iostream>
0024 #include "CLHEP/Vector/defs.h"
0025
0026 namespace CLHEP {
0027
0028 class HepRotation;
0029 class HepEulerAngles;
0030 class HepAxisAngle;
0031
0032
0033
0034
0035
0036 class Hep3Vector {
0037
0038 public:
0039
0040
0041
0042 enum { X=0, Y=1, Z=2, NUM_COORDINATES=3, SIZE=NUM_COORDINATES };
0043
0044
0045
0046 Hep3Vector();
0047 explicit Hep3Vector(double x);
0048 Hep3Vector(double x, double y);
0049 Hep3Vector(double x, double y, double z);
0050
0051
0052 inline Hep3Vector(const Hep3Vector &);
0053 inline Hep3Vector(Hep3Vector &&) = default;
0054
0055
0056 inline ~Hep3Vector();
0057
0058
0059 inline double operator () (int) const;
0060
0061
0062 inline double operator [] (int) const;
0063
0064
0065 inline double & operator () (int);
0066
0067
0068 inline double & operator [] (int);
0069
0070
0071 inline double x() const;
0072 inline double y() const;
0073 inline double z() const;
0074
0075
0076 inline void setX(double);
0077 inline void setY(double);
0078 inline void setZ(double);
0079
0080
0081 inline void set( double x, double y, double z);
0082
0083
0084 inline double phi() const;
0085
0086
0087 inline double theta() const;
0088
0089
0090 inline double cosTheta() const;
0091
0092
0093 inline double cos2Theta() const;
0094
0095
0096 inline double mag2() const;
0097
0098
0099 inline double mag() const;
0100
0101
0102 inline void setPhi(double);
0103
0104
0105 inline void setTheta(double);
0106
0107
0108 void setMag(double);
0109
0110
0111 inline double perp2() const;
0112
0113
0114 inline double perp() const;
0115
0116
0117 inline void setPerp(double);
0118
0119
0120 void setCylTheta(double);
0121
0122
0123 inline double perp2(const Hep3Vector &) const;
0124
0125
0126 inline double perp(const Hep3Vector &) const;
0127
0128
0129 inline Hep3Vector & operator = (const Hep3Vector &);
0130 inline Hep3Vector & operator = (Hep3Vector &&) = default;
0131
0132
0133 inline bool operator == (const Hep3Vector &) const;
0134 inline bool operator != (const Hep3Vector &) const;
0135
0136
0137 bool isNear (const Hep3Vector &, double epsilon=tolerance) const;
0138
0139
0140
0141 double howNear(const Hep3Vector & v ) const;
0142
0143
0144
0145 double deltaR(const Hep3Vector & v) const;
0146
0147
0148 inline Hep3Vector & operator += (const Hep3Vector &);
0149
0150
0151 inline Hep3Vector & operator -= (const Hep3Vector &);
0152
0153
0154 inline Hep3Vector operator - () const;
0155
0156
0157 inline Hep3Vector & operator *= (double);
0158
0159
0160 Hep3Vector & operator /= (double);
0161
0162
0163 inline Hep3Vector unit() const;
0164
0165
0166 inline Hep3Vector orthogonal() const;
0167
0168
0169 inline double dot(const Hep3Vector &) const;
0170
0171
0172 inline Hep3Vector cross(const Hep3Vector &) const;
0173
0174
0175 double angle(const Hep3Vector &) const;
0176
0177
0178 double pseudoRapidity() const;
0179
0180
0181 void setEta ( double p );
0182
0183
0184 void setCylEta ( double p );
0185
0186
0187 Hep3Vector & rotateX(double);
0188
0189
0190 Hep3Vector & rotateY(double);
0191
0192
0193 Hep3Vector & rotateZ(double);
0194
0195
0196 Hep3Vector & rotateUz(const Hep3Vector&);
0197
0198
0199 Hep3Vector & rotate(double, const Hep3Vector &);
0200
0201
0202
0203 Hep3Vector & operator *= (const HepRotation &);
0204 Hep3Vector & transform(const HepRotation &);
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223 inline void setRThetaPhi (double r, double theta, double phi);
0224
0225
0226 inline void setREtaPhi ( double r, double eta, double phi );
0227
0228
0229 inline void setRhoPhiZ (double rho, double phi, double z);
0230
0231
0232 void setRhoPhiTheta ( double rho, double phi, double theta);
0233
0234
0235 void setRhoPhiEta ( double rho, double phi, double eta);
0236
0237
0238
0239
0240 inline double getX() const;
0241 inline double getY() const;
0242 inline double getZ() const;
0243
0244
0245 inline double getR () const;
0246 inline double getTheta() const;
0247 inline double getPhi () const;
0248
0249
0250 inline double r () const;
0251
0252
0253 inline double rho () const;
0254 inline double getRho () const;
0255
0256
0257 double eta () const;
0258 double getEta () const;
0259
0260
0261 inline void setR ( double s );
0262
0263
0264 inline void setRho ( double s );
0265
0266
0267
0268
0269 int compare (const Hep3Vector & v) const;
0270 bool operator > (const Hep3Vector & v) const;
0271 bool operator < (const Hep3Vector & v) const;
0272 bool operator>= (const Hep3Vector & v) const;
0273 bool operator<= (const Hep3Vector & v) const;
0274
0275
0276 inline double diff2 (const Hep3Vector & v) const;
0277
0278
0279 static double setTolerance (double tol);
0280 static inline double getTolerance ();
0281
0282
0283 bool isParallel (const Hep3Vector & v, double epsilon=tolerance) const;
0284
0285
0286 bool isOrthogonal (const Hep3Vector & v, double epsilon=tolerance) const;
0287
0288
0289 double howParallel (const Hep3Vector & v) const;
0290
0291
0292 double howOrthogonal (const Hep3Vector & v) const;
0293
0294
0295 static const int ToleranceTicks = 100;
0296
0297
0298
0299 double beta () const;
0300
0301
0302
0303 double gamma() const;
0304
0305
0306 double coLinearRapidity() const;
0307
0308
0309
0310
0311
0312
0313
0314 inline double angle() const;
0315
0316
0317 inline double theta(const Hep3Vector & v2) const;
0318
0319
0320 double cosTheta (const Hep3Vector & v2) const;
0321 double cos2Theta(const Hep3Vector & v2) const;
0322
0323
0324 inline Hep3Vector project () const;
0325 Hep3Vector project (const Hep3Vector & v2) const;
0326
0327
0328 inline Hep3Vector perpPart() const;
0329 inline Hep3Vector perpPart (const Hep3Vector & v2) const;
0330
0331
0332 double rapidity () const;
0333
0334
0335 double rapidity (const Hep3Vector & v2) const;
0336
0337
0338
0339 double eta(const Hep3Vector & v2) const;
0340
0341
0342
0343
0344
0345
0346 double polarAngle (const Hep3Vector & v2) const;
0347
0348
0349 double deltaPhi (const Hep3Vector & v2) const;
0350
0351
0352 double azimAngle (const Hep3Vector & v2) const;
0353
0354
0355 double polarAngle (const Hep3Vector & v2,
0356 const Hep3Vector & ref) const;
0357
0358
0359
0360 double azimAngle (const Hep3Vector & v2,
0361 const Hep3Vector & ref) const;
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371 Hep3Vector & rotate (const Hep3Vector & axis, double delta);
0372
0373
0374 Hep3Vector & rotate (const HepAxisAngle & ax);
0375
0376
0377 Hep3Vector & rotate (const HepEulerAngles & e);
0378 Hep3Vector & rotate (double phi,
0379 double theta,
0380 double psi);
0381
0382
0383
0384 protected:
0385 void setSpherical (double r, double theta, double phi);
0386 void setCylindrical (double r, double phi, double z);
0387 double negativeInfinity() const;
0388
0389 protected:
0390
0391 double data[3];
0392
0393
0394 static double tolerance;
0395
0396 };
0397
0398
0399
0400 Hep3Vector rotationXOf (const Hep3Vector & vec, double delta);
0401 Hep3Vector rotationYOf (const Hep3Vector & vec, double delta);
0402 Hep3Vector rotationZOf (const Hep3Vector & vec, double delta);
0403
0404 Hep3Vector rotationOf (const Hep3Vector & vec,
0405 const Hep3Vector & axis, double delta);
0406 Hep3Vector rotationOf (const Hep3Vector & vec, const HepAxisAngle & ax);
0407
0408 Hep3Vector rotationOf (const Hep3Vector & vec,
0409 double phi, double theta, double psi);
0410 Hep3Vector rotationOf (const Hep3Vector & vec, const HepEulerAngles & e);
0411
0412
0413 std::ostream & operator << (std::ostream &, const Hep3Vector &);
0414
0415
0416 std::istream & operator >> (std::istream &, Hep3Vector &);
0417
0418
0419 extern const Hep3Vector HepXHat, HepYHat, HepZHat;
0420
0421 typedef Hep3Vector HepThreeVectorD;
0422 typedef Hep3Vector HepThreeVectorF;
0423
0424 Hep3Vector operator / (const Hep3Vector &, double a);
0425
0426
0427 inline Hep3Vector operator + (const Hep3Vector &, const Hep3Vector &);
0428
0429
0430 inline Hep3Vector operator - (const Hep3Vector &, const Hep3Vector &);
0431
0432
0433 inline double operator * (const Hep3Vector &, const Hep3Vector &);
0434
0435
0436 inline Hep3Vector operator * (const Hep3Vector &, double a);
0437 inline Hep3Vector operator * (double a, const Hep3Vector &);
0438
0439
0440 }
0441
0442 #include "CLHEP/Vector/ThreeVector.icc"
0443
0444 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0445
0446 using namespace CLHEP;
0447 #endif
0448
0449 #endif