ThePEG  1.8.0
ColourLine.h
1 // -*- C++ -*-
2 //
3 // ColourLine.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_ColourLine_H
10 #define ThePEG_ColourLine_H
11 // This is the declaration of the ColourLine class.
12 
13 #include "EventConfig.h"
14 #include "ThePEG/Utilities/ClassDescription.h"
15 #include "ThePEG/EventRecord/ColourSinglet.h"
16 
17 namespace ThePEG {
18 
36 class ColourLine: public EventRecordBase {
37 
38 public:
39 
46  static tColinePtr create(tPPtr col, tPPtr anti);
47 
55  static tColinePtr create(tPPtr p, bool anti = false);
56 
62  static tColinePtr createAnti(tPPtr p) { return create(p, true); }
63 
70  static tColinePtr create(tColinePtr son1, tColinePtr son2,
71  tColinePtr sin1, tColinePtr sin2);
73 
77  virtual ~ColourLine();
78 
79 public:
80 
87  const tPVector & coloured() const { return theColoured; }
88 
93  const tPVector & antiColoured() const { return theAntiColoured; }
94 
101  tPPtr startParticle() const;
102 
108  tPPtr endParticle() const;
109 
111 
117  void addAntiColoured(tPPtr);
118 
124  void addColoured(tPPtr p, bool anti = false);
125 
129  void addAntiColouredIndexed(tPPtr p, int index);
130 
136  void addColouredIndexed(tPPtr p, int index, bool anti=false);
137 
142 
148  void removeColoured(tPPtr p, bool anti = false);
149 
151 
159 
165  tColinePair sourceNeighbours(bool anti = false) const {
167  }
168 
175  theSinkNeighbours.second = l1->theSinkNeighbours.second = l2;
176  l2->theSinkNeighbours.second = theSinkNeighbours.first = l1;
177  l1->theSinkNeighbours.first = l2->theSinkNeighbours.first = this;
178  }
179 
186  theSourceNeighbours.second = l1->theSourceNeighbours.second = l2;
187  l2->theSourceNeighbours.second = theSourceNeighbours.first = l1;
188  l1->theSourceNeighbours.first = l2->theSourceNeighbours.first = this;
189  }
190 
192 
201  bool join(ColinePtr line);
202 
207  template <typename Iterator>
208  typename std::iterator_traits<Iterator>::value_type
209  getColouredParticle(Iterator first, Iterator last, bool anti = false) const {
210  typedef typename std::iterator_traits<Iterator>::value_type ParticlePointer;
211  for ( ; first != last; ++first )
212  if ( (**first).coloured() && (**first).hasColourLine(this, anti) )
213  return *first;
214  return ParticlePointer();
215  }
216 
220  void write(ostream & os, tcEventPtr event, bool anti) const;
221 
222 public:
223 
227  void persistentOutput(PersistentOStream &) const;
228 
232  void persistentInput(PersistentIStream &, int);
233 
234 private:
235 
241 
247 
253 
259 
265  vector<ColinePtr> orphanedConnectors;
266 
267 private:
268 
273 
277  ColourLine & operator=(const ColourLine &);
278 
279 };
280 
281 }
282 
283 
284 namespace ThePEG {
285 
292 template <>
293 struct BaseClassTrait<ColourLine,1>: public ClassTraitsType {
295  typedef EventRecordBase NthBase;
296 };
297 
302 template <>
303 struct ClassTraits<ColourLine>: public ClassTraitsBase<ColourLine> {
305  static string className() { return "ThePEG::ColourLine"; }
308  static string library() { return "ColourLine.so"; }
309 };
310 
313 }
314 
315 #endif /* ThePEG_ColourLine_H */