Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:20:02

0001 
0002 /***********************************************************************
0003 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
0004 *                                                                      *
0005 * This file is part of EvtGen.                                         *
0006 *                                                                      *
0007 * EvtGen is free software: you can redistribute it and/or modify       *
0008 * it under the terms of the GNU General Public License as published by *
0009 * the Free Software Foundation, either version 3 of the License, or    *
0010 * (at your option) any later version.                                  *
0011 *                                                                      *
0012 * EvtGen is distributed in the hope that it will be useful,            *
0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
0015 * GNU General Public License for more details.                         *
0016 *                                                                      *
0017 * You should have received a copy of the GNU General Public License    *
0018 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
0019 ***********************************************************************/
0020 
0021 #ifndef EVTGAMMAMATRIX_HH
0022 #define EVTGAMMAMATRIX_HH
0023 
0024 #include "EvtGenBase/EvtComplex.hh"
0025 #include "EvtGenBase/EvtDiracSpinor.hh"    // needed for adjoint
0026 //#include <iostream.h>
0027 #include <iosfwd>
0028 class EvtGammaMatrix;
0029 class EvtVector4C;
0030 
0031 namespace EvtGenFunctions {
0032     // slash or Feynman slash a 4-vector
0033     EvtGammaMatrix slash( const EvtVector4C& p );
0034     EvtGammaMatrix slash( const EvtVector4R& p );
0035 }    // namespace EvtGenFunctions
0036 
0037 // Description: Class to manipulate gamma matrices. The reperesentation
0038 //              used is the "standard" Dirac representation.
0039 
0040 class EvtGammaMatrix final {
0041     friend EvtGammaMatrix operator*( const EvtComplex& c,
0042                                      const EvtGammaMatrix& g );
0043     friend EvtGammaMatrix operator*( const EvtGammaMatrix& g,
0044                                      const EvtComplex& c );
0045     friend EvtGammaMatrix operator/( const EvtGammaMatrix& g, const double d );
0046     friend EvtDiracSpinor operator*( const EvtGammaMatrix& g,
0047                                      const EvtDiracSpinor& d );
0048     friend EvtGammaMatrix operator+( const EvtGammaMatrix& g1,
0049                                      const EvtGammaMatrix& g2 );
0050     friend EvtGammaMatrix operator-( const EvtGammaMatrix& g1,
0051                                      const EvtGammaMatrix& g2 );
0052     friend EvtGammaMatrix operator*( const EvtGammaMatrix& g1,
0053                                      const EvtGammaMatrix& g2 );
0054     friend std::ostream& operator<<( std::ostream& s, const EvtGammaMatrix& v );
0055     friend EvtDiracSpinor EvtDiracSpinor::adjoint() const;
0056 
0057   public:
0058     EvtGammaMatrix();
0059     EvtGammaMatrix( const EvtGammaMatrix& gm );
0060     EvtGammaMatrix& operator=( const EvtGammaMatrix& gm );
0061 
0062     void init();
0063     static const EvtGammaMatrix& g( int );
0064     static const EvtGammaMatrix& g0();
0065     static const EvtGammaMatrix& g1();
0066     static const EvtGammaMatrix& g2();
0067     static const EvtGammaMatrix& g3();
0068     static const EvtGammaMatrix& g5();
0069     static const EvtGammaMatrix& id();
0070     static const EvtGammaMatrix& va0();
0071     static const EvtGammaMatrix& va1();
0072     static const EvtGammaMatrix& va2();
0073     static const EvtGammaMatrix& va3();
0074     static const EvtGammaMatrix& v0();
0075     static const EvtGammaMatrix& v1();
0076     static const EvtGammaMatrix& v2();
0077     static const EvtGammaMatrix& v3();
0078     // Dirac sigma matrix with upper or lower indices (only one element)
0079     static const EvtGammaMatrix& sigmaUpper( unsigned int mu, unsigned int nu );
0080     static const EvtGammaMatrix& sigmaLower( unsigned int mu, unsigned int nu );
0081 
0082     EvtGammaMatrix& operator+=( const EvtGammaMatrix& g );
0083     EvtGammaMatrix& operator-=( const EvtGammaMatrix& g );
0084     EvtGammaMatrix& operator*=( const EvtGammaMatrix& g );
0085 
0086   private:
0087     EvtComplex _gamma[4][4];
0088 };
0089 
0090 inline EvtGammaMatrix operator+( const EvtGammaMatrix& g1,
0091                                  const EvtGammaMatrix& g2 )
0092 {
0093     return EvtGammaMatrix( g1 ) += g2;
0094 }
0095 
0096 inline EvtGammaMatrix operator-( const EvtGammaMatrix& g1,
0097                                  const EvtGammaMatrix& g2 )
0098 {
0099     return EvtGammaMatrix( g1 ) -= g2;
0100 }
0101 
0102 inline EvtGammaMatrix operator*( const EvtGammaMatrix& g1,
0103                                  const EvtGammaMatrix& g2 )
0104 {
0105     return EvtGammaMatrix( g1 ) *= g2;
0106 }
0107 
0108 inline EvtGammaMatrix operator/( const EvtGammaMatrix& g, const double d )
0109 {
0110     return g * EvtComplex( 1 / d, 0 );
0111 }
0112 
0113 #endif