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 EVTVECTOR3C_N
0022 #define EVTVECTOR3C_N
0023 
0024 #include "EvtGenBase/EvtComplex.hh"
0025 #include "EvtGenBase/EvtVector3R.hh"
0026 
0027 #include <iosfwd>
0028 
0029 class EvtVector3C final {
0030     friend EvtVector3C rotateEuler( const EvtVector3C& v, double phi,
0031                                     double theta, double ksi );
0032 
0033     inline friend EvtVector3C operator*( const EvtComplex& c,
0034                                          const EvtVector3C& v2 );
0035     inline friend EvtVector3C operator*( const EvtComplex& c,
0036                                          const EvtVector3R& v2 );
0037     inline friend EvtComplex operator*( const EvtVector3R& v1,
0038                                         const EvtVector3C& v2 );
0039     inline friend EvtComplex operator*( const EvtVector3C& v1,
0040                                         const EvtVector3R& v2 );
0041     inline friend EvtComplex operator*( const EvtVector3C& v1,
0042                                         const EvtVector3C& v2 );
0043     inline friend EvtVector3C operator+( const EvtVector3C& v1,
0044                                          const EvtVector3C& v2 );
0045     inline friend EvtVector3C operator-( const EvtVector3C& v1,
0046                                          const EvtVector3C& v2 );
0047     inline friend EvtVector3C operator*( const EvtVector3C& v1,
0048                                          const EvtComplex& c );
0049 
0050   public:
0051     EvtVector3C();
0052     EvtVector3C( const EvtComplex&, const EvtComplex&, const EvtComplex& );
0053     inline void set( const int, const EvtComplex& );
0054     inline void set( const EvtComplex&, const EvtComplex&, const EvtComplex& );
0055     inline void set( double, double, double );
0056     inline EvtVector3C& operator*=( const EvtComplex& c );
0057     inline EvtVector3C& operator/=( const EvtComplex& c );
0058     inline EvtVector3C& operator+=( const EvtVector3C& v2 );
0059     inline EvtVector3C& operator-=( const EvtVector3C& v2 );
0060     inline EvtVector3C( const EvtVector3R& v1 );
0061     void applyRotateEuler( double phi, double theta, double ksi );
0062     inline const EvtComplex& get( int ) const;
0063     inline EvtVector3C conj() const;
0064     EvtVector3C cross( const EvtVector3C& v2 );
0065     friend std::ostream& operator<<( std::ostream& c, const EvtVector3C& v );
0066     double dot( const EvtVector3C& p2 );
0067 
0068   private:
0069     EvtComplex v[3];
0070 };
0071 
0072 inline EvtVector3C::EvtVector3C( const EvtVector3R& v1 )
0073 {
0074     v[0] = EvtComplex( v1.get( 0 ), 0.0 );
0075     v[1] = EvtComplex( v1.get( 1 ), 0.0 );
0076     v[2] = EvtComplex( v1.get( 2 ), 0.0 );
0077 }
0078 
0079 inline void EvtVector3C::set( const int i, const EvtComplex& c )
0080 {
0081     v[i] = c;
0082 }
0083 
0084 inline void EvtVector3C::set( const EvtComplex& x, const EvtComplex& y,
0085                               const EvtComplex& z )
0086 {
0087     v[0] = x;
0088     v[1] = y;
0089     v[2] = z;
0090 }
0091 
0092 inline void EvtVector3C::set( double x, double y, double z )
0093 {
0094     v[0] = EvtComplex( x );
0095     v[1] = EvtComplex( y );
0096     v[2] = EvtComplex( z );
0097 }
0098 
0099 inline const EvtComplex& EvtVector3C::get( int i ) const
0100 {
0101     return v[i];
0102 }
0103 
0104 inline EvtVector3C& EvtVector3C::operator*=( const EvtComplex& c )
0105 {
0106     v[0] *= c;
0107     v[1] *= c;
0108     v[2] *= c;
0109     return *this;
0110 }
0111 
0112 inline EvtVector3C& EvtVector3C::operator/=( const EvtComplex& c )
0113 {
0114     v[0] /= c;
0115     v[1] /= c;
0116     v[2] /= c;
0117     return *this;
0118 }
0119 
0120 inline EvtVector3C& EvtVector3C::operator+=( const EvtVector3C& v2 )
0121 {
0122     v[0] += v2.v[0];
0123     v[1] += v2.v[1];
0124     v[2] += v2.v[2];
0125     return *this;
0126 }
0127 
0128 inline EvtVector3C& EvtVector3C::operator-=( const EvtVector3C& v2 )
0129 {
0130     v[0] -= v2.v[0];
0131     v[1] -= v2.v[1];
0132     v[2] -= v2.v[2];
0133     return *this;
0134 }
0135 
0136 inline EvtVector3C operator+( const EvtVector3C& v1, const EvtVector3C& v2 )
0137 {
0138     return EvtVector3C( v1 ) += v2;
0139 }
0140 
0141 inline EvtVector3C operator-( const EvtVector3C& v1, const EvtVector3C& v2 )
0142 {
0143     return EvtVector3C( v1 ) -= v2;
0144 }
0145 
0146 inline EvtVector3C operator*( const EvtVector3C& v1, const EvtComplex& c )
0147 {
0148     return EvtVector3C( v1 ) *= c;
0149 }
0150 
0151 inline EvtVector3C operator*( const EvtComplex& c, const EvtVector3C& v2 )
0152 {
0153     return EvtVector3C( v2 ) *= c;
0154 }
0155 
0156 inline EvtVector3C operator*( const EvtComplex& c, const EvtVector3R& v2 )
0157 {
0158     return EvtVector3C( v2 ) *= c;
0159 }
0160 
0161 inline EvtComplex operator*( const EvtVector3R& v1, const EvtVector3C& v2 )
0162 {
0163     return v1.get( 0 ) * v2.v[0] + v1.get( 1 ) * v2.v[1] + v1.get( 2 ) * v2.v[2];
0164 }
0165 
0166 inline EvtComplex operator*( const EvtVector3C& v1, const EvtVector3R& v2 )
0167 {
0168     return v1.v[0] * v2.get( 0 ) + v1.v[1] * v2.get( 1 ) + v1.v[2] * v2.get( 2 );
0169 }
0170 
0171 inline EvtComplex operator*( const EvtVector3C& v1, const EvtVector3C& v2 )
0172 {
0173     return v1.v[0] * v2.v[0] + v1.v[1] * v2.v[1] + v1.v[2] * v2.v[2];
0174 }
0175 
0176 inline EvtVector3C EvtVector3C::conj() const
0177 {
0178     return EvtVector3C( ::conj( v[0] ), ::conj( v[1] ), ::conj( v[2] ) );
0179 }
0180 
0181 #endif