Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:09

0001 // @(#)root/mathcore:$Id$
0002 // Authors: W. Brown, M. Fischler, L. Moneta    2005
0003 
0004  /**********************************************************************
0005   *                                                                    *
0006   * Copyright (c) 2005 ROOT FNAL MathLib Team                          *
0007   *                                                                    *
0008   *                                                                    *
0009   **********************************************************************/
0010 
0011 // Header file for Boost
0012 //
0013 // Created by: Mark Fischler  Mon Nov 1  2005
0014 //
0015 // Last update: $Id$
0016 //
0017 #ifndef ROOT_Math_GenVector_Boost
0018 #define ROOT_Math_GenVector_Boost 1
0019 
0020 #include "Math/GenVector/LorentzVector.h"
0021 #include "Math/GenVector/PxPyPzE4D.h"
0022 #include "Math/GenVector/DisplacementVector3D.h"
0023 #include "Math/GenVector/Cartesian3D.h"
0024 
0025 #include "Math/GenVector/BoostX.h"
0026 #include "Math/GenVector/BoostY.h"
0027 #include "Math/GenVector/BoostZ.h"
0028 
0029 namespace ROOT {
0030 
0031   namespace Math {
0032 
0033 //__________________________________________________________________________________________
0034   /**
0035      Lorentz boost class with the (4D) transformation represented internally
0036      by a 4x4 orthosymplectic matrix.
0037      See also BoostX, BoostY and BoostZ for classes representing
0038      specialized Lorentz boosts.
0039      Also, the 3-D rotation classes can be considered to be special Lorentz
0040      transformations which do not mix space and time components.
0041 
0042      @ingroup GenVector
0043 
0044      @sa Overview of the @ref GenVector "physics vector library"
0045   */
0046 
0047 class Boost {
0048 
0049 public:
0050 
0051   typedef double Scalar;
0052 
0053   enum ELorentzRotationMatrixIndex {
0054       kLXX =  0, kLXY =  1, kLXZ =  2, kLXT =  3
0055     , kLYX =  4, kLYY =  5, kLYZ =  6, kLYT =  7
0056     , kLZX =  8, kLZY =  9, kLZZ = 10, kLZT = 11
0057     , kLTX = 12, kLTY = 13, kLTZ = 14, kLTT = 15
0058   };
0059 
0060   enum EBoostMatrixIndex {
0061       kXX =  0, kXY =  1, kXZ =  2, kXT =  3
0062      , kYY =  4, kYZ =  5, kYT =  6
0063      , kZZ =  7, kZT =  8
0064      , kTT =  9
0065   };
0066 
0067   // ========== Constructors and Assignment =====================
0068 
0069   /**
0070       Default constructor (identity transformation)
0071   */
0072   Boost() { SetIdentity(); }
0073 
0074   /**
0075      Construct given a three Scalars beta_x, beta_y, and beta_z
0076    */
0077   Boost(Scalar beta_x, Scalar beta_y, Scalar beta_z)
0078    { SetComponents(beta_x, beta_y, beta_z); }
0079 
0080   /**
0081      Construct given a beta vector (which must have methods x(), y(), z())
0082    */
0083   template <class Avector>
0084   explicit
0085   Boost(const Avector & beta) { SetComponents(beta); }
0086 
0087   /**
0088      Construct given a pair of pointers or iterators defining the
0089      beginning and end of an array of three Scalars to use as beta_x, _y, and _z
0090    */
0091   template<class IT>
0092   Boost(IT begin, IT end) { SetComponents(begin,end); }
0093 
0094    /**
0095       copy constructor
0096    */
0097    Boost(Boost const & b) {
0098       *this = b;
0099    }
0100 
0101   /**
0102      Construct from an axial boost
0103   */
0104 
0105   explicit Boost( BoostX const & bx ) {SetComponents(bx.BetaVector());}
0106   explicit Boost( BoostY const & by ) {SetComponents(by.BetaVector());}
0107   explicit Boost( BoostZ const & bz ) {SetComponents(bz.BetaVector());}
0108 
0109   // The compiler-generated copy ctor, copy assignment, and dtor are OK.
0110 
0111    /**
0112       Assignment operator
0113     */
0114    Boost &
0115    operator=(Boost const & rhs ) {
0116     for (unsigned int i=0; i < 10; ++i) {
0117        fM[i] = rhs.fM[i];
0118     }
0119     return *this;
0120    }
0121 
0122   /**
0123      Assign from an axial pure boost
0124   */
0125   Boost &
0126   operator=( BoostX const & bx ) { return operator=(Boost(bx)); }
0127   Boost &
0128   operator=( BoostY const & by ) { return operator=(Boost(by)); }
0129   Boost &
0130   operator=( BoostZ const & bz ) { return operator=(Boost(bz)); }
0131 
0132   /**
0133      Re-adjust components to eliminate small deviations from a perfect
0134      orthosyplectic matrix.
0135    */
0136   void Rectify();
0137 
0138   // ======== Components ==============
0139 
0140   /**
0141      Set components from beta_x, beta_y, and beta_z
0142   */
0143   void
0144   SetComponents (Scalar beta_x, Scalar beta_y, Scalar beta_z);
0145 
0146   /**
0147      Get components into beta_x, beta_y, and beta_z
0148   */
0149   void
0150   GetComponents (Scalar& beta_x, Scalar& beta_y, Scalar& beta_z) const;
0151 
0152   /**
0153      Set components from a beta vector
0154   */
0155   template <class Avector>
0156   void
0157   SetComponents (const Avector & beta)
0158    { SetComponents(beta.x(), beta.y(), beta.z()); }
0159 
0160   /**
0161      Set given a pair of pointers or iterators defining the beginning and end of
0162      an array of three Scalars to use as beta_x,beta _y, and beta_z
0163    */
0164   template<class IT>
0165   void SetComponents(IT begin, IT end) {
0166     IT a = begin; IT b = ++begin; IT c = ++begin;
0167     (void)end;
0168     assert (++begin==end);
0169     SetComponents (*a, *b, *c);
0170   }
0171 
0172   /**
0173      Get given a pair of pointers or iterators defining the beginning and end of
0174      an array of three Scalars into which to place beta_x, beta_y, and beta_z
0175    */
0176   template<class IT>
0177   void GetComponents(IT begin, IT end) const {
0178     IT a = begin; IT b = ++begin; IT c = ++begin;
0179     (void)end;
0180     assert (++begin==end);
0181     GetComponents (*a, *b, *c);
0182   }
0183 
0184   /**
0185      Get given a pointer or an iterator defining the beginning of
0186      an array into which to place beta_x, beta_y, and beta_z
0187    */
0188   template<class IT>
0189   void GetComponents(IT begin ) const {
0190      double bx,by,bz = 0;
0191      GetComponents (bx,by,bz);
0192      *begin++ = bx;
0193      *begin++ = by;
0194      *begin = bz;
0195   }
0196 
0197   /**
0198      The beta vector for this boost
0199    */
0200   typedef  DisplacementVector3D<Cartesian3D<double>, DefaultCoordinateSystemTag > XYZVector;
0201   XYZVector BetaVector() const;
0202 
0203   /**
0204      Get elements of internal 4x4 symmetric representation, into a data
0205      array suitable for direct use as the components of a LorentzRotation
0206      Note -- 16 Scalars will be written into the array; if the array is not
0207      that large, then this will lead to undefined behavior.
0208   */
0209   void
0210   GetLorentzRotation (Scalar r[]) const;
0211 
0212   // =========== operations ==============
0213 
0214   /**
0215      Lorentz transformation operation on a Minkowski ('Cartesian')
0216      LorentzVector
0217   */
0218   LorentzVector< ROOT::Math::PxPyPzE4D<double> >
0219   operator() (const LorentzVector< ROOT::Math::PxPyPzE4D<double> > & v) const;
0220 
0221   /**
0222      Lorentz transformation operation on a LorentzVector in any
0223      coordinate system
0224    */
0225   template <class CoordSystem>
0226   LorentzVector<CoordSystem>
0227   operator() (const LorentzVector<CoordSystem> & v) const {
0228     LorentzVector< PxPyPzE4D<double> > xyzt(v);
0229     LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt);
0230     return LorentzVector<CoordSystem> ( r_xyzt );
0231   }
0232 
0233   /**
0234      Lorentz transformation operation on an arbitrary 4-vector v.
0235      Preconditions:  v must implement methods x(), y(), z(), and t()
0236      and the arbitrary vector type must have a constructor taking (x,y,z,t)
0237    */
0238   template <class Foreign4Vector>
0239   Foreign4Vector
0240   operator() (const Foreign4Vector & v) const {
0241     LorentzVector< PxPyPzE4D<double> > xyzt(v);
0242     LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt);
0243     return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() );
0244   }
0245 
0246   /**
0247      Overload operator * for boost on a vector
0248    */
0249   template <class A4Vector>
0250   inline
0251   A4Vector operator* (const A4Vector & v) const
0252   {
0253     return operator()(v);
0254   }
0255 
0256   /**
0257       Invert a Boost in place
0258    */
0259   void Invert();
0260 
0261   /**
0262       Return inverse of  a boost
0263    */
0264   Boost Inverse() const;
0265 
0266   /**
0267      Equality/inequality operators
0268    */
0269   bool operator == (const Boost & rhs) const {
0270     for (unsigned int i=0; i < 10; ++i) {
0271       if( fM[i] != rhs.fM[i] )  return false;
0272     }
0273     return true;
0274   }
0275   bool operator != (const Boost & rhs) const {
0276     return ! operator==(rhs);
0277   }
0278 
0279 protected:
0280 
0281   void SetIdentity();
0282 
0283 private:
0284 
0285   Scalar fM[10];
0286 
0287 };  // Boost
0288 
0289 // ============ Class Boost ends here ============
0290 
0291 /**
0292    Stream Output and Input
0293  */
0294   // TODO - I/O should be put in the manipulator form
0295 
0296 std::ostream & operator<< (std::ostream & os, const Boost & b);
0297 
0298 
0299 } //namespace Math
0300 } //namespace ROOT
0301 
0302 
0303 
0304 
0305 
0306 
0307 
0308 #endif /* ROOT_Math_GenVector_Boost  */