Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // ColourBase.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_ColourBase_H
0010 #define ThePEG_ColourBase_H
0011 // This is the declaration of the ColourBase class.
0012 
0013 #include "ThePEG/EventRecord/EventInfoBase.h"
0014 #include "ThePEG/EventRecord/ColourLine.h"
0015 
0016 namespace ThePEG {
0017 
0018 /**
0019  * ColourBase is the base class to be used to supply a
0020  * Particle with information about its colour
0021  * state. This base class supplies information about the
0022  * <code>ColourLine</code>s to which the particle is
0023  * connected. This should be sufficient for most uses. If any other
0024  * info is required for a particle, it may be supplied by an object of
0025  * a sub-class of <code>ColourBase</code>, the additional information
0026  * would then have to be extracted by dynamically casting to the
0027  * sub-class.
0028  *
0029  * @see Particle
0030  * @see ColourLine
0031  */
0032 class ColourBase: public EventInfoBase {
0033 
0034 public:
0035 
0036   /** ColourLine is a good friend. */
0037   friend class ColourLine;
0038 
0039 public:
0040 
0041   /**
0042    * Return the anti-colour line to which this particle is connected.
0043    */
0044   tColinePtr antiColourLine() const { return theAntiColourLine; }
0045 
0046   /**
0047    * Return the colour line to which this particle is connected.
0048    */
0049   tColinePtr colourLine() const { return theColourLine; }
0050 
0051   /**
0052    * Return the anti-colour lines to which this particle is
0053    * connected. (Always only one colour line for this base class.)
0054    */
0055   virtual vector<tcColinePtr> antiColourLines() const;
0056 
0057   /**
0058    * Return the colour lines to which this particle is
0059    * connected. (Always only one colour line for this base class.)
0060    */
0061   virtual vector<tcColinePtr> colourLines() const;
0062 
0063   /**
0064    * Return true if the particle is connected to the given (\a anti-)
0065    * colour \a line.
0066    */
0067   virtual bool hasColourLine(tcColinePtr line, bool anti = false) const;
0068 
0069   /**
0070    * Return true if the particle is connected to the given anti-colour
0071    * \a line.
0072    */
0073   bool hasAntiColourLine(tcColinePtr line) const {
0074     return hasColourLine(line, true);
0075   }
0076 
0077 protected:
0078 
0079   /**
0080    * Set the anti-colour \a line to which this particle is connected.
0081    */
0082   virtual void antiColourLine(tColinePtr line) {
0083     theAntiColourLine = line;
0084   }
0085 
0086   /**
0087    * Set the (\a anti-) colour line to which this particle is connected.
0088    */
0089   virtual void colourLine(tColinePtr l, bool anti = false) {
0090     if ( anti ) antiColourLine(l);
0091     else theColourLine = l;
0092   }
0093 
0094   /**
0095    * Remove the anti-colour \a line to which this particle is connected.
0096    */
0097   virtual void removeAntiColourLine(tcColinePtr line) {
0098     if ( antiColourLine() == line ) theAntiColourLine = tColinePtr();
0099   }
0100 
0101   /**
0102    * Remove the (\a anti-) colour line to which this particle is connected.
0103    */
0104   virtual void removeColourLine(tcColinePtr line, bool anti = false) {
0105     if ( anti ) removeAntiColourLine(line);
0106     else if ( colourLine() == line ) theColourLine = tColinePtr();
0107   }
0108 
0109 public:
0110 
0111   /**
0112    * Rebind to cloned objects. When a ColourBase is cloned, a shallow
0113    * copy is done first, then all <code>ColourLine</code>s etc, are
0114    * cloned, and finally this method is used to see to that the
0115    * pointers in the cloned ColourBase points to the cloned
0116    * <code>ColourLine</code>s etc.
0117    */
0118   virtual void rebind(const EventTranslationMap & trans);
0119 
0120   /**
0121    * Standard function for writing to a persistent stream.
0122    */
0123   void persistentOutput(PersistentOStream &) const;
0124 
0125   /**
0126    * Standard functions for reading from a persistent stream.
0127    */
0128   void persistentInput(PersistentIStream &, int);
0129 
0130   /**
0131    * Standard Init function. @see Base::Init().
0132    */
0133   static void Init();
0134 
0135   /**
0136    * Standard clone method.
0137    */
0138   virtual EIPtr clone() const;
0139 
0140 private:
0141 
0142   /**
0143    * The anti-colour line to which this particle is connected.
0144    */
0145   ColinePtr theAntiColourLine;
0146 
0147   /**
0148    * The colour line to which this particle is connected.
0149    */
0150   ColinePtr theColourLine;
0151 
0152 private:
0153 
0154   /**
0155    * Describe concrete class with persistent data.
0156    */
0157   static ClassDescription<ColourBase> initColourBase;
0158 
0159   /**
0160    *  Private and non-existent assignment operator.
0161    */
0162   ColourBase & operator=(const ColourBase &) = delete;
0163 
0164 };
0165 
0166 
0167 /** @cond TRAITSPECIALIZATIONS */
0168 ThePEG_DECLARE_CLASS_TRAITS(ColourBase,EventInfoBase);
0169 /** @endcond */
0170 
0171 }
0172 
0173 #endif /* ThePEG_ColourBase_H */