Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 /*
0003  *  Col_str.h
0004  *  Contains declaration of the class Col_str and associated types and operators.
0005  *  Created on: Jul 7, 2010
0006  *  Author: Malin Sjodahl
0007  */
0008 
0009 #ifndef COLORFULL_Col_str_h
0010 #define COLORFULL_Col_str_h
0011 
0012 #include "Quark_line.h"
0013 
0014 namespace ColorFull {
0015 
0016 /// For containing a vector (or list) of Quark_lines
0017 /// the color information part of a Col_str.
0018 /// The col_str is a product of Quark_lines,
0019 /// contained in a vector of quark-lines.
0020 typedef std::vector < Quark_line > col_str;
0021 
0022 
0023 /// A class to contain ONE color structure, a direct product of Quark_lines,
0024 /// multiplying a Polynomial, Poly.
0025 /// The Quark_lines are stored as components in a vector, a col_str.
0026 class Col_str {
0027 public:
0028 
0029     /// Default constructor, leaves cs empty.
0030     Col_str(){};
0031 
0032     /// Constructor for setting the color structure using a string.
0033     /// Should be used as:
0034     /// "Col_str Cs("2*Nc*TR^(3) [{1,2,3,4}(5,6)(7,8)(9,10,11,12)]");",
0035     /// i.e. the argument should be a Polynomial * col_str.
0036     /// (The Polynomial should multiply the whole col_str,
0037     /// rather than a quark_line inside the [] brackets.)
0038     Col_str( const std::string str );
0039 
0040     /// Make a Col_str of a Quark_line.
0041     Col_str( Quark_line Ql ) {cs.push_back(Ql);}
0042 
0043     /// For containing the information about the color structure,
0044     /// a direct product of Quark_lines,
0045     /// contained in a vector of quark-lines.
0046     col_str cs;
0047 
0048     /// Polynomial factor multiplying the whole product of quark-lines.
0049     Polynomial Poly;
0050 
0051     /// Returns the Quark_line at place i.
0052     const Quark_line & at( int i ) const {return cs.at(i);}
0053 
0054     /// Returns the Quark_line at place i.
0055     Quark_line & at( int i ) {return cs.at(i);}
0056 
0057     /// Returns the parton at place j in Quark_line i.
0058     int at( int i, int j ) const;
0059 
0060     /// The size of the col_str
0061     uint size() const{ return cs.size(); }
0062 
0063     /// Is the col_str empty?
0064     bool empty() const { return cs.empty(); }
0065 
0066     /// Erase information in col_str.
0067     void clear() { cs.clear(); }
0068 
0069     /// Erases the Quark_line at place i.
0070     void erase( int i );
0071 
0072     /// Erases the parton at place i, j.
0073     void erase( int i, int j );
0074 
0075     /// Erases a parton at location place.
0076     void erase(std::pair<int, int> place);
0077 
0078     /// Appends a Quark_line to data member cs.
0079     void append( Quark_line Ql ) { cs.push_back( Ql ); }
0080 
0081     /// To insert the parton part_num in quark_line i
0082     /// at place j.
0083     void insert( int i, int j, int part_num );
0084 
0085     /// Append the content of a col_str to the cs of the Col_str.
0086     void append( col_str cs_in );
0087 
0088     /// Function for reading in the Col_str from the file filename.
0089     void read_in_Col_str( std::string filename );
0090 
0091     /// Function for writing out the Col_str to a file
0092     /// with name filename.
0093     void write_out_Col_str( std::string filename ) const;
0094 
0095     /// Locates the parton with number part_num in a Col_str.
0096     std::pair<int, int> find_parton( int part_num ) const;
0097 
0098     /// Function for telling if the partons p1 and p2 are neighbors.
0099     bool neighbor( int p1, int p2 ) const;
0100 
0101     /// Function for telling if parton p2 stands to the right of parton p1.
0102     bool right_neighbor( int p1, int p2 ) const;
0103 
0104     /// Function for telling if parton p2 stands to the left of parton p1.
0105     bool left_neighbor( int p1, int p2 ) const;
0106 
0107     /// Replaces the parton index old_ind with new_ind.
0108     void replace( int old_ind, int new_ind );
0109 
0110     /// Finds out if a parton is a quark, anti-quark or a gluon,
0111     /// returns "q", "qbar" or "g" respectively.
0112     /// This function does NOT loop over all partons, but assumes
0113     /// that the parton is a gluon if the Quark_line is closed,
0114     /// or if the Quark_line is open, but p cannot be found in the ends.
0115     std::string find_kind( int p ) const;
0116 
0117     /// Checks if the amplitude only has gluons, i.e. if all Quark_lines are closed.
0118     bool gluons_only() const;
0119 
0120     /// Counts the number of gluons in a Col_str.
0121     /// Counts all gluon indices, both free and contractable.
0122     int n_gluon() const;
0123 
0124     /// Counts the number of quarks (=number of anti-quarks) in a Col_str.
0125     /// Counts all quark indices, both free and contracted.
0126     int n_quark() const;
0127 
0128     /// Normal orders the Col_str by first
0129     /// normal order individual Quark_lines
0130     /// and then normal order different Quark_lines in the cs.
0131     /// For the ordering see the member function smallest in this
0132     /// class and in the Quark_line class.
0133     void normal_order();
0134 
0135     /// Finds out the "smallest" Col_str of two Col_strs, i.e.
0136     /// which Col_str should stand first in a normal ordered Col_amp or basis.
0137     /// Returns 1, if Cs1 should stand before Cs2
0138     /// and 2 if Cs2 should stand before Cs1.
0139     /// Both Col_strs have to be normal ordered for the result to be unique.
0140     /// The Col_strs are ordered by
0141     /// (1) number of Quark_lines
0142     /// (2) if the Quark_line at place 0,1,2... is open or not
0143     /// (3) the size of the Quark_line at place 1,2,3...
0144     /// (4) the parton numbers in the Quark_lines at place 1,2,3...,
0145     /// i.e. first the first parton in the first Quark_line is checked
0146     /// and last the last parton in the last Quark_line.
0147     /// The function returns 0 if Cs1=Cs2.
0148     int smallest( const Col_str & Cs1, const Col_str & Cs2 ) const;
0149 
0150     /// Returns the length of the longest Quark_line in the Col_str.
0151     int longest_quark_line() const;
0152 
0153     /// Removes Quark_lines with only one gluon as Tr(t^a)=0.
0154     void remove_1_rings();
0155 
0156     /// Removes Quark_lines without partons, equal to Nc (closed) or 1 (open).
0157     void remove_0_rings();
0158 
0159     /// Removes 0 and 1-rings,
0160     /// moves factors multiplying the individual Quark_lines to
0161     /// multiply the col_str instead (i.e., being stored in Poly)
0162     /// simplifies the Polynomial and normal orders the quark_lines.
0163     void simplify();
0164 
0165     /// Function for conjugating the Col_str by conjugating each Quark_line in cs,
0166     /// as well as the Polynomial Poly.
0167     void conjugate();
0168 
0169     /// Contracts neighboring and next to neighboring gluons in each
0170     /// Quark_line in the Col_str, starting with contracting neighbors.
0171     /// This function should only be used on Col_strs with only closed Quark_lines.
0172     void contract_next_neighboring_gluons( );
0173 
0174     /// Function for contracting gluon indices in closed Quark_lines with only 2 gluons.
0175     /// This removes the 2-ring, replaces one of the gluon indices,,
0176     /// and multiplies with a factor tr[t^a t^a]=TR (no sum),
0177     /// only intended for fully contractable Col_strs.
0178     void contract_2_rings( );
0179 
0180     /// Function for contracting quarks between two color structures Cs1 and Cs2.
0181     /// The result is stored in the Col_str itself.
0182     void contract_quarks( const Col_str Cs1, const Col_str Cs2 );
0183 
0184 
0185 private:
0186 
0187     /// Function to tell which quark_line should stand first in normal order.
0188     /// The quark_lines at place i1 and i2 are compared.
0189     /// Returns i1 if i1 should stand first, i2 if i2 should stand first
0190     /// and i1 if the quark_lines are equal.
0191     int compare_quark_lines( int i1, int i2 ) const;
0192 
0193     /// Function to allow setting the color structure by using a string.
0194     /// Used by string constructor and by
0195     void Col_str_of_str( const std::string str  );
0196 
0197     /// Setting the col_str member cs
0198     /// (i.e. the non-Polynomial information) using a string,
0199     /// used by Col_str_of_str and read_in_Col_str.
0200     void col_str_of_str( std::string );
0201 
0202 }; //end class Col_str
0203 
0204 
0205 /// Define the operator == for two col_str's.
0206 /// The col_str's must have equal length and
0207 /// all Quark_lines must be the same
0208 /// (i.e. have same Polynomial and same parton ordering).
0209 /// The quark_lines are NOT normal ordered before comparison.
0210 bool operator==(const col_str & cs1, const col_str & cs2);
0211 
0212 /// Define the operator != for two col_str's.
0213 /// Returns false if cs1==cs2 and false otherwise.
0214 bool operator!=(const col_str & cs1, const col_str & cs2);
0215 
0216 /// Define the operator << for col_str
0217 std::ostream& operator<<( std::ostream& out, const col_str & cs );
0218 
0219 /// Define the operator * for Col_str and int.
0220 Col_str operator*( const Col_str & Cs, const int i );
0221 
0222 /// Define the operator * for int and Col_str.
0223 Col_str operator*( const int i, const Col_str & Cs );
0224 
0225 /// Define the operator * for Col_str and double.
0226 Col_str operator*( const Col_str & Cs, const double d );
0227 
0228 /// Define the operator * for double and Col_str.
0229 Col_str operator*( const double d, const Col_str & Cs );
0230 
0231 /// Define the operator * for Col_str and cnum.
0232 Col_str operator*( const Col_str & Cs, const cnum c);
0233 
0234 /// Define the operator * for cnum and Col_str.
0235 Col_str operator*( const cnum c, const Col_str & Cs );
0236 
0237 /// Define the operator * for Col_str and Monomial.
0238 Col_str operator*( const Col_str & Cs, const Monomial & Mon );
0239 
0240 /// Define the operator * for Monomial and Col_str.
0241 Col_str operator*( const Monomial & Mon, const Col_str & Cs);
0242 
0243 /// Define the operator * for Col_str and Polynomial.
0244 Col_str operator*( const Col_str & Cs, const Polynomial & Poly );
0245 
0246 /// Define the operator * for Polynomial and Col_str.
0247 Col_str operator*( const Polynomial & Poly, const Col_str & Cs );
0248 
0249 /// Define the operator * for a Col_str and a Quark_line, adding Ql and multiplying Polynomial info.
0250 Col_str operator*( const Col_str & Cs, const Quark_line & Ql);
0251 
0252 /// Define the operator * for a Quark_line and a Col_str, adding Ql and multiplying Polynomial info.
0253 Col_str operator*( const Quark_line & Ql, const Col_str & Cs );
0254 
0255 /// Define the operator * for two Col_str's, adding Ql and multiplying Polynomial info.
0256 Col_str operator*( const Col_str & Cs1, const Col_str & Cs2 );
0257 
0258 /// Define the operator * for two Quark_lines. Clearly the result cannot be contained in
0259 /// a Quark_line, but needs (at least) a Col_str.
0260 Col_str operator*( const Quark_line & Ql1, const Quark_line & Ql2 );
0261 
0262 /// Define the operator << for Col_str.
0263 std::ostream& operator<<(std::ostream& out, const Col_str & Cs);
0264 
0265 /// Define the operator == for two Col_str's
0266 /// the col_strs must be equal, and the
0267 /// Polynomials must be equal. Note that for Polynomials cf+Nc!=Nc+cf.
0268 /// Function does NOT first normal order Col_strs.
0269 bool operator==( const Col_str & Cs1, const Col_str & Cs2 );
0270 
0271 /// Define the operator != for two Col_str's, the negation of ==.
0272 /// Function does NOT first normal order Col_strs.
0273 bool operator!=( const Col_str & Cs1, const Col_str & Cs2 );
0274 
0275 }
0276 
0277 #endif /* COLORFULL_Col_str_h */