00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef HEP_LORENTZVECTOR_H
00022 #define HEP_LORENTZVECTOR_H
00023
00024 #ifdef GNUPRAGMA
00025 #pragma interface
00026 #endif
00027
00028 #include "CLHEP/config/CLHEP.h"
00029 #include "CLHEP/Vector/ThreeVector.h"
00030 #include "CLHEP/config/iostream.h"
00031
00032 #ifdef HEP_NO_INLINE_IN_DECLARATION
00033 #define inline
00034 #endif
00035
00036
00037 class HepLorentzVector;
00038 class HepLorentzRotation;
00039 class HepRotation;
00040 class HepAxisAngle;
00041 class HepEulerAngles;
00042 class Tcomponent;
00043 HepLorentzVector rotationXOf( const HepLorentzVector & vec, double delta );
00044 HepLorentzVector rotationYOf( const HepLorentzVector & vec, double delta );
00045 HepLorentzVector rotationZOf( const HepLorentzVector & vec, double delta );
00046 HepLorentzVector rotationOf
00047 ( const HepLorentzVector & vec, const Hep3Vector & axis, double delta );
00048 HepLorentzVector rotationOf
00049 ( const HepLorentzVector & vec, const HepAxisAngle & ax );
00050 HepLorentzVector rotationOf
00051 ( const HepLorentzVector & vec, const HepEulerAngles & e );
00052 HepLorentzVector rotationOf
00053 ( const HepLorentzVector & vec, double phi,
00054 double theta,
00055 double psi );
00056 inline
00057 HepLorentzVector boostXOf( const HepLorentzVector & vec, double beta );
00058 inline
00059 HepLorentzVector boostYOf( const HepLorentzVector & vec, double beta );
00060 inline
00061 HepLorentzVector boostZOf( const HepLorentzVector & vec, double beta );
00062 inline HepLorentzVector boostOf
00063 ( const HepLorentzVector & vec, const Hep3Vector & betaVector );
00064 inline HepLorentzVector boostOf
00065 ( const HepLorentzVector & vec, const Hep3Vector & axis, double beta );
00066
00067 enum ZMpvMetric_t { TimePositive, TimeNegative };
00068
00069
00074 class HepLorentzVector {
00075
00076 public:
00077
00078 enum { X=0, Y=1, Z=2, T=3, NUM_COORDINATES=4, SIZE=NUM_COORDINATES };
00079
00080
00081
00082 inline HepLorentzVector(double x, double y,
00083 double z, double t);
00084
00085
00086 inline HepLorentzVector(double x, double y, double z);
00087
00088
00089 inline HepLorentzVector(double t);
00090
00091
00092 inline HepLorentzVector();
00093
00094
00095 inline HepLorentzVector(const Hep3Vector & p, double e);
00096 inline HepLorentzVector(double e, const Hep3Vector & p);
00097
00098
00099 inline HepLorentzVector(const HepLorentzVector &);
00100
00101
00102 inline ~HepLorentzVector();
00103
00104
00105 inline operator const Hep3Vector & () const;
00106 inline operator Hep3Vector & ();
00107
00108
00109 inline double x() const;
00110 inline double y() const;
00111 inline double z() const;
00112 inline double t() const;
00113
00114
00115 inline void setX(double);
00116 inline void setY(double);
00117 inline void setZ(double);
00118 inline void setT(double);
00119
00120
00121 inline double px() const;
00122 inline double py() const;
00123 inline double pz() const;
00124 inline double e() const;
00125
00126
00127 inline void setPx(double);
00128 inline void setPy(double);
00129 inline void setPz(double);
00130 inline void setE(double);
00131
00132
00133 inline Hep3Vector vect() const;
00134
00135
00136 inline void setVect(const Hep3Vector &);
00137
00138
00139 inline double theta() const;
00140 inline double cosTheta() const;
00141 inline double phi() const;
00142 inline double rho() const;
00143
00144
00145 inline void setTheta(double);
00146 inline void setPhi(double);
00147 inline void setRho(double);
00148
00149
00150 double operator () (int) const;
00151 inline double operator [] (int) const;
00152
00153
00154 double & operator () (int);
00155 inline double & operator [] (int);
00156
00157
00158 inline HepLorentzVector & operator = (const HepLorentzVector &);
00159
00160
00161 inline HepLorentzVector operator + (const HepLorentzVector &) const;
00162 inline HepLorentzVector & operator += (const HepLorentzVector &);
00163
00164
00165 inline HepLorentzVector operator - (const HepLorentzVector &) const;
00166 inline HepLorentzVector & operator -= (const HepLorentzVector &);
00167
00168
00169 inline HepLorentzVector operator - () const;
00170
00171
00172 inline HepLorentzVector & operator *= (double);
00173 HepLorentzVector & operator /= (double);
00174
00175
00176 inline bool operator == (const HepLorentzVector &) const;
00177 inline bool operator != (const HepLorentzVector &) const;
00178
00179
00180 inline double perp2() const;
00181
00182
00183 inline double perp() const;
00184
00185
00186 inline void setPerp(double);
00187
00188
00189 inline double perp2(const Hep3Vector &) const;
00190
00191
00192 inline double perp(const Hep3Vector &) const;
00193
00194
00195 inline double angle(const Hep3Vector &) const;
00196
00197
00198 inline double mag2() const;
00199
00200
00201
00202 inline double m2() const;
00203
00204
00205 inline double mag() const;
00206 inline double m() const;
00207
00208
00209 inline double mt2() const;
00210
00211
00212 inline double mt() const;
00213
00214
00215 inline double et2() const;
00216
00217
00218 inline double et() const;
00219
00220
00221 inline double dot(const HepLorentzVector &) const;
00222 inline double operator * (const HepLorentzVector &) const;
00223
00224
00225 inline double invariantMass2( const HepLorentzVector & w ) const;
00226
00227
00228 double invariantMass ( const HepLorentzVector & w ) const;
00229
00230
00231 inline void setVectMag(const Hep3Vector & spatial, double magnitude);
00232 inline void setVectM(const Hep3Vector & spatial, double mass);
00233
00234
00235 inline double plus() const;
00236 inline double minus() const;
00237
00238
00239 Hep3Vector boostVector() const;
00240
00241
00242
00243 HepLorentzVector & boost(double, double, double);
00244 inline HepLorentzVector & boost(const Hep3Vector &);
00245
00246
00247 HepLorentzVector & boostX( double beta );
00248 HepLorentzVector & boostY( double beta );
00249 HepLorentzVector & boostZ( double beta );
00250
00251
00252 double rapidity() const;
00253
00254
00255 inline double pseudoRapidity() const;
00256
00257
00258 inline bool isTimelike() const;
00259
00260
00261 inline bool isSpacelike() const;
00262
00263
00264 inline bool isLightlike(double epsilon=tolerance) const;
00265
00266
00267 HepLorentzVector & rotateX(double);
00268
00269
00270 HepLorentzVector & rotateY(double);
00271
00272
00273 HepLorentzVector & rotateZ(double);
00274
00275
00276 HepLorentzVector & rotateUz(const Hep3Vector &);
00277
00278
00279 HepLorentzVector & rotate(double, const Hep3Vector &);
00280
00281
00282 inline HepLorentzVector & operator *= (const HepRotation &);
00283 inline HepLorentzVector & transform(const HepRotation &);
00284
00285
00286 HepLorentzVector & operator *= (const HepLorentzRotation &);
00287 HepLorentzVector & transform(const HepLorentzRotation &);
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 static ZMpvMetric_t setMetric( ZMpvMetric_t m );
00310 static ZMpvMetric_t getMetric();
00311
00312
00313
00314 inline void set (double x, double y, double z, double t);
00315 inline void set (double x, double y, double z, Tcomponent t);
00316 inline HepLorentzVector(double x, double y, double z, Tcomponent t);
00317
00318
00319 inline void set (Tcomponent t, double x, double y, double z);
00320 inline HepLorentzVector(Tcomponent t, double x, double y, double z);
00321
00322
00323 inline void set ( double t );
00324
00325 inline void set ( Tcomponent t );
00326 inline explicit HepLorentzVector( Tcomponent t );
00327
00328
00329 inline void set ( const Hep3Vector & v );
00330 inline explicit HepLorentzVector( const Hep3Vector & v );
00331
00332
00333 inline HepLorentzVector & operator=( const Hep3Vector & v );
00334
00335
00336 inline void set ( const Hep3Vector & v, double t );
00337 inline void set ( double t, const Hep3Vector & v );
00338
00339
00340
00341
00342 inline double getX() const;
00343 inline double getY() const;
00344 inline double getZ() const;
00345 inline double getT() const;
00346
00347
00348 inline Hep3Vector v() const;
00349 inline Hep3Vector getV() const;
00350
00351
00352 inline void setV(const Hep3Vector &);
00353
00354
00355
00356
00357 inline void setV( double x, double y, double z );
00358
00359 inline void setRThetaPhi( double r, double theta, double phi);
00360 inline void setREtaPhi( double r, double eta, double phi);
00361 inline void setRhoPhiZ( double rho, double phi, double z );
00362
00363
00364
00365 int compare( const HepLorentzVector & w ) const;
00366
00367 bool operator >( const HepLorentzVector & w ) const;
00368 bool operator <( const HepLorentzVector & w ) const;
00369 bool operator>=( const HepLorentzVector & w ) const;
00370 bool operator<=( const HepLorentzVector & w ) const;
00371
00372 bool isNear ( const HepLorentzVector & w,
00373 double epsilon=tolerance ) const;
00374 double howNear( const HepLorentzVector & w ) const;
00375
00376
00377 bool isNearCM ( const HepLorentzVector & w,
00378 double epsilon=tolerance ) const;
00379 double howNearCM( const HepLorentzVector & w ) const;
00380
00381
00382
00383
00384
00385
00386
00387 bool isParallel( const HepLorentzVector & w,
00388 double epsilon=tolerance ) const;
00389
00390 double howParallel (const HepLorentzVector & w) const;
00391
00392 static double getTolerance();
00393 static double setTolerance( double tol );
00394
00395
00396
00397 double deltaR(const HepLorentzVector & v) const;
00398
00399
00400
00401
00402 double howLightlike() const;
00403
00404
00405 inline double euclideanNorm2() const;
00406
00407
00408 inline double euclideanNorm() const;
00409
00410
00411
00412
00413
00414
00415
00416 inline double restMass2() const;
00417 inline double invariantMass2() const;
00418
00419
00420 inline double restMass() const;
00421 inline double invariantMass() const;
00422
00423
00424
00425
00426
00427 HepLorentzVector rest4Vector() const;
00428
00429
00430
00431
00432
00433 double beta() const;
00434
00435
00436 double gamma() const;
00437
00438
00439 inline double eta() const;
00440
00441
00442 inline double eta(const Hep3Vector & ref) const;
00443
00444
00445 double rapidity(const Hep3Vector & ref) const;
00446
00447
00448 double coLinearRapidity() const;
00449
00450
00451 Hep3Vector findBoostToCM() const;
00452
00453
00454
00455
00456 Hep3Vector findBoostToCM( const HepLorentzVector & w ) const;
00457
00458
00459
00460
00461 inline double et2(const Hep3Vector &) const;
00462
00463
00464 inline double et(const Hep3Vector &) const;
00465
00466
00467
00468
00469 inline double diff2( const HepLorentzVector & w ) const;
00470
00471
00472 inline double delta2Euclidean ( const HepLorentzVector & w ) const;
00473
00474
00475
00476
00477 double plus( const Hep3Vector & ref ) const;
00478
00479
00480 double minus( const Hep3Vector & ref ) const;
00481
00482
00483
00484
00485 HepLorentzVector & rotate ( const Hep3Vector & axis, double delta );
00486
00487
00488 HepLorentzVector & rotate ( const HepAxisAngle & ax );
00489 HepLorentzVector & rotate ( const HepEulerAngles & e );
00490 HepLorentzVector & rotate ( double phi,
00491 double theta,
00492 double psi );
00493
00494
00495 HepLorentzVector & boost ( const Hep3Vector & axis, double beta );
00496
00497
00498
00499 friend HepLorentzVector rotationXOf
00500 ( const HepLorentzVector & vec, double delta );
00501 friend HepLorentzVector rotationYOf
00502 ( const HepLorentzVector & vec, double delta );
00503 friend HepLorentzVector rotationZOf
00504 ( const HepLorentzVector & vec, double delta );
00505 friend HepLorentzVector rotationOf
00506 ( const HepLorentzVector & vec, const Hep3Vector & axis, double delta );
00507 friend HepLorentzVector rotationOf
00508 ( const HepLorentzVector & vec, const HepAxisAngle & ax );
00509 friend HepLorentzVector rotationOf
00510 ( const HepLorentzVector & vec, const HepEulerAngles & e );
00511 friend HepLorentzVector rotationOf
00512 ( const HepLorentzVector & vec, double phi,
00513 double theta,
00514 double psi );
00515
00516 inline friend HepLorentzVector boostXOf
00517 ( const HepLorentzVector & vec, double beta );
00518 inline friend HepLorentzVector boostYOf
00519 ( const HepLorentzVector & vec, double beta );
00520 inline friend HepLorentzVector boostZOf
00521 ( const HepLorentzVector & vec, double beta );
00522 inline friend HepLorentzVector boostOf
00523 ( const HepLorentzVector & vec, const Hep3Vector & betaVector );
00524 inline friend HepLorentzVector boostOf
00525 ( const HepLorentzVector & vec, const Hep3Vector & axis, double beta );
00526
00527 private:
00528
00529 Hep3Vector pp;
00530 double ee;
00531
00532 static double tolerance;
00533 static double metric;
00534
00535 };
00536
00537
00538
00539 static const HepLorentzVector X_HAT4 = HepLorentzVector( 1, 0, 0, 0 );
00540 static const HepLorentzVector Y_HAT4 = HepLorentzVector( 0, 1, 0, 0 );
00541 static const HepLorentzVector Z_HAT4 = HepLorentzVector( 0, 0, 1, 0 );
00542 static const HepLorentzVector T_HAT4 = HepLorentzVector( 0, 0, 0, 1 );
00543
00544
00545
00546 HepStd::ostream & operator << (HepStd::ostream &, const HepLorentzVector &);
00547
00548
00549 HepStd::istream & operator >> (HepStd::istream &, HepLorentzVector &);
00550
00551
00552 #ifdef HEP_NO_INLINE_IN_DECLARATION
00553 #undef inline
00554 #endif
00555
00556 #ifdef HEP_SHORT_NAMES
00557 typedef HepLorentzVector VectorL;
00558 typedef HepLorentzVector Vector4;
00559 typedef HepLorentzVector DVectorL;
00560 typedef HepLorentzVector DVector4;
00561 typedef HepLorentzVector FVectorL;
00562 typedef HepLorentzVector FVector4;
00563 #endif
00564
00565 typedef HepLorentzVector HepLorentzVectorD;
00566 typedef HepLorentzVector HepLorentzVectorF;
00567
00568 inline HepLorentzVector operator * (const HepLorentzVector &, double a);
00569 inline HepLorentzVector operator * (double a, const HepLorentzVector &);
00570
00571
00572 HepLorentzVector operator / (const HepLorentzVector &, double a);
00573
00574
00575
00576
00577
00578 class Tcomponent {
00579 private:
00580 double t_;
00581 public:
00582 explicit Tcomponent(double t) : t_(t) {}
00583 operator double() const { return t_; }
00584 };
00585
00586 #ifndef HEP_DEBUG_INLINE
00587 #include "CLHEP/Vector/LorentzVector.icc"
00588 #endif
00589
00590 #endif