Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:24

0001 // HelicityBasics.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2024 Philip Ilten, Torbjorn Sjostrand.
0003 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0004 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0005 
0006 // Header file for a number of helper classes used in tau decays.
0007 
0008 #ifndef Pythia8_HelicityBasics_H
0009 #define Pythia8_HelicityBasics_H
0010 
0011 #include "Pythia8/Basics.h"
0012 #include "Pythia8/Event.h"
0013 #include "Pythia8/PythiaComplex.h"
0014 #include "Pythia8/PythiaStdlib.h"
0015 
0016 namespace Pythia8 {
0017 
0018 //==========================================================================
0019 
0020 // The Wave4 class provides a class for complex four-vector wave functions.
0021 // The Wave4 class can be multiplied with the GammaMatrix class to allow
0022 // for the writing of helicity matrix elements.
0023 
0024 class Wave4 {
0025 
0026 public:
0027 
0028   // Constructors and destructor.
0029   Wave4() {};
0030   Wave4(complex v0, complex v1, complex v2, complex v3) {val[0] = v0;
0031     val[1] = v1; val[2] = v2; val[3] = v3;}
0032   Wave4(Vec4 v) {val[0] = v.e(); val[1] = v.px(); val[2] = v.py();
0033     val[3] = v.pz();}
0034   ~Wave4() {};
0035 
0036   // Access an element of the wave vector.
0037   complex& operator() (int i) {return val[i];}
0038 
0039   // Wave4 + Wave4.
0040   Wave4 operator+(Wave4 w) {return Wave4( val[0] + w.val[0],
0041     val[1] + w.val[1], val[2] + w.val[2], val[3] + w.val[3]);}
0042 
0043   // Wave4 - Wave4.
0044   Wave4 operator-(Wave4 w) {return Wave4( val[0] - w.val[0],
0045     val[1] - w.val[1], val[2] - w.val[2], val[3] - w.val[3]);}
0046 
0047   // - Wave4.
0048   Wave4 operator-() {return Wave4(-val[0], -val[1], -val[2], -val[3]);}
0049 
0050   // Wave4 * Wave4.
0051   complex operator*(Wave4 w) {return val[0] * w.val[0]
0052     + val[1] * w.val[1] + val[2] * w.val[2] + val[3] * w.val[3];}
0053 
0054   // Wave4 * complex.
0055   Wave4 operator*(complex s) {return Wave4(val[0] * s, val[1] * s,
0056     val[2] * s, val[3] * s);}
0057 
0058   // complex * Wave4.
0059   friend Wave4 operator*(complex s, const Wave4& w);
0060 
0061   // Wave4 * double.
0062   Wave4 operator*(double s) {return Wave4(val[0] * s, val[1] * s,
0063     val[2] * s, val[3] * s);}
0064 
0065   // double * Wave4.
0066   friend Wave4 operator*(double s, const Wave4& w);
0067 
0068   // Wave4 / complex.
0069   Wave4 operator/(complex s) {return Wave4(val[0] / s, val[1] / s,
0070     val[2] / s, val[3] / s);}
0071 
0072   // Wave4 / double.
0073   Wave4 operator/(double s) {return Wave4(val[0] / s, val[1] / s,
0074     val[2]/s, val[3]/s);}
0075 
0076   // Complex conjugate.
0077   friend Wave4 conj(Wave4 w);
0078 
0079   // Permutation operator.
0080   friend Wave4 epsilon(Wave4 w1, Wave4 w2, Wave4 w3);
0081 
0082   // Invariant squared mass for REAL Wave4 (to save time).
0083   friend double m2(Wave4 w);
0084   friend double m2(Wave4 w1, Wave4 w2);
0085 
0086   // Wave4 * GammaMatrix multiplication is defined in the GammaMatrix class.
0087 
0088   // Print a Wave4 vector.
0089   friend ostream& operator<<(ostream& output, Wave4 w);
0090 
0091 protected:
0092 
0093   complex val[4];
0094 
0095 };
0096 
0097 //--------------------------------------------------------------------------
0098 
0099 // Namespace function declarations; friends of Wave4 class.
0100 Wave4 operator*(complex s, const Wave4& w);
0101 Wave4 operator*(double s, const Wave4& w);
0102 Wave4 conj(Wave4 w);
0103 Wave4 epsilon(Wave4 w1, Wave4 w2, Wave4 w3);
0104 double m2(Wave4 w);
0105 double m2(Wave4 w1, Wave4 w2);
0106 ostream& operator<<(ostream& os, Wave4 w);
0107 
0108 //==========================================================================
0109 
0110 // The GammaMatrix class is a special sparse matrix class used to write
0111 // helicity matrix elements in conjuction with the Wave4 class. Note that
0112 // only left to right multplication of Wave4 vectors with the GammaMatrix
0113 // class is allowed. Additionally, subtracting a scalar from a GammaMatrix
0114 // (or subtracting a GammaMatrix from a scalar) subtracts the scalar from
0115 //each non-zero element of the GammaMatrix. This is designed specifically
0116 // with the (1 - gamma^5) structure of matrix elements in mind.
0117 
0118 class GammaMatrix {
0119 
0120 public:
0121 
0122   // Constructors and destructor.
0123   GammaMatrix() : index() {};
0124   GammaMatrix(int mu);
0125   ~GammaMatrix() {};
0126 
0127   // Access an element of the matrix.
0128   complex& operator() (int I, int J) {if (index[J] == I) return val[J];
0129     else return COMPLEXZERO; }
0130 
0131   // Wave4 * GammaMatrix.
0132   friend Wave4 operator*(Wave4 w, GammaMatrix g);
0133 
0134   // GammaMatrix * Scalar.
0135   GammaMatrix operator*(complex s) {val[0] = s*val[0]; val[1] = s*val[1];
0136     val[2] = s*val[2]; val[3] = s*val[3]; return *this;}
0137 
0138   // Scalar * GammaMatrix.
0139   friend GammaMatrix operator*(complex s, GammaMatrix g);
0140 
0141   // Gamma5 - I * Scalar.
0142   GammaMatrix operator-(complex s) {val[0] = val[0] - s; val[1] = val[1] - s;
0143     val[2] = val[2] - s; val[3] = val[3] - s; return *this;}
0144 
0145   // I * Scalar - Gamma5.
0146   friend GammaMatrix operator-(complex s, GammaMatrix g);
0147 
0148   // Gamma5 + I * Scalar
0149   GammaMatrix operator+(complex s) {val[0] = val[0] + s; val[1] = val[1] + s;
0150     val[2] = val[2] + s; val[3] = val[3] + s; return *this;}
0151 
0152   // I * Scalar + Gamma5
0153   friend GammaMatrix operator+(complex s, GammaMatrix g);
0154 
0155   // << GammaMatrix.
0156   friend ostream& operator<<(ostream& os, GammaMatrix g);
0157 
0158 protected:
0159 
0160   complex val[4];
0161   int     index[4];
0162 
0163   // Need to define complex 0 as a variable for operator() to work.
0164   complex COMPLEXZERO;
0165 
0166 };
0167 
0168 //--------------------------------------------------------------------------
0169 
0170 // Namespace function declarations; friends of GammaMatrix class.
0171 Wave4 operator*(Wave4 w, GammaMatrix g);
0172 GammaMatrix operator*(complex s, GammaMatrix g);
0173 GammaMatrix operator-(complex s, GammaMatrix g);
0174 GammaMatrix operator+(complex s, GammaMatrix g);
0175 ostream& operator<<(ostream& os, GammaMatrix g);
0176 
0177 //==========================================================================
0178 
0179 // Helicity particle class containing helicity information, derived from
0180 // particle base class.
0181 
0182 class HelicityParticle : public Particle {
0183 
0184 public:
0185 
0186   // Constructors.
0187   HelicityParticle() : Particle(), indexSave() { direction = 1;}
0188   HelicityParticle(int idIn, int statusIn = 0, int mother1In = 0,
0189     int mother2In = 0, int daughter1In = 0, int daughter2In = 0,
0190     int colIn = 0, int acolIn = 0, double pxIn = 0.,
0191     double pyIn = 0., double pzIn = 0., double eIn = 0.,
0192     double mIn = 0., double scaleIn = 0., ParticleData* ptr = 0)
0193     : Particle(idIn, statusIn, mother1In, mother2In, daughter1In, daughter2In,
0194     colIn, acolIn, pxIn, pyIn, pzIn, eIn, mIn, scaleIn), indexSave() {
0195     if (ptr) setPDEPtr( ptr->particleDataEntryPtr( idIn) );
0196     initRhoD();
0197     direction = 1; }
0198   HelicityParticle(int idIn, int statusIn, int mother1In, int mother2In,
0199     int daughter1In, int daughter2In, int colIn, int acolIn, Vec4 pIn,
0200     double mIn = 0., double scaleIn = 0., ParticleData* ptr = 0)
0201     : Particle(idIn, statusIn, mother1In, mother2In, daughter1In, daughter2In,
0202     colIn, acolIn, pIn, mIn, scaleIn), indexSave() {
0203     if (ptr) setPDEPtr( ptr->particleDataEntryPtr( idIn) );
0204     initRhoD();
0205     direction = 1; }
0206   HelicityParticle(const Particle& ptIn, ParticleData* ptr = 0)
0207     : Particle(ptIn) {
0208     indexSave = ptIn.index();
0209     if (ptr) setPDEPtr( ptr->particleDataEntryPtr( id()) );
0210     initRhoD();
0211     direction = 1; }
0212 
0213   // Methods.
0214   Wave4 wave(int h);
0215   Wave4 waveBar(int h);
0216   void normalize(vector< vector<complex> >& m);
0217   int spinStates();
0218 
0219   // Return and set mass (redefine from Particle).
0220   double m() {return mSave;}
0221   void   m(double mIn) {mSave = mIn; initRhoD();}
0222 
0223   // Set the helicity state (redefine from Particle).
0224   double pol() {return polSave;}
0225   void   pol(double hIn);
0226 
0227   // Event record position (redefine from Particle).
0228   int  index() const {return indexSave;}
0229   void index(int indexIn) {indexSave = indexIn;}
0230 
0231   // Flag for whether particle is incoming (-1) or outgoing (1).
0232   int direction;
0233 
0234   // Helicity density matrix.
0235   vector< vector<complex> > rho;
0236 
0237   // Decay matrix.
0238   vector< vector<complex> > D;
0239 
0240 private:
0241 
0242   // Initialize the helicity density and decay matrix.
0243   void initRhoD();
0244 
0245   // Particle index in the event record.
0246   int indexSave;
0247 
0248 };
0249 
0250 //==========================================================================
0251 
0252 } // end namespace Pythia8
0253 
0254 #endif // Pythia8_HelicityBasics_H