|
|
|||
File indexing completed on 2026-08-06 09:38:21
0001 // -*- C++ -*- 0002 // 0003 // ColourLine.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_ColourLine_H 0010 #define ThePEG_ColourLine_H 0011 // This is the declaration of the ColourLine class. 0012 0013 #include "EventConfig.h" 0014 #include "ThePEG/Utilities/ClassDescription.h" 0015 #include "ThePEG/EventRecord/ColourSinglet.h" 0016 0017 namespace ThePEG { 0018 0019 /** 0020 * The ColourLine class represents colour lines connecting 0021 * <code>Particle</code>s. A <code>ColourLine</code> keeps track on 0022 * the particles connected to it. To connect a particle to a colour 0023 * line the <code>addColoured()</code> and 0024 * <code>addAntiColoured()</code> functions should be used - these 0025 * will automatically set up the Particle correctly. There is no 0026 * method in a Particle to directly set its colour lines. 0027 * 0028 * If a colour line stems from a colour source or ends in a colour 0029 * sink, it is possible to obtain the neighbouring colour lines. This 0030 * is also the way junction strings and sinks and sources are 0031 * implemented. 0032 * 0033 * @see Particle 0034 * @see ColourBase 0035 */ 0036 class ColourLine: public EventRecordBase { 0037 0038 public: 0039 0040 /** @name Creation functions. */ 0041 //@{ 0042 /** 0043 * Create a colour line. Set a pair of colour - anticolour particles 0044 * in a newly created colour line. 0045 */ 0046 static tColinePtr create(tPPtr col, tPPtr anti); 0047 0048 /** 0049 * Create a colour line. Set a particle for which the created object 0050 * is a (anti-)colour line . 0051 * @param p the particle to be connected. 0052 * @param anti if true, the created object is the anti-colour line 0053 * of \a p. 0054 */ 0055 static tColinePtr create(tPPtr p, bool anti = false); 0056 0057 /** 0058 * Create a colour line. Set a particle for which the created object 0059 * is a anti-colour line . 0060 * @param p the particle to be connected. 0061 */ 0062 static tColinePtr createAnti(tPPtr p) { return create(p, true); } 0063 0064 /** 0065 * Create a coloue line which is a connector between two junctions, 0066 * a source junction with neigboring colour lines \a son1 and \a 0067 * son2 and a sink junction with neigboring colour lines \a sin1 and 0068 * \a sin2. 0069 */ 0070 static tColinePtr create(tColinePtr son1, tColinePtr son2, 0071 tColinePtr sin1, tColinePtr sin2); 0072 //@} 0073 0074 /** 0075 * Destructor. 0076 */ 0077 virtual ~ColourLine(); 0078 0079 public: 0080 0081 /** @name Access particles connected to the colour line. */ 0082 //@{ 0083 /** 0084 * Return the vectors of particles connected to this line with their 0085 * colours. 0086 */ 0087 const tPVector & coloured() const { return theColoured; } 0088 0089 /** 0090 * Return the vectors of particles connected to this line with their 0091 * anti-colours. 0092 */ 0093 const tPVector & antiColoured() const { return theAntiColoured; } 0094 0095 /** 0096 * Return the first particle on this colour line. Returns null if 0097 * this line stems from a colour source. If the particle is 0098 * outgoing, its anti colour is connected, otherwise its colour is 0099 * connected. 0100 */ 0101 tPPtr startParticle() const; 0102 0103 /** 0104 * Return the last particle on this colour line. Returns null if 0105 * this line ends in a colour sink. If the particle is outgoing, its 0106 * colour is connected, otherwise its anti colour is connected. 0107 */ 0108 tPPtr endParticle() const; 0109 0110 //@} 0111 0112 /** @name Add and remove particles in a colour line. */ 0113 //@{ 0114 /** 0115 * Add a particle having this as a anti-colour line. 0116 */ 0117 void addAntiColoured(tPPtr); 0118 0119 /** 0120 * Add a particle having this as a (anti-)colour line. 0121 * @param p the particle to be connected. 0122 * @param anti if true, this is the anti-colour line of \a p. 0123 */ 0124 void addColoured(tPPtr p, bool anti = false); 0125 0126 /** 0127 * Add a particle having this as a anti-colour line at a given index. 0128 */ 0129 void addAntiColouredIndexed(tPPtr p, int index); 0130 0131 /** 0132 * Add a particle having this as a (anti-)colour line at a given index. 0133 * @param p the particle to be connected. 0134 * @param anti if true, this is the anti-colour line of \a p. 0135 */ 0136 void addColouredIndexed(tPPtr p, int index, bool anti=false); 0137 0138 /** 0139 * Remove a particle having this as an anti-colour line. 0140 */ 0141 void removeAntiColoured(tPPtr); 0142 0143 /** 0144 * Remove a particle having this as a (anti-)colour line. 0145 * @param p the particle to be removed. 0146 * @param anti if true, this is the anti-colour line of \a p. 0147 */ 0148 void removeColoured(tPPtr p, bool anti = false); 0149 0150 //@} 0151 0152 /** @name Functions for junction strings. */ 0153 //@{ 0154 /** 0155 * If this colour line ends in a colour sink, these two colour lines 0156 * ends in the same. 0157 */ 0158 tColinePair sinkNeighbours() const { return theSinkNeighbours; } 0159 0160 /** 0161 * If this colour line stems from a colour source (sink), these two colour 0162 * lines stems from (ends in) the same. 0163 * @param anti if true return sinkNeighbours(). 0164 */ 0165 tColinePair sourceNeighbours(bool anti = false) const { 0166 return anti? theSinkNeighbours: theSourceNeighbours; 0167 } 0168 0169 /** 0170 * Add two colour lines as neighbours to this line. Afterwards all 0171 * three will end in the same sink. Also the neighbors are set up 0172 * correspondingly. 0173 */ 0174 void setSinkNeighbours(tColinePtr l1, tColinePtr l2) { 0175 theSinkNeighbours.second = l1->theSinkNeighbours.second = l2; 0176 l2->theSinkNeighbours.second = theSinkNeighbours.first = l1; 0177 l1->theSinkNeighbours.first = l2->theSinkNeighbours.first = this; 0178 } 0179 0180 /** 0181 * Add two colour lines as neighbours to this line. Afterwards all 0182 * three will stem from the same source. Also the neighbors are set 0183 * up correspondingly. 0184 */ 0185 void setSourceNeighbours(tColinePtr l1, tColinePtr l2) { 0186 theSourceNeighbours.second = l1->theSourceNeighbours.second = l2; 0187 l2->theSourceNeighbours.second = theSourceNeighbours.first = l1; 0188 l1->theSourceNeighbours.first = l2->theSourceNeighbours.first = this; 0189 } 0190 0191 //@} 0192 0193 /** 0194 * Join with the given ColourLine. The colour of the given \a line 0195 * is joined so that it will flow into this line, ie. the 0196 * anti-coloured particle in the end of the \a line will become 0197 * connected to the coloured particle in the of this line. After 0198 * the joining the given \a line will not be connected to 0199 * anything. 0200 */ 0201 bool join(ColinePtr line); 0202 0203 /** 0204 * Return the first (anti-)coloured parton among the given range of 0205 * particles which is on this colour line. 0206 */ 0207 template <typename Iterator> 0208 typename std::iterator_traits<Iterator>::value_type 0209 getColouredParticle(Iterator first, Iterator last, bool anti = false) const { 0210 typedef typename std::iterator_traits<Iterator>::value_type ParticlePointer; 0211 for ( ; first != last; ++first ) 0212 if ( (**first).coloured() && (**first).hasColourLine(this, anti) ) 0213 return *first; 0214 return ParticlePointer(); 0215 } 0216 0217 /** 0218 * Write out information about this colour line to the stream. 0219 */ 0220 void write(ostream & os, tcEventPtr event, bool anti) const; 0221 0222 public: 0223 0224 /** 0225 * Standard function for writing to a persistent stream. 0226 */ 0227 void persistentOutput(PersistentOStream &) const; 0228 0229 /** 0230 * Standard function for reading from a persistent stream. 0231 */ 0232 void persistentInput(PersistentIStream &, int); 0233 0234 private: 0235 0236 /** 0237 * The particles connecting to this colour line, following the 0238 * incoming colour flow. 0239 */ 0240 tPVector theColoured; 0241 0242 /** 0243 * The particles connecting to this colour line, following the 0244 * outgoing colour flow. 0245 */ 0246 tPVector theAntiColoured; 0247 0248 /** 0249 * If this colour line stems from a colour source, these two colour 0250 * lines stems from the same. 0251 */ 0252 tColinePair theSourceNeighbours; 0253 0254 /** 0255 * If this colour line ends in a colour sink, these two colour lines 0256 * ends in the same. 0257 */ 0258 tColinePair theSinkNeighbours; 0259 0260 /** 0261 * Colour lines which are connectors between two junctions do not 0262 * have a particle which owns it, instead it is owned by one of the 0263 * source neighbours. 0264 */ 0265 vector<ColinePtr> orphanedConnectors; 0266 0267 private: 0268 0269 /** 0270 * Describe a concrete class with persistent data. 0271 */ 0272 static ClassDescription<ColourLine> initColourLine; 0273 0274 /** 0275 * Private and non-existent assignment operator. 0276 */ 0277 ColourLine & operator=(const ColourLine &) = delete; 0278 0279 }; 0280 0281 } 0282 0283 0284 namespace ThePEG { 0285 0286 /** @cond TRAITSPECIALIZATIONS */ 0287 0288 /** 0289 * The following template specialization informs ThePEG about the 0290 * base class of ColourLine. 0291 */ 0292 template <> 0293 struct BaseClassTrait<ColourLine,1>: public ClassTraitsType { 0294 /** Typedef of the first base class of ColourLine. */ 0295 typedef EventRecordBase NthBase; 0296 }; 0297 0298 /** 0299 * The following template specialization informs ThePEG about the 0300 * name of this class and the shared object where it is defined. 0301 */ 0302 template <> 0303 struct ClassTraits<ColourLine>: public ClassTraitsBase<ColourLine> { 0304 /** Return the class name. */ 0305 static string className() { return "ThePEG::ColourLine"; } 0306 /** Return the name of the shared library to be loaded to get 0307 * access to this class. */ 0308 static string library() { return "ColourLine.so"; } 0309 }; 0310 0311 /** @endcond */ 0312 0313 } 0314 0315 #endif /* ThePEG_ColourLine_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|