Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 /*
0003  * Col_functions.h
0004  * Contains declarations of the class Col_str and associated types and operators
0005  * Author: Malin Sjodahl
0006  */
0007 
0008 #ifndef COLORFULL_Col_functions_h
0009 #define COLORFULL_Col_functions_h
0010 
0011 
0012 #include "Col_amp.h"
0013 #include "Poly_matr.h"
0014 #include <list>
0015 #include <map>
0016 #include <memory>
0017 
0018 namespace ColorFull {
0019 
0020 using std::shared_ptr;
0021 
0022 /// Library class containing functions for index contraction and
0023 /// numerical evaluation.
0024 /// This is where the parameters Nc, TR and CF are contained.
0025 class Col_functions {
0026 
0027 private:
0028 
0029 /// The number of colors, used in numerical results,
0030 /// changed by using set_Nc.
0031 double Nc;
0032 
0033 /// The trace convention Tr( t^a t^a )=TR (no sum).
0034 /// The normalization of the SU(Nc) generators, to be used in numerical evaluation,
0035 /// changed by using set_TR.
0036 /// The value 1/2 corresponds to the Gell-Mann normalization.
0037 double TR;
0038 
0039 /// The value of CF=TR*Nc-TR/Nc, changed by using set_CF.
0040 /// Note that CF can be changed independently of Nc.
0041 double CF;
0042 
0043 /// While evaluating leading terms one may want to keep the full value of CF for
0044 /// TR(Nc^2-1)/Nc, or only keep the leading Nc term =TR*Nc (default).
0045 /// full_CF is used by the Polynomial version of leading
0046 /// (and hence also Poly_vec and Poly_matr versions etc).
0047 /// The leading functions replaces CF by TR*Nc if full_CF is false (default)
0048 /// while evaluating the leading terms.
0049 /// If full_CF is true, CF is replaced by TR(Nc^2-1)/Nc.
0050 /// Clearly this affects the result of subsequent numerical evaluation.
0051 /// In the Col_basis class (and derived) the matrix version of leading
0052 /// is used to evaluate scalar product matrices.
0053 bool full_CF;
0054 
0055 
0056 public:
0057 
0058 /// Default constructor.
0059 Col_functions()
0060   : Nc(3.0), TR(0.5), CF(4.0/3.0), full_CF( false )  {}
0061 
0062 /// Set the number of colors.
0063 /// The value of CF is adjusted accordingly.
0064 void set_Nc( double n) {
0065   Nc = n;
0066   CF = TR*(Nc*Nc-1.)/Nc;
0067 }
0068 
0069 /// Set the normalization of the generators.
0070 /// The value of CF is adjusted accordingly.
0071 void set_TR( double tr) {
0072   CF *= tr/TR;
0073   TR = tr;
0074 }
0075 
0076 /// Set the value of CF.
0077 /// The value of Nc is NOT adjusted accordingly.
0078 void set_CF( double cf) {
0079   CF = cf;
0080 }
0081 
0082 /// Switch on/off full_CF.
0083 void set_full_CF( bool is_full ) { full_CF = is_full; }
0084 
0085 /// Returns the number of colors.
0086 double get_Nc() const { return Nc; }
0087 
0088 /// Returns the normalization of the generators,
0089 /// tr(t^a t^b)=TR*delta^{a,b}.
0090 double get_TR() const { return TR; }
0091 
0092 /// Returns the value of CF.
0093 double get_CF() const { return CF; }
0094 
0095 /// Returns true, if full CF is used.
0096 bool get_full_CF() const { return full_CF; }
0097 
0098 
0099 /****************** Functions for leading terms *************************/
0100 // The functions called leading(...) depend on the variable full_CF.
0101 // As it would be messy to let each Polynomial carry around
0102 // its own full_CF, these functions are kept here.
0103 
0104 /// Function for finding the leading power of Nc in a Poly_vec,
0105 /// i.e., the power of Nc plus the power of CF.
0106 int  leading_Nc_pow( const Polynomial & Poly ) const;
0107 
0108 /// Function for finding the leading power of Nc in a Poly_vec.
0109 int  leading_Nc_pow( const Poly_vec & Pv ) const;
0110 
0111 /*
0112 /// Function for finding the leading power of Nc in a
0113 /// vector of pointers to Polynomials.
0114 int  leading_Nc_pow( const std::vector< shared_ptr<Polynomial> > & Pvp) const;
0115 */
0116 
0117 /// Takes the leading Nc terms of a Polynonmial, i.e. Monomials with highest
0118 /// power of Nc+CF. If full_CF is false (default), CF is replaced by TR Nc.
0119 /// If full_CF is true CF is replaced by TR(Nc^2-1)/Nc.
0120 Polynomial leading( const Polynomial & Poly ) const;
0121 
0122 /// Take the leading part of a Poly_vec.
0123 /// Keeps only Monomials with maximal power of CF plus Nc,
0124 /// uses leading( const Polynomial & Poly).
0125 /// If full_CF is false (default), CF is replaced by TR Nc.
0126 /// If full_CF is true CF is replaced by TR(Nc^2-1)/Nc.
0127 /// Note that taking the leading terms of a Poly_vec is not
0128 /// the same as taking the leading terms in each Polynomial.
0129 // Used only by Poly_matr version of leading
0130 Poly_vec leading( const Poly_vec & Pv ) const;
0131 
0132 /// Takes the leading part of a matrix of Polynomials,
0133 /// keeping only those with maximal power of CF plus Nc.
0134 /// If full_CF is false (default), CF is replaced by TR Nc.
0135 /// If full_CF is true CF is replaced by TR(Nc^2-1)/Nc.
0136 /// Note that taking the leading terms of a Poly_matr is not
0137 /// the same as taking the leading terms in each Poly_vec.
0138 // Used only once in Col_basis
0139 Poly_matr leading( const Poly_matr & Pm ) const;
0140 
0141 /*
0142 /// Take the leading part of a Poly_vec, given a vector of pointers to the Polynomials.
0143 /// Keeps only Monomials with maximal power of CF plus Nc.
0144 // Currently never used
0145 Poly_vec leading( const std::vector<shared_ptr<Polynomial> > & Pvp) const;
0146 
0147 /// Take the leading part of a Poly_matr, given a vector of vector of pointers to the Polynomials.
0148 /// Loops over Monomials in all Polynomials
0149 /// and keeps only those with maximal power of CF plus Nc.
0150 // used only by scalar_product_matrix_mem in Col_functions
0151 dmatr leading( const std::vector< std::vector< shared_ptr<Polynomial> > > & Pm ) const;
0152 */
0153 
0154 /********************* Functions for numerical evaluation *************************/
0155 // These functions has to be kept in Col_functions class as they need numerical
0156 // values for evaluation. Letting each Polynomial carry around its own Nc etc.
0157 // would be messy.
0158 
0159 
0160 /// Numerically evaluates a Monomial using the Nc, TR and CF data members.
0161 cnum cnum_num( const Monomial & Mon ) const;
0162 
0163 /// Numerically evaluates a Polynomial, using the Nc, TR and CF data members.
0164 cnum cnum_num( const Polynomial & Poly ) const;
0165 
0166 /// Numerically evaluates a Poly_vec (vector of Polynomial),
0167 /// using cnum_num (Polynomial).
0168 cvec cnum_num( const Poly_vec & Pv ) const;
0169 
0170 /// Numerically evaluates a Poly_matr (vector of Poly_vec),
0171 /// using cnum_num( Poly_vec ) for each Poly_vec.
0172 cmatr cnum_num( const Poly_matr & Pm ) const;
0173 
0174 /// Numerically evaluates a Monomial to a double using the Nc, TR and CF data members.
0175 double double_num( const Monomial & Mon ) const;
0176 
0177 /// Numerically evaluates a Polynomial to a double using the Nc, TR and CF data members.
0178 double double_num( const Polynomial & Poly ) const;
0179 
0180 /// Numerically evaluates a Poly_vec (vector of Polynomial)
0181 /// using the Nc, TR and CF data members.
0182 dvec double_num( const Poly_vec & Pv ) const;
0183 
0184 /// Numerically evaluates a Poly_matr (vector of Poly_vec),
0185 /// using the Nc, TR and CF data members.
0186 dmatr double_num( const Poly_matr & Pm ) const;
0187 
0188 /*
0189 /// Returns a double vector. The argument is a vector of pointers to Polynomials.
0190 dvec double_num( const std::vector<std::shared_ptr<Polynomial> > & Pv ) const;
0191 
0192 /// Returns a double matrix. The argument is a vector of vector of pointers to Polynomials.
0193 // (not used 14 06 08)
0194 dmatr double_num( const std::vector<std::vector<std::shared_ptr<Polynomial> > > & Pm ) const;
0195 
0196 /// To take the numerical value of a map.
0197 // (not used 14 06 08)
0198 std::map< std::string, double > double_num( std::map< std::string, std::shared_ptr<Polynomial> > mem_map ) const;
0199 
0200 /// To take the numerical value of a map.
0201 // (not used 14 06 08)
0202 std::map< std::string, double > double_num( std::map< std::string, Polynomial > mem_map ) const;
0203 */
0204 
0205 /// Numerically evaluates a Polynomial using the value of the data member Nc,
0206 /// and stores in the format of a Polynomial with only one term with only a numerical part.
0207 Polynomial Polynomial_cnum_num( const Polynomial & Poly ) const;
0208 
0209 /// Numerically evaluates a Poly_vec (vector of Polynomial)
0210 /// and stores in the form of a Poly_vec, uses polynomial_cnum_num( Pv.at( p ) ).
0211 /// for each Polynomial.
0212 Poly_vec Poly_vec_cnum_num( const Poly_vec & Pv ) const;
0213 
0214 /// Numerically evaluates a Poly_matr (vector of Poly_vec)
0215 /// and stores in the form of a Poly_matr.
0216 Poly_matr Poly_matr_cnum_num( const Poly_matr & Pm ) const;
0217 
0218 
0219 /****************** Functions for scalar products *************************/
0220 
0221 /// Function for calculating the scalar products between Col_amps.
0222 /// Does not add implicit state in the gluons only case.
0223 Polynomial scalar_product( const Col_amp & Ca1, const Col_amp & Ca2 ) const;
0224 
0225 /// Function for calculating the scalar product between two Col_strs.
0226 /// Does not add implicit state in the gluons only case.
0227 Polynomial scalar_product( const Col_str & Cs1, const Col_str & Cs2 ) const;
0228 
0229 
0230 /****************** Functions for gluon emission exchange, and splitting *************/
0231 
0232 /// Function for emitting a gluon from a Col_str.
0233 /// When the gluon is inserted before the emitter in a Quark_line,
0234 /// the amplitude comes with a minus sign.
0235 Col_amp emit_gluon( const Col_str & in_Col_str, int emitter, int g_new ) const;
0236 
0237 /// Function for emitting a gluon from a Col_amp.
0238 /// When the gluon is inserted before the emitter in a Quark_line,
0239 /// the amplitude comes with a minus sign.
0240 Col_amp emit_gluon( const Col_amp & Ca_in, int emitter, int g_new ) const;
0241 
0242 /// Function for splitting the gluon g_old in a Col_str to a qqbar pair.
0243 Col_amp split_gluon( const Col_str & in_Col_str, int g_old, int q_new, int qbar_new ) const;
0244 
0245 /// Function for splitting the gluon g_old in a Col_amp to a qqbar pair.
0246 Col_amp split_gluon( const Col_amp & in_Col_amp, int g_old, int q_new, int qbar_new ) const;
0247 
0248 
0249 /// Function for exchanging a gluon between the partons p1 and p2 in the Col_str Cs.
0250 /// When the gluon is inserted before the emitter in a Quark_line,
0251 /// the amplitude comes with a minus sign.
0252 Col_amp exchange_gluon( const Col_str & Cs, int p1, int p2 ) const;
0253 
0254 /// Function for exchanging a gluon between two partons p1 and p2 in the Col_amp Ca.
0255 /// When the gluon is inserted before the emitter in a Quark_line,
0256 /// the amplitude comes with a minus sign.
0257 /// (There is no special treatment of the glons only cases.)
0258 Col_amp exchange_gluon( const Col_amp & Ca, int p1, int p2 ) const;
0259 
0260 /// Calculates < M | T_i T_j | M >, the "color correlator"
0261 /// relevant for coherent gluon emission of gluon g_new from
0262 /// parton i and parton j, or gluon exchange between i and j.
0263 /// The Ca should thus be | M >,
0264 /// and i and j are the partons involved in the emission (exchange).
0265 /// (The incoming amplitude is what it is, there is no special
0266 /// treatment of gluons only cases.)
0267 Polynomial color_correlator( const Col_amp Ca, int i, int j ) const;
0268 
0269 
0270 /********************* Other functions *************************/
0271 
0272 // As dvec and dmatr are not classes some read and write functions
0273 // are contained here.
0274 
0275 /// Reads in a numerical vector and save it as a double vector, dvec.
0276 /// The file should be of the format
0277 /// {d11,...,d1n},
0278 /// and may contain comment lines starting with # at the top.
0279 dvec read_in_dvec( std::string filename ) const;
0280 
0281 /// Reads in a numerical matrix and save it as a double matrix, dmatr.
0282 /// The file should be of the format
0283 /// {{d11,...,d1n},
0284 /// ...,
0285 /// {dn1,...,dnn}},
0286 /// and may contain comment lines starting with # at the top.
0287 dmatr read_in_dmatr( std::string filename ) const;
0288 
0289 /// Function for writing out a numerical vector,
0290 /// to the file filename.
0291 void write_out_dvec( const dvec & dv, std::string filename ) const;
0292 
0293 /// Writes out the double version of a (scalar product) matrix
0294 /// to the file filename.
0295 void write_out_dmatr( const dmatr & matr, std::string filename ) const;
0296 
0297 /// The factorial of an int, 0! is defined as 1.
0298 int factorial( int i ) const;
0299 
0300 /// Function that finds the default parton numbers for a Col_str.
0301 /// The default numbers are 1,...,N_parton, where quarks have the first
0302 /// odd numbers, anti-quarks have the first even numbers, and gluons have
0303 /// subsequent numbers. The intended usage is after gluon splitting, where
0304 /// the gluon g_old has split into q_new and qbar_new, and the parton numbers
0305 /// before splitting are assumed to be default.
0306 std::map<int, int> default_parton_numbers( const Col_str &, int g_old, int q_new, int qbar_new ) const;
0307 
0308 
0309 /// Function that renames the partons in a Col_str using a map where, in each pair,
0310 /// the first number is to be replaced by the second. (The Col_functions member
0311 /// function default_parton_numbers returns a map where the partons are given
0312 /// default numbers.)
0313 Col_str rename_partons( const Col_str &, const std::map <int, int> replacements ) const;
0314 
0315 
0316 /// Function that renames the partons in a Col_amp using a map where, in each pair,
0317 /// the first number is to be replaced by the second. (The Col_functions member
0318 /// function default_parton_numbers returns a map where the partons are given
0319 /// default numbers.)
0320 Col_amp rename_partons( const Col_amp &, const std::map <int, int> replacements ) const;
0321 
0322 
0323 }; // end class Col_functions
0324 
0325 
0326 /////////////////////// DECLEARING OPERATORS /////////////////////
0327 
0328 /// Defining + operator to be able to erase elements at place
0329 std::list<int>::iterator operator+( std::list<int>::iterator x, int n );
0330 
0331 std::list<int>::iterator operator-( std::list<int>::iterator x, int n );
0332 
0333 /// Defining + operator to be able to erase elements at place
0334 std::list< Quark_line >::iterator operator+( std::list < Quark_line >::iterator x, int n );
0335 
0336 col_str::iterator operator-( col_str::iterator x, int n );
0337 
0338 /// Define the operator << for vector of int.
0339 std::ostream& operator<<( std::ostream& out, const std::vector<int> & vec );
0340 
0341 /// Define the operator << for cvec.
0342 std::ostream& operator<<( std::ostream& out, const cvec & cv );
0343 
0344 /// Define the operator << for dvec.
0345 std::ostream& operator<<( std::ostream& out, const dvec & dv );
0346 
0347 /// Define the operator << for cmatr.
0348 std::ostream& operator<<( std::ostream& out, const cmatr & cm );
0349 
0350 /// Define the operator << for dmatr.
0351 std::ostream& operator<<( std::ostream& out, const dmatr & matr );
0352 
0353 /// Define the operator << for std::pair<int, int>.
0354 std::ostream& operator<<( std::ostream& out, std::pair<int, int> pair );
0355 } // end namespace ColorFull
0356 
0357 #endif /* COLORFULL_Col_functions_h */