Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:33

0001 // -*- C++ -*-
0002 //
0003 // SpinOneLorentzRotation.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef ThePEG_SpinOneLorentzRotation_H
0010 #define ThePEG_SpinOneLorentzRotation_H
0011 
0012 #include "ThePEG/Helicity/HelicityDefinitions.h"
0013 #include "ThePEG/Helicity/LorentzRank3Tensor.fh"
0014 #include "ThePEG/Helicity/LorentzTensor.fh"
0015 #include "ThePEG/Helicity/LorentzRSSpinor.fh"
0016 #include "ThePEG/Helicity/LorentzRSSpinorBar.fh"
0017 #include "ThreeVector.h"
0018 #include <vector>
0019 
0020 namespace ThePEG {
0021 
0022 /**
0023  * The SpinOneLorentzRotation class is ... */
0024 
0025 class SpinOneLorentzRotation {
0026 public:
0027 
0028   /** @name Constructors and destructor. */
0029   //@{
0030 
0031   /**
0032    * Default constructor. Gives a unit matrix.
0033    */
0034   SpinOneLorentzRotation() {
0035     xx_() = yy_() = zz_() = tt_() = 1.0;
0036   }
0037   
0038   /**
0039    * Constructor giving the components of a Lorentz boost.
0040    * @param bx The x-component of the boost
0041    * @param by The y-component of the boost
0042    * @param bz The z-component of the boost
0043    * @param gamma The \f$\gamma\f$ factor (optional)
0044    */
0045   SpinOneLorentzRotation (double bx, double by, double bz, double gamma=-1.) 
0046   {
0047     setBoost(bx,by,bz,gamma);
0048   }
0049 
0050   /**
0051    * Constructor giving the vector for a Lorentz boost.
0052    * @param b The boost vector
0053    * @param gamma The \f$\gamma\f$ factor (optional)
0054    */
0055   explicit SpinOneLorentzRotation (const Boost & b, double gamma=-1.)
0056   {
0057     setBoost(b.x(), b.y(), b.z(),gamma);
0058   }
0059   //@}
0060 
0061   /**
0062    * Returns true if the Identity matrix.
0063    */
0064   bool isIdentity() const;
0065 
0066   /**
0067    * Return the inverse.
0068    */
0069   SpinOneLorentzRotation inverse() const;
0070 
0071   /**
0072    * Inverts the SpinOneLorentzRotation matrix.
0073    */
0074   SpinOneLorentzRotation & invert() { return *this = inverse(); }
0075 
0076   /**
0077    *  output operator
0078    */
0079   std::ostream & print( std::ostream & os ) const;
0080 
0081   /** @name Set methods for speical cases of simple rotations and boosts */
0082   //@{
0083 
0084   /**
0085    * Specify the components of a Lorentz Boost
0086    * @param bx The x-component of the boost
0087    * @param by The y-component of the boost
0088    * @param bz The z-component of the boost
0089    * @param gamma The \f$\gamma\f$ factor (optional)
0090    */
0091   SpinOneLorentzRotation & setBoost (double bx, double by, double bz, double gamma=-1.);
0092 
0093   /**
0094    * Specify a Lorentz Boost as a vector
0095    * @param b The boost vector
0096    * @param gamma The \f$\gamma\f$ factor (optional)
0097    */
0098   SpinOneLorentzRotation & setBoost (const Boost & b, double gamma=-1.) {
0099     return setBoost(b.x(), b.y(), b.z(),gamma); 
0100   }
0101 
0102   /**
0103    * Specify a rotation about a general axis by the angle given.
0104    * @param delta The angle
0105    * @param axis The axis
0106    */
0107   SpinOneLorentzRotation & setRotate(double delta, const Axis & axis);
0108 
0109   /**
0110    * Specify a rotation by the given angle about the x-axis
0111    * @param angle The rotation angle 
0112    */
0113   SpinOneLorentzRotation & setRotateX (double angle);
0114 
0115   /**
0116    * Specify a rotation by the given angle about the y-axis
0117    * @param angle The rotation angle 
0118    */
0119   SpinOneLorentzRotation & setRotateY (double angle);
0120 
0121   /**
0122    * Specify a rotation by the given angle about the z-axis
0123    * @param angle The rotation angle 
0124    */
0125   SpinOneLorentzRotation & setRotateZ (double angle);
0126   
0127   //@}
0128 
0129   /** @name Access methods for the components of the spin-1 rotation */
0130   //@{
0131 
0132   /**
0133    *   The xx component
0134    */
0135   double xx() const { return matrix_[ 0]; }
0136 
0137   /**
0138    *   The xy component
0139    */
0140   double xy() const { return matrix_[ 1]; }
0141 
0142   /**
0143    *   The xz component
0144    */
0145   double xz() const { return matrix_[ 2]; }
0146 
0147   /**
0148    *   The xt component
0149    */
0150   double xt() const { return matrix_[ 3]; }
0151 
0152   /**
0153    *   The yx component
0154    */
0155   double yx() const { return matrix_[ 4]; }
0156 
0157   /**
0158    *   The yy component
0159    */
0160   double yy() const { return matrix_[ 5]; }
0161 
0162   /**
0163    *   The yz component
0164    */
0165   double yz() const { return matrix_[ 6]; }
0166 
0167   /**
0168    *   The yt component
0169    */
0170   double yt() const { return matrix_[ 7]; }
0171 
0172   /**
0173    *   The zx component
0174    */
0175   double zx() const { return matrix_[ 8]; }
0176 
0177   /**
0178    *   The zy component
0179    */
0180   double zy() const { return matrix_[ 9]; }
0181 
0182   /**
0183    *   The zz component
0184    */
0185   double zz() const { return matrix_[10]; }
0186 
0187   /**
0188    *   The zt component
0189    */
0190   double zt() const { return matrix_[11]; }
0191 
0192   /**
0193    *   The tx component
0194    */
0195   double tx() const { return matrix_[12]; }
0196 
0197   /**
0198    *   The ty component
0199    */
0200   double ty() const { return matrix_[13]; }
0201 
0202   /**
0203    *   The tz component
0204    */
0205   double tz() const { return matrix_[14]; }
0206 
0207   /**
0208    *   The tt component
0209    */
0210   double tt() const { return matrix_[15]; }
0211   //@}
0212 
0213   /** @name Transformation and product members */
0214   //@{
0215 
0216   /**
0217    * Product with a LorentzVector simply returns the rotated vector.
0218    */
0219   template <typename Value>
0220   LorentzVector<Value>
0221   operator*(const LorentzVector<Value> & v) const {
0222     return LorentzVector<Value>
0223       (xx()*v.x() + xy()*v.y() + xz()*v.z() + xt()*v.t(),
0224        yx()*v.x() + yy()*v.y() + yz()*v.z() + yt()*v.t(),
0225        zx()*v.x() + zy()*v.y() + zz()*v.z() + zt()*v.t(),
0226        tx()*v.x() + ty()*v.y() + tz()*v.z() + tt()*v.t());
0227   }
0228 
0229   /**
0230    * Product with a Lorentz5Vector simply returns the rotated vector.
0231    */
0232   template <typename Value>
0233   Lorentz5Vector<Value>
0234   operator*(const Lorentz5Vector<Value> & v) const {
0235     return Lorentz5Vector<Value>
0236       (xx()*v.x() + xy()*v.y() + xz()*v.z() + xt()*v.t(),
0237        yx()*v.x() + yy()*v.y() + yz()*v.z() + yt()*v.t(),
0238        zx()*v.x() + zy()*v.y() + zz()*v.z() + zt()*v.t(),
0239        tx()*v.x() + ty()*v.y() + tz()*v.z() + tt()*v.t());
0240   }
0241 
0242   /**
0243    * Product of two LorentzRotations (this) * lt - matrix multiplication  
0244    * @param lt The LorentzRotation we are multiplying
0245    */
0246   SpinOneLorentzRotation operator * (const SpinOneLorentzRotation & lt) const;
0247 
0248   /**
0249    * Multiply by and assign a*=b becomes a= a*b
0250    */
0251   SpinOneLorentzRotation & operator *= (const SpinOneLorentzRotation & lt) {
0252     return *this = *this * lt;
0253   }
0254 
0255   /**
0256    *  Transform  (similar to *= but a.transform(b) becomes a = b*a
0257    */
0258   SpinOneLorentzRotation & transform   (const SpinOneLorentzRotation & lt) {
0259     return *this = lt * *this;
0260   }
0261 
0262   /**
0263    * Rotation around the x-axis; equivalent to LT = RotationX(delta) * LT
0264    */
0265   SpinOneLorentzRotation & rotateX(double delta) {
0266     SpinOneLorentzRotation tmp;
0267     tmp.setRotateX(delta);
0268     return *this = tmp * *this;
0269   }
0270 
0271   /**
0272    * Rotation around the y-axis; equivalent to LT = RotationY(delta) * LT
0273    */
0274   SpinOneLorentzRotation & rotateY(double delta) {
0275     SpinOneLorentzRotation tmp;
0276     tmp.setRotateY(delta);
0277     return *this = tmp * *this;
0278   }
0279 
0280   /**
0281    * Rotation around the z-axis; equivalent to LT = RotationZ(delta) * LT
0282    */
0283   SpinOneLorentzRotation & rotateZ(double delta) {
0284     SpinOneLorentzRotation tmp;
0285     tmp.setRotateZ(delta);
0286     return *this = tmp * *this;
0287   }
0288   
0289   /**
0290    *  Rotation around specified vector - LT = Rotation(delta,axis)*LT
0291    */
0292   SpinOneLorentzRotation & rotate(double delta, const Axis & axis) {
0293     SpinOneLorentzRotation tmp;
0294     tmp.setRotate(delta, axis);
0295     return *this = tmp * *this;
0296   }
0297 
0298   /**
0299    * Pure boost along the x-axis; equivalent to LT = BoostX(beta) * LT
0300    */
0301   SpinOneLorentzRotation & boostX(double beta) {
0302     return *this = SpinOneLorentzRotation(beta,0,0) * *this;
0303   }
0304 
0305   /**
0306    * Pure boost along the y-axis; equivalent to LT = BoostX(beta) * LT
0307    */
0308   SpinOneLorentzRotation & boostY(double beta) {
0309     return *this = SpinOneLorentzRotation(0,beta,0) * *this;
0310   }
0311 
0312   /**
0313    * Pure boost along the z-axis; equivalent to LT = BoostX(beta) * LT
0314    */
0315   SpinOneLorentzRotation & boostZ(double beta) {
0316     return *this = SpinOneLorentzRotation(0,0,beta) * *this;
0317   }
0318 
0319   /**
0320    *  boost equivalent to LT = Boost(bx,by,bz) * LT
0321    * @param bx The x-component of the boost
0322    * @param by The y-component of the boost
0323    * @param bz The z-component of the boost
0324    * @param gamma The \f$\gamma\f$ factor (optional)
0325    */
0326   SpinOneLorentzRotation & boost(double bx, double by, double bz,
0327                  double gamma=-1.) {
0328     return *this = SpinOneLorentzRotation(bx,by,bz,gamma) * *this;
0329   }
0330 
0331   /**
0332    *  boost equivalent to LT = Boost(bv) * LT
0333    * @param b The boost vector
0334    * @param gamma The \f$\gamma\f$ factor (optional)
0335    */
0336   SpinOneLorentzRotation & boost(const Boost & b, double gamma=-1.) {
0337     return *this = SpinOneLorentzRotation(b.x(),b.y(),b.z(),gamma) * *this;
0338   }
0339   //@}
0340 
0341 private:
0342 
0343   template<typename Value> friend class Helicity::LorentzTensor;
0344   template<typename Value> friend class Helicity::LorentzRank3Tensor;
0345   template<typename Value> friend class Helicity::LorentzRSSpinor;
0346   template<typename Value> friend class Helicity::LorentzRSSpinorBar;
0347 
0348   /// Matrix components, order: \f$(xx, xy, \ldots, tz, tt)\f$.
0349   array<double,16> matrix_ = {};
0350 
0351   /// Constructor from doubles.
0352   SpinOneLorentzRotation (double xx, double xy, double xz, double xt,
0353               double yx, double yy, double yz, double yt,
0354               double zx, double zy, double zz, double zt,
0355               double tx, double ty, double tz, double tt);
0356 
0357   /// Component access by index: x=0, t=3.
0358   double operator()(unsigned int i, unsigned int j) const {
0359     return matrix_[4*i + j];
0360   }
0361 
0362   /// @name Component access.
0363   //@{
0364   double & xx_() { return matrix_[ 0]; }
0365   double & xy_() { return matrix_[ 1]; }
0366   double & xz_() { return matrix_[ 2]; }
0367   double & xt_() { return matrix_[ 3]; }
0368 
0369   double & yx_() { return matrix_[ 4]; }
0370   double & yy_() { return matrix_[ 5]; }
0371   double & yz_() { return matrix_[ 6]; }
0372   double & yt_() { return matrix_[ 7]; }
0373 
0374   double & zx_() { return matrix_[ 8]; }
0375   double & zy_() { return matrix_[ 9]; }
0376   double & zz_() { return matrix_[10]; }
0377   double & zt_() { return matrix_[11]; }
0378 
0379   double & tx_() { return matrix_[12]; }
0380   double & ty_() { return matrix_[13]; }
0381   double & tz_() { return matrix_[14]; }
0382   double & tt_() { return matrix_[15]; }
0383   //@}
0384 };
0385 
0386 /**
0387  *  output operator
0388  */
0389 inline std::ostream & operator<< ( std::ostream & os,
0390                    const  SpinOneLorentzRotation& lt ) {
0391   return lt.print(os);
0392 }
0393 
0394 }
0395 
0396 #endif /* ThePEG_SpinOneLorentzRotation_H */