Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:21

0001 // -*- C++ -*-
0002 //
0003 // ColourSinglet.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef ThePEG_ColourSinglet_H
0010 #define ThePEG_ColourSinglet_H
0011 
0012 #include "ThePEG/EventRecord/EventConfig.h"
0013 
0014 namespace ThePEG {
0015 
0016 /**
0017  * A <code>ColourSinglet</code> object represents a set of
0018  * colour-connected partons in a total colour-singlet state. The
0019  * simplest form is a single string represented by a vector of partons
0020  * starting from a colour-triplet parton followed by a number of
0021  * colour-octet partons and ending in a anti-triplet. A closed string
0022  * is represented by a vector of colour-octet partons. If junctions
0023  * are present, there will be a vector of string pieces containing the
0024  * associated partons, with associated information about the string
0025  * pieces connected via sinks or sources.
0026  *
0027  * @see ColourLine
0028  * @see Particle
0029  * 
0030  */
0031 class ColourSinglet {
0032 
0033 public:
0034 
0035   /** A piece of string. */
0036   typedef deque<tcPPtr> StringPiece;
0037   /** An integer type used as index in a string pieece. */
0038   typedef StringPiece::size_type Index;
0039   /** Representaion of a junction. */
0040   typedef pair<Index,Index> Junction;
0041 
0042 public:
0043 
0044   /**
0045    * Default constructor.
0046    */
0047   ColourSinglet() {}
0048 
0049   /**
0050    * Constructor taking an initial colour line and a set of partons to
0051    * select from.
0052    */
0053   ColourSinglet(tcColinePtr cl, tcParticleSet & left);
0054 
0055 protected:
0056 
0057   /**
0058    * Internal constructor. When splitting an internal line, create a
0059    * new colour singlet starting from the string piece \a si in the
0060    * singlet \a cs.
0061    */
0062   ColourSinglet(const ColourSinglet & cs, Index si);
0063 
0064 public:
0065 
0066   /**
0067    * Access the vector of partons.
0068    */
0069   tcPVector & partons() { return thePartons; }
0070 
0071   /**
0072    * Access the vector of partons.
0073    */
0074   const tcPVector & partons() const { return thePartons; }
0075 
0076   /**
0077    * Access a parton giving an index.
0078    */
0079   tcPPtr parton(tcPVector::size_type i) const { return thePartons[i]; }
0080 
0081   /**
0082    * Return the total momentum for the partons in the colour singlet.
0083    */
0084   LorentzMomentum momentum() const;
0085 
0086   /**
0087    * Return the number of string pieces.
0088    */
0089   Index nPieces() const { return thePieces.size(); }
0090 
0091   /**
0092    * Return the partons belonging to string piece with index i (note
0093    * that the indices starts with 1).
0094    */
0095   StringPiece & piece(Index i) { return thePieces[i - 1]; }
0096 
0097   /**
0098    * Return the partons belonging to string piece with index i (note
0099    * that the indices starts with 1).
0100    */
0101   const StringPiece & piece(Index i) const { return thePieces[i - 1]; }
0102 
0103   /**
0104    * Return the sink (or source if \a forward is false) neighbors of
0105    * a string piece with index i (note that the indices starts with 1).
0106    */
0107   Junction & junction(Index i, bool forward) {
0108     return forward ? sink(i) : source(i);
0109   }
0110 
0111   /**
0112    * Return the sink (or source if \a forward is false) neighbors of
0113    * a string piece with index i (note that the indices starts with 1).
0114    */
0115   const Junction & junction(Index i, bool forward) const {
0116     return forward ? sink(i) : source(i);
0117   }
0118 
0119   /**
0120    * Return the sink or source neighbors of a string piece with index
0121    * i (note that the indices starts with 1).
0122    */
0123   Junction & sink(Index i) { return theSinks[i - 1]; }
0124 
0125   /**
0126    * Return the sink or source neighbors of a string piece with index
0127    * i (note that the indices starts with 1).
0128    */
0129   const Junction & sink(Index i) const { return theSinks[i - 1]; }
0130 
0131   /**
0132    * Return the sink or source neighbors of a string piece with index
0133    * i (note that the indices starts with 1).
0134    */
0135   Junction & source(Index i) { return theSources[i - 1]; }
0136   /**
0137    * Return the sink or source neighbors of a string piece with index
0138    * i (note that the indices starts with 1).
0139    */
0140   const Junction & source(Index i) const { return theSources[i - 1]; }
0141 
0142   /**
0143    * Extract colour-singlet strings/clusters of partons from the given
0144    * set. The set will be empty afterwards if all went well - even
0145    * colour-singlet particles will be removed.
0146    */
0147   static vector<ColourSinglet> getSinglets(tcParticleSet & left);
0148 
0149   /**
0150    * Extract colour-singlet strings/clusters of partons from the given
0151    * range of particles.
0152    */
0153   template <typename Iterator>
0154   static vector<ColourSinglet>
0155   getSinglets(Iterator first, Iterator last) {
0156     tcParticleSet pset(first, last);
0157     return getSinglets(pset);
0158   }
0159 
0160   /**
0161    * Return a vector with data objects corresponding to all triplet
0162    * partons in this singlet.
0163    */
0164   tcPDVector getTripletData() const;
0165 
0166   /**
0167    * Split a junction string. Split an internal string piece \a sp
0168    * (one that starts from a source and ends in a sink). Randomly pair
0169    * together the connectin string pieces and randomly assign possible
0170    * colour octet partons to the two joined string pieces. The singlet
0171    * will then split into two - one is returned and this will contain
0172    * the other. If no argument is given, a random internal line will
0173    * be picked.
0174    */
0175   ColourSinglet splitInternal(Index sp = 0);
0176 
0177   /**
0178    * Split a junction string. Split an internal string piece \a sp
0179    * (one that starts from a source and ends in a sink). The source
0180    * neighbour \a sa will be joined with the sink neighbour \a
0181    * sc. Possible colour octet partons in the split string piece will
0182    * be assigned to the joined \a sa-\a sc string piece if the
0183    * corresponing \a assign element is true. The singlet will then
0184    * split into two - one is returned and this will contain the other.
0185    */
0186   ColourSinglet splitInternal(Index sp, Index sa, Index sc,
0187                   const vector<bool> & assing);
0188 
0189   /**
0190    * Split a junction string. If a sting piece \a sp is connected to a
0191    * junction and ends in a diquark diq, split the diquark into two
0192    * quarks, remove the junction, adding the other partons to the
0193    * first neighbouring string piece if the corresponding \a assign
0194    * element is true. The singlet will then split into two - one is
0195    * returned and this will contain the other. Note that the
0196    * parent-children relationship and colour flows of the diquark and
0197    * the two quarks is not handled by this function.
0198    */
0199   ColourSinglet
0200   splitDiQuarkJunction(Index sp, tcPPtr diq, tcPPair qq,
0201                const vector<bool> & assign = vector<bool>());
0202 
0203   /**
0204    * Split a di-quark string. If this singlet is a simple string with
0205    * (anti-)diquarks in both ends, split the diquarks into the given
0206    * quark pairs and create two new string pieces the betwen the quark
0207    * and anit-quarks, adding the remaining partons to the first piece
0208    * if the corresponding \a assign element is true. The singlet will
0209    * then split into two - one is returned and this will contain the
0210    * other. Note that the parent-children relationship and colour
0211    * flows of the diquark and the two quarks is not handled by this
0212    * function.
0213    */
0214   ColourSinglet splitDiDiQuark(tcPPair qq1, tcPPair qq2,
0215                    const vector<bool> & assign = vector<bool>());
0216 
0217   /**
0218    * Swap this colour singlet for the argument.
0219    */
0220   void swap(ColourSinglet & x) {
0221     thePartons.swap(x.thePartons);
0222     thePieces.swap(x.thePieces);
0223     theSources.swap(x.theSources);
0224     theSinks.swap(x.theSinks);
0225   }
0226 
0227 private:
0228 
0229   /**
0230    * Fill a string piece. Follow a colour line \a forward in colour
0231    * removing partons from the \a left set and adding them to the
0232    * string piece \a s0 as we go along. If a line ends in a colour
0233    * sink/source, follow the other two colour lines in turn with the
0234    * value of \a forward reversed.
0235    */
0236   bool fill(Index s0, bool forward, tcColinePtr first, tcParticleSet & left);
0237 
0238   /**
0239    * Fill a string piece. When creating a new singlet from an old one
0240    * which has been split, add the string piece \a i1. If it ends in a
0241    * sink or a source add the neighbors recursively.
0242    */
0243   void fill(Index i0, bool forward, const ColourSinglet & cs, Index i1);
0244 
0245   /**
0246    * Add a new string piece and return its index.
0247    */
0248   Index addPiece() {
0249     thePieces.push_back(StringPiece());
0250     theSinks.push_back(Junction());
0251     theSources.push_back(Junction());
0252     return nPieces();
0253   }
0254 
0255   /**
0256    * Add a junction which is a source (or sink if \a forward) to the
0257    * string piece \a s0. Return the indices of the two connected
0258    * string pieces.
0259    */
0260   Junction addJunction(Index s0, bool forward);
0261 
0262 public:
0263 
0264   /** @cond EXCEPTIONCLASSES */
0265   /** An exception class to indicate that something went wrong with a
0266    *  ColourSinglet. */
0267   class ColourSingletException: public Exception {};
0268   /** @endcond */
0269 
0270 private:
0271 
0272   /**
0273    * The vector of all partons.
0274    */
0275   tcPVector thePartons;
0276 
0277   /**
0278    * The different string pieces.
0279    */
0280   vector<StringPiece> thePieces;
0281 
0282   /**
0283    * The source neighbours of the string pieces.
0284    */
0285   vector<Junction> theSources;
0286 
0287   /**
0288    * The sink neighbours of the string pieces.
0289    */
0290   vector<Junction> theSinks;
0291 
0292 };
0293 
0294 }
0295 
0296 #endif /* ThePEG_ColourSinglet_H */