00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_ColourLine_H
00010 #define ThePEG_ColourLine_H
00011
00012
00013 #include "EventConfig.h"
00014 #include "ThePEG/Utilities/ClassDescription.h"
00015 #include "ThePEG/EventRecord/ColourSinglet.h"
00016
00017 namespace ThePEG {
00018
00036 class ColourLine: public EventRecordBase {
00037
00038 public:
00039
00046 static tColinePtr create(tPPtr col, tPPtr anti);
00047
00055 static tColinePtr create(tPPtr p, bool anti = false);
00056
00062 static tColinePtr createAnti(tPPtr p) { return create(p, true); }
00063
00070 static tColinePtr create(tColinePtr son1, tColinePtr son2,
00071 tColinePtr sin1, tColinePtr sin2);
00073
00077 virtual ~ColourLine();
00078
00079 public:
00080
00087 const tPVector & coloured() const { return theColoured; }
00088
00093 const tPVector & antiColoured() const { return theAntiColoured; }
00094
00101 tPPtr startParticle() const;
00102
00108 tPPtr endParticle() const;
00109
00111
00117 void addAntiColoured(tPPtr);
00118
00124 void addColoured(tPPtr p, bool anti = false);
00125
00129 void removeAntiColoured(tPPtr);
00130
00136 void removeColoured(tPPtr p, bool anti = false);
00137
00139
00146 tColinePair sinkNeighbours() const { return theSinkNeighbours; }
00147
00153 tColinePair sourceNeighbours(bool anti = false) const {
00154 return anti? theSinkNeighbours: theSourceNeighbours;
00155 }
00156
00162 void setSinkNeighbours(tColinePtr l1, tColinePtr l2) {
00163 theSinkNeighbours.second = l1->theSinkNeighbours.second = l2;
00164 l2->theSinkNeighbours.second = theSinkNeighbours.first = l1;
00165 l1->theSinkNeighbours.first = l2->theSinkNeighbours.first = this;
00166 }
00167
00173 void setSourceNeighbours(tColinePtr l1, tColinePtr l2) {
00174 theSourceNeighbours.second = l1->theSourceNeighbours.second = l2;
00175 l2->theSourceNeighbours.second = theSourceNeighbours.first = l1;
00176 l1->theSourceNeighbours.first = l2->theSourceNeighbours.first = this;
00177 }
00178
00180
00189 bool join(ColinePtr line);
00190
00195 template <typename Iterator>
00196 typename std::iterator_traits<Iterator>::value_type
00197 getColouredParticle(Iterator first, Iterator last, bool anti = false) const {
00198 typedef typename std::iterator_traits<Iterator>::value_type ParticlePointer;
00199 for ( ; first != last; ++first )
00200 if ( (**first).coloured() && (**first).hasColourLine(this, anti) )
00201 return *first;
00202 return ParticlePointer();
00203 }
00204
00208 void write(ostream & os, tcEventPtr event, bool anti) const;
00209
00210 public:
00211
00215 void persistentOutput(PersistentOStream &) const;
00216
00220 void persistentInput(PersistentIStream &, int);
00221
00222 private:
00223
00228 tPVector theColoured;
00229
00234 tPVector theAntiColoured;
00235
00240 tColinePair theSourceNeighbours;
00241
00246 tColinePair theSinkNeighbours;
00247
00253 vector<ColinePtr> orphanedConnectors;
00254
00255 private:
00256
00260 static ClassDescription<ColourLine> initColourLine;
00261
00265 ColourLine & operator=(const ColourLine &);
00266
00267 };
00268
00269 }
00270
00271
00272 namespace ThePEG {
00273
00280 template <>
00281 struct BaseClassTrait<ColourLine,1>: public ClassTraitsType {
00283 typedef EventRecordBase NthBase;
00284 };
00285
00290 template <>
00291 struct ClassTraits<ColourLine>: public ClassTraitsBase<ColourLine> {
00293 static string className() { return "ThePEG::ColourLine"; }
00296 static string library() { return "ColourLine.so"; }
00297 };
00298
00301 }
00302
00303 #endif