#include "ATOOLS/Phys/Spinor.H" #include "ATOOLS/Org/Exception.H" using namespace ATOOLS; // #define TEST_Representation template double Spinor::s_accu(1.0e-12); template std::ostream & ATOOLS::operator<<(std::ostream &ostr,const Spinor &s) { return ostr<<"|"<0?">":"]"); } template void Spinor::SetGauge(const int gauge) { switch (gauge) { case 0: s_r1=1; s_r2=2; s_r3=3; break; case 1: s_r1=2; s_r2=3; s_r3=1; break; case 2: s_r1=3; s_r2=1; s_r3=2; break; default: THROW(fatal_error,"Gauge choice not implemented"); } } template Vec4 Spinor::GetK0() { Vec4 k0(1.0,0.0,0.0,0.0); k0[R3()]=-1.0; return k0; } template Vec4 Spinor::GetK1() { Vec4 k1(0.0,0.0,0.0,0.0); k1[R1()]=1.0; return k1; } template void Spinor::Construct(const Vec4 &p) { double pp(PPlus(p)), pm(PMinus(p)); Complex rpp(csqrt(pp)), rpm(csqrt(pm)), pt(PT(p)); m_u1=rpp; m_u2=rpm; Scalar sv(dabs(p[0])*s_accu); if ((dabs(pt.real())>sv || dabs(pt.imag())>sv) && (dabs(rpp.real())>sv || dabs(rpp.imag())>sv)) { m_u2=Complex(pt.real(),m_r>0?pt.imag():-pt.imag())/rpp; } #ifndef USING__old_phase_convention if (pp<0.0 || pm<0.0) { if (m_r<0) { m_u1=Complex(-m_u1.imag(),m_u1.real()); m_u2=Complex(-m_u2.imag(),m_u2.real()); } else { m_u1=-Complex(-m_u1.imag(),m_u1.real()); m_u2=-Complex(-m_u2.imag(),m_u2.real()); } } #endif } template std::complex Spinor::operator*(const Spinor &s) const { #ifdef TEST_Representation if (m_r!=s.m_r) { msg_Error()< bool Spinor::operator==(const Spinor &s) const { Scalar max(Max(std::abs(m_u1),std::abs(m_u2))); Scalar q(IsZero(max)?1.0:1.0/max); if (std::abs(q*(m_u1-s.m_u1))>Accuracy()) return false; if (std::abs(q*(m_u2-s.m_u2))>Accuracy()) return false; return true; } template Spinor Spinor::operator*(const Scalar &d) const { return Spinor(m_r,m_u1*d,m_u2*d); } template Spinor Spinor::operator*(const SComplex &c) const { return Spinor(m_r,m_u1*c,m_u2*c); } template Spinor Spinor::operator/(const Scalar &d) const { return Spinor(m_r,m_u1/d,m_u2/d); } template Spinor Spinor::operator/(const SComplex &c) const { return Spinor(m_r,m_u1/c,m_u2/c); } template Spinor Spinor::operator*=(const Scalar &d) { m_u1*=d; m_u2*=d; return *this; } template Spinor Spinor::operator*=(const SComplex &c) { m_u1*=c; m_u2*=c; return *this; } template Spinor Spinor::operator/=(const Scalar &d) { m_u1/=d; m_u2/=d; return *this; } template Spinor Spinor::operator/=(const SComplex &c) { m_u1/=c; m_u2/=c; return *this; } template Spinor Spinor::operator+(const Spinor &s) const { return Spinor(m_r,m_u1+s.m_u1,m_u2+s.m_u2); } template Spinor Spinor::operator-(const Spinor &s) const { return Spinor(m_r,m_u1-s.m_u1,m_u2-s.m_u2); } template Spinor Spinor::operator+=(const Spinor &s) { m_u1+=s.m_u1; m_u2+=s.m_u2; return *this; } template Spinor Spinor::operator-=(const Spinor &s) { m_u1-=s.m_u1; m_u2-=s.m_u2; return *this; } namespace ATOOLS { template class DWSpinor; template std::ostream &operator<<(std::ostream &ostr,const DWSpinor &s); template class QWSpinor; template std::ostream &operator<<(std::ostream &ostr,const QWSpinor &s); }