Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:11

0001 // -*- C++ -*-
0002 /*
0003  * Quark_line.h
0004  *  Contains declaration of the class Quark_line and associated types and operators.
0005  *  Created on: Jul 7, 2010
0006  *  Author: Malin Sjodahl
0007  */
0008 
0009 #ifndef COLORFULL_Quark_line_h
0010 #define COLORFULL_Quark_line_h
0011 
0012 #include "Polynomial.h"
0013 
0014 
0015 namespace ColorFull {
0016 
0017 
0018 /// Define a type to contain a quark-line with gluons attached,
0019 /// the actual color information about how quarks are ordered in a
0020 /// Quark_line.
0021 typedef std::vector <int> quark_line;
0022 
0023 /// A class to contain one quark-line with gluons attached
0024 /// multiplying a Polynomial, Poly.
0025 /// The partons are ordered as {q,g1,g2...gn,qbar} for an open quark-line
0026 /// containing a q and a qbar, or (g1,g2...gn) for a closed
0027 /// quark-line with only gluons.
0028 /// The parton numbers are stored as components in a vector, a quark_line,
0029 /// whereas the member open contains information about it the quark-line is
0030 /// closed as a trace (true) or open, false.
0031 class Quark_line {
0032 
0033 public:
0034 
0035     /// Constructor used to set the color structure using a string.
0036     /// The string should be of form Polynomial*quark_line,
0037     /// used as "Quark_line Ql("5*TR*Nc^2 {1,6,7,2}");"
0038     /// for an open Quark_line with a quark with
0039     /// number 1, two gluons with number 6 and 7, and a qbar with number 2.
0040     /// For a closed Quark_line with 3 gluons the syntax is
0041     /// "Quark_line Ql("(1,2,3)");".
0042     /// The integers should be positive.
0043     /// The Polynomial should be in such a shape that it is readable by the
0044     /// Polynomial( std::string ) constructor.
0045     Quark_line( const std::string str );
0046 
0047     /// Default constructor.
0048     Quark_line();
0049 
0050     /// To actually contain the color information,
0051     /// in order {q, g1, ... gn, qbar} or (g1, ..., gn).
0052     quark_line ql;
0053 
0054     /// Polynomial factor, multiplying the quark_line.
0055     Polynomial Poly;
0056 
0057     /// Is the string open, with a q in the beginning and a qbar in the end, or not?
0058     bool open;
0059 
0060     /// Function for reading in the Quark_line from the file filename,
0061     /// uses Quark_line_of_str.
0062     void read_in_Quark_line( std::string filename );
0063 
0064     /// Function for writing out the Quark_line to a file
0065     /// with name filename.
0066     void write_out_Quark_line( std::string filename ) const;
0067 
0068     /// Returns the parton at place j.
0069     /// For closed quark_lines j may be between -size and 2*size.
0070     int at( int j ) const;
0071 
0072     /// The size of the quark_line.
0073     uint size() const{ return ql.size();}
0074 
0075     /// Erase information in quark_line ql.
0076     void clear() { ql.clear(); }
0077 
0078     /// Is the quark_line empty?
0079     bool empty() const { return ql.empty(); }
0080 
0081     /// If the quark_line is open, there is nothing to do,
0082     /// else order with smallest gluon index first
0083     /// (use that the trace is cyclic).
0084     void normal_order();
0085 
0086     /// To erase the parton at place i.
0087     void erase( int i );
0088 
0089     /// Conjugates the Quark_line by reversing the quark_line ql
0090     /// and conjugating the Polynomial Poly.
0091     void conjugate();
0092 
0093     /// Appends parton p to the Quark_line.
0094     void append( int p ) { ql.push_back( p ); }
0095 
0096     /// Appends a whole quark_line to the Quark_line.
0097     void append( const std::vector<int> & in_ql );
0098 
0099     /// Prepends parton p to the Quark_line.
0100     void prepend( int p );
0101 
0102     /// Prepends a whole quark_line to the Quark_line.
0103     void prepend( std::vector<int> in_ql );
0104 
0105     /// Inserting parton p at place j.
0106     void insert( int j, int p );
0107 
0108     /// Returns a Quark_line where the ql member is changed to contain
0109     /// only partons before place j.
0110     Quark_line before( int j ) const;
0111 
0112     /// Returns a Quark_line where the ql member is changed to contain
0113     /// only partons after place j.
0114     Quark_line after( int j ) const;
0115 
0116     /// Function for splitting a closed Quark_line into two Quark_lines.
0117     /// The gluons at j1 and j2 are removed in the split.
0118     /// May create 1-rings and 0-rings.
0119     std::pair<Quark_line, Quark_line> split_Quark_line( int j1, int j2 ) const;
0120 
0121     /// Function for finding the "smallest" Quark_line of Ql1 and Ql2,
0122     /// used for deciding which Quark_line should stand first while normal ordering.
0123     /// Does NOT first normal order the Quark_lines.
0124     /// If only one is open, that Quark_line should stand first.
0125     /// If both are open or both are closed, the longest Quark_line should stand first.
0126     /// If the size is the same, the Quark_line with smallest starting number should stand first.
0127     /// If the first number is the same, check the 2nd number, then the 3rd...
0128     /// 1 is returned if Ql1 should stand first, and 2 if Ql2 should stand first.
0129     /// If Ql1==Ql2, 0 is returned.
0130     int smallest( const Quark_line & Ql1 , const Quark_line & Ql2 ) const;
0131 
0132     /// Contracts neighboring gluons in the Quark_line starting at j,
0133     /// only intended for closed Quark_lines.
0134     void contract_neighboring_gluons( int j );
0135 
0136     /// Contracts neighboring gluons in a Quark_line starting at place 0,
0137     /// and checking all neighbors, only intended for closed Quark_lines.
0138     void contract_neighboring_gluons( );
0139 
0140     /// Contracts neighboring and next to neighboring gluons in the Quark_line,
0141     /// starting at place j (i.e. checking gluon j and j+2).
0142     /// Also looks for new neighbors, only intended for closed Quark_lines.
0143     void contract_next_neighboring_gluons( int j );
0144 
0145     /// Contracts neighboring and next to neighboring gluons in the Quark_line,
0146     /// starting with contracting neighbors, only intended for closed Quark_lines.
0147     void contract_next_neighboring_gluons( );
0148 
0149 
0150 private:
0151 
0152     /// Function used to set the color structure using a string.
0153     /// The string should be of form Polynomial*quark_line,
0154     /// used as "Quark_line Ql("Polynomial {5,6,7}");"
0155     /// for an open Quark_line with a quark with
0156     /// number 5, a gluon with number 6 and a qbar with number 7, and as
0157     /// "Quark_line Ql("(5,6,7)");" for 3 gluons attached to a quark line.
0158     /// The Polynomial should be in such a shape that it's readable by the
0159     /// Polynomial( std::string ) constructor.
0160     void Quark_line_of_str( const std::string str );
0161 
0162     /// To make it easy to define a Quark_line using a string,
0163     /// used by Quark_line_of_str(std::string str)
0164     /// to set the quark_line member ql.
0165     void quark_line_of_str( std::string str );
0166 
0167 };
0168 
0169 /// Define the operator * for Quark_line and int.
0170 /// The Polynomial of the Quark_line is multiplied with i.
0171 Quark_line operator*( const Quark_line & Ql, const int i );
0172 
0173 /// Define the operator * for Quark_line and int,
0174 /// returns Ql*i.
0175 Quark_line operator*( const int i, const Quark_line & Ql );
0176 
0177 /// Define the operator * for Quark_line and cnum.
0178 /// The Polynomial of the Quark_line is multiplied with c.
0179 Quark_line operator*( const Quark_line & Ql, const cnum c );
0180 
0181 /// Define the operator * for Quark_line and cnum,
0182 /// returns Ql*c.
0183 Quark_line operator*( const cnum c, const Quark_line & Ql );
0184 
0185 /// Define the operator * for Quark_line and double.
0186 /// The Polynomial of the Quark_line is multiplied with d.
0187 
0188 Quark_line operator*( const Quark_line & Ql, const double d );
0189 /// Define the operator * for Quark_line and double,
0190 
0191 /// returns Ql*d.
0192 Quark_line operator*( const double d, const Quark_line & Ql );
0193 
0194 /// Define the operator * for Quark_line and Monomial.
0195 /// The polynomial of the Quark_line is multipled with Mon.
0196 Quark_line operator*( const Quark_line & Ql, const Monomial & Mon );
0197 
0198 /// Define the operator * for Quark_line and Monomial.
0199 /// returns Ql*Mon.
0200 Quark_line operator*( const Monomial & Mon, const Quark_line & Ql );
0201 
0202 /// Define the operator * for Quark_line and Polynomial.
0203 /// The Polynomial of the Quark_line is multiplied with Poly.
0204 Quark_line operator*( const Quark_line & Ql, const Polynomial & Poly );
0205 
0206 /// Define the operator * for Quark_line and Polynomial
0207 /// returns Ql*Poly.
0208 Quark_line operator*( const Polynomial & Poly, const Quark_line & Ql );
0209 
0210 /// Define the operator == for two Quark_lines
0211 /// the quark_lines must be equal, the member variable open and the
0212 /// Polynomials must be equal. Note that for Polynomials cf+Nc!=Nc+cf.
0213 bool operator==( const Quark_line & Ql1, const Quark_line & Ql2 );
0214 
0215 /// The negation of the Quark_line operator ==.
0216 bool operator!=( const Quark_line & Ql1, const Quark_line & Ql2 );
0217 
0218 
0219 /// Define the operator << for Quark_line.
0220 std::ostream& operator<<( std::ostream& out, const Quark_line & Ql );
0221 
0222 
0223 }// end namespace ColorFull
0224 
0225 #endif /* COLORFULL_Quark_line_h */