Back to home page

EIC code displayed by LXR

 
 

    


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

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 EvtTensor4C_HH
0022 #define EvtTensor4C_HH
0023 
0024 #include "EvtGenBase/EvtComplex.hh"
0025 
0026 //Class to handle 4D complex valued tensors.
0027 class EvtTensor4C;
0028 class EvtVector4C;
0029 class EvtVector4R;
0030 class EvtVector3R;
0031 
0032 namespace EvtGenFunctions {
0033     EvtTensor4C directProd( const EvtVector4R& c1, const EvtVector4R& c2 );
0034     EvtTensor4C directProd( const EvtVector4C& c1, const EvtVector4C& c2 );
0035     EvtTensor4C directProd( const EvtVector4C& c1, const EvtVector4R& c2 );
0036 }    // namespace EvtGenFunctions
0037 
0038 class EvtTensor4C final {
0039     friend EvtTensor4C EvtGenFunctions::directProd( const EvtVector4R& c1,
0040                                                     const EvtVector4R& c2 );
0041     friend EvtTensor4C EvtGenFunctions::directProd( const EvtVector4C& c1,
0042                                                     const EvtVector4C& c2 );
0043     friend EvtTensor4C EvtGenFunctions::directProd( const EvtVector4C& c1,
0044                                                     const EvtVector4R& c2 );
0045 
0046     friend EvtTensor4C rotateEuler( const EvtTensor4C& e, double alpha,
0047                                     double beta, double gamma );
0048     friend EvtTensor4C boostTo( const EvtTensor4C& e, const EvtVector4R p4 );
0049     friend EvtTensor4C boostTo( const EvtTensor4C& e, const EvtVector3R boost );
0050     friend EvtTensor4C dual( const EvtTensor4C& t2 );
0051     friend EvtTensor4C conj( const EvtTensor4C& t2 );
0052     friend EvtTensor4C cont22( const EvtTensor4C& t1, const EvtTensor4C& t2 );
0053     friend EvtTensor4C cont11( const EvtTensor4C& t1, const EvtTensor4C& t2 );
0054     friend EvtTensor4C operator*( const EvtTensor4C& t1, const EvtComplex& c );
0055     friend EvtTensor4C operator*( const EvtComplex& c, const EvtTensor4C& t1 );
0056     friend EvtTensor4C operator*( const EvtTensor4C& t1, double d );
0057     friend EvtTensor4C operator*( double d, const EvtTensor4C& t1 );
0058     friend EvtComplex cont( const EvtTensor4C& t1, const EvtTensor4C& t2 );
0059     friend EvtTensor4C operator+( const EvtTensor4C& t1, const EvtTensor4C& t2 );
0060     friend EvtTensor4C operator-( const EvtTensor4C& t1, const EvtTensor4C& t2 );
0061 
0062   public:
0063     EvtTensor4C() { ; }
0064 
0065     EvtTensor4C( double t00, double t11, double t22, double t33 )
0066     {
0067         setdiag( t00, t11, t22, t33 );
0068     }
0069 
0070     EvtTensor4C( const EvtTensor4C& t1 );
0071     EvtTensor4C& operator=( const EvtTensor4C& t1 );
0072     EvtTensor4C& operator*=( const EvtComplex& c );
0073     EvtTensor4C& operator*=( double d );
0074     EvtTensor4C& addDirProd( const EvtVector4R& p1, const EvtVector4R& p2 );
0075     static const EvtTensor4C& g();
0076     inline void set( int i, int j, const EvtComplex& c );
0077     void setdiag( double t00, double t11, double t22, double t33 );
0078     inline const EvtComplex& get( int i, int j ) const;
0079     inline EvtComplex trace() const;
0080     void zero();
0081     void applyRotateEuler( double alpha, double beta, double gamma );
0082     void applyBoostTo( const EvtVector4R& p4 );
0083     void applyBoostTo( const EvtVector3R& boost );
0084     friend std::ostream& operator<<( std::ostream& s, const EvtTensor4C& t );
0085     EvtTensor4C& operator+=( const EvtTensor4C& t2 );
0086     EvtTensor4C& operator-=( const EvtTensor4C& t2 );
0087     EvtTensor4C conj() const;
0088     EvtVector4C cont1( const EvtVector4C& v4 ) const;
0089     EvtVector4C cont2( const EvtVector4C& v4 ) const;
0090     EvtVector4C cont1( const EvtVector4R& v4 ) const;
0091     EvtVector4C cont2( const EvtVector4R& v4 ) const;
0092 
0093   private:
0094     EvtComplex t[4][4];
0095 };
0096 
0097 inline EvtTensor4C operator+( const EvtTensor4C& t1, const EvtTensor4C& t2 )
0098 {
0099     return EvtTensor4C( t1 ) += t2;
0100 }
0101 
0102 inline EvtTensor4C operator-( const EvtTensor4C& t1, const EvtTensor4C& t2 )
0103 {
0104     return EvtTensor4C( t1 ) -= t2;
0105 }
0106 
0107 inline void EvtTensor4C::set( int i, int j, const EvtComplex& c )
0108 {
0109     t[i][j] = c;
0110 }
0111 
0112 inline const EvtComplex& EvtTensor4C::get( int i, int j ) const
0113 {
0114     return t[i][j];
0115 }
0116 
0117 inline EvtComplex EvtTensor4C::trace() const
0118 {
0119     return t[0][0] - t[1][1] - t[2][2] - t[3][3];
0120 }
0121 
0122 #endif