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 EVTDIRACSPINOR_HH
0022 #define EVTDIRACSPINOR_HH
0023 
0024 #include "EvtGenBase/EvtComplex.hh"
0025 #include "EvtGenBase/EvtVector3R.hh"
0026 #include "EvtGenBase/EvtVector4R.hh"
0027 
0028 class EvtTensor4C;
0029 class EvtVector4C;
0030 class EvtDiracSpinor;
0031 
0032 class EvtDiracSpinor final {
0033     friend EvtDiracSpinor rotateEuler( const EvtDiracSpinor& sp, double alpha,
0034                                        double beta, double gamma );
0035     friend EvtDiracSpinor boostTo( const EvtDiracSpinor& sp,
0036                                    const EvtVector4R p4 );
0037     friend EvtDiracSpinor boostTo( const EvtDiracSpinor& sp,
0038                                    const EvtVector3R boost );
0039     friend EvtVector4C EvtLeptonVACurrent( const EvtDiracSpinor& d,
0040                                            const EvtDiracSpinor& dp );
0041     friend EvtVector4C EvtLeptonVCurrent( const EvtDiracSpinor& d,
0042                                           const EvtDiracSpinor& dp );
0043     friend EvtVector4C EvtLeptonACurrent( const EvtDiracSpinor& d,
0044                                           const EvtDiracSpinor& dp );
0045     friend EvtComplex EvtLeptonSCurrent( const EvtDiracSpinor& d,
0046                                          const EvtDiracSpinor& dp );
0047     friend EvtComplex EvtLeptonPCurrent( const EvtDiracSpinor& d,
0048                                          const EvtDiracSpinor& dp );
0049     friend EvtTensor4C EvtLeptonTCurrent( const EvtDiracSpinor& d,
0050                                           const EvtDiracSpinor& dp );
0051     friend EvtDiracSpinor operator+( const EvtDiracSpinor& u1,
0052                                      const EvtDiracSpinor& u2 );
0053     friend EvtDiracSpinor operator-( const EvtDiracSpinor& u1,
0054                                      const EvtDiracSpinor& u2 );
0055     friend EvtDiracSpinor operator*( const EvtComplex& c,
0056                                      const EvtDiracSpinor& d );
0057 
0058     friend EvtComplex operator*( const EvtDiracSpinor& d,
0059                                  const EvtDiracSpinor& dp );
0060 
0061     friend std::ostream& operator<<( std::ostream& s, const EvtDiracSpinor& c );
0062 
0063   public:
0064     inline EvtDiracSpinor();
0065     EvtDiracSpinor( const EvtComplex& sp0, const EvtComplex& sp1,
0066                     const EvtComplex& sp2, const EvtComplex& sp3 );
0067     inline EvtDiracSpinor( const EvtDiracSpinor& dspinor );
0068     inline EvtDiracSpinor& operator=( const EvtDiracSpinor& dspinor );
0069 
0070     inline EvtDiracSpinor& operator+=( const EvtDiracSpinor& u2 );
0071     inline EvtDiracSpinor& operator-=( const EvtDiracSpinor& u2 );
0072 
0073     void set( const EvtComplex& sp0, const EvtComplex& sp1,
0074               const EvtComplex& sp2, const EvtComplex& sp3 );
0075     void set_spinor( int i, const EvtComplex& sp );
0076     const EvtComplex& get_spinor( int i ) const;
0077     EvtDiracSpinor conj() const;
0078     void applyRotateEuler( double alpha, double beta, double gamma );
0079     void applyBoostTo( const EvtVector4R& p4 );
0080     void applyBoostTo( const EvtVector3R& boost );
0081     EvtDiracSpinor adjoint() const;
0082 
0083   private:
0084     EvtComplex spinor[4];
0085 };
0086 
0087 EvtDiracSpinor::EvtDiracSpinor()
0088 {
0089     spinor[0] = EvtComplex();
0090     spinor[1] = EvtComplex();
0091     spinor[2] = EvtComplex();
0092     spinor[3] = EvtComplex();
0093 }
0094 
0095 EvtDiracSpinor::EvtDiracSpinor( const EvtDiracSpinor& dspinor )
0096 {
0097     spinor[0] = dspinor.spinor[0];
0098     spinor[1] = dspinor.spinor[1];
0099     spinor[2] = dspinor.spinor[2];
0100     spinor[3] = dspinor.spinor[3];
0101 }
0102 
0103 EvtDiracSpinor& EvtDiracSpinor::operator=( const EvtDiracSpinor& dspinor )
0104 {
0105     spinor[0] = dspinor.spinor[0];
0106     spinor[1] = dspinor.spinor[1];
0107     spinor[2] = dspinor.spinor[2];
0108     spinor[3] = dspinor.spinor[3];
0109 
0110     return *this;
0111 }
0112 
0113 inline EvtDiracSpinor& EvtDiracSpinor::operator+=( const EvtDiracSpinor& u2 )
0114 {
0115     spinor[0] += u2.spinor[0];
0116     spinor[1] += u2.spinor[1];
0117     spinor[2] += u2.spinor[2];
0118     spinor[3] += u2.spinor[3];
0119 
0120     return *this;
0121 }
0122 
0123 inline EvtDiracSpinor operator+( const EvtDiracSpinor& u1,
0124                                  const EvtDiracSpinor& u2 )
0125 {
0126     return EvtDiracSpinor( u1 ) += u2;
0127 }
0128 
0129 inline EvtDiracSpinor& EvtDiracSpinor::operator-=( const EvtDiracSpinor& u2 )
0130 {
0131     spinor[0] -= u2.spinor[0];
0132     spinor[1] -= u2.spinor[1];
0133     spinor[2] -= u2.spinor[2];
0134     spinor[3] -= u2.spinor[3];
0135 
0136     return *this;
0137 }
0138 
0139 inline EvtDiracSpinor operator-( const EvtDiracSpinor& u1,
0140                                  const EvtDiracSpinor& u2 )
0141 {
0142     return EvtDiracSpinor( u1 ) -= u2;
0143 }
0144 
0145 #endif