ThePEG  1.8.0
ColourSinglet.h
1 // -*- C++ -*-
2 //
3 // ColourSinglet.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_ColourSinglet_H
10 #define ThePEG_ColourSinglet_H
11 
12 #include "ThePEG/EventRecord/EventConfig.h"
13 
14 namespace ThePEG {
15 
32 
33 public:
34 
36  typedef deque<tcPPtr> StringPiece;
38  typedef StringPiece::size_type Index;
40  typedef pair<Index,Index> Junction;
41 
42 public:
43 
48 
54 
55 protected:
56 
62  ColourSinglet(const ColourSinglet & cs, Index si);
63 
64 public:
65 
69  tcPVector & partons() { return thePartons; }
70 
74  const tcPVector & partons() const { return thePartons; }
75 
79  tcPPtr parton(tcPVector::size_type i) const { return thePartons[i]; }
80 
84  LorentzMomentum momentum() const;
85 
89  Index nPieces() const { return thePieces.size(); }
90 
95  StringPiece & piece(Index i) { return thePieces[i - 1]; }
96 
101  const StringPiece & piece(Index i) const { return thePieces[i - 1]; }
102 
107  Junction & junction(Index i, bool forward) {
108  return forward ? sink(i) : source(i);
109  }
110 
115  const Junction & junction(Index i, bool forward) const {
116  return forward ? sink(i) : source(i);
117  }
118 
123  Junction & sink(Index i) { return theSinks[i - 1]; }
124 
129  const Junction & sink(Index i) const { return theSinks[i - 1]; }
130 
135  Junction & source(Index i) { return theSources[i - 1]; }
140  const Junction & source(Index i) const { return theSources[i - 1]; }
141 
147  static vector<ColourSinglet> getSinglets(tcParticleSet & left);
148 
153  template <typename Iterator>
154  static vector<ColourSinglet>
155  getSinglets(Iterator first, Iterator last) {
156  tcParticleSet pset(first, last);
157  return getSinglets(pset);
158  }
159 
164  tcPDVector getTripletData() const;
165 
176 
187  const vector<bool> & assing);
188 
201  const vector<bool> & assign = vector<bool>());
202 
215  const vector<bool> & assign = vector<bool>());
216 
220  void swap(ColourSinglet & x) {
221  thePartons.swap(x.thePartons);
222  thePieces.swap(x.thePieces);
223  theSources.swap(x.theSources);
224  theSinks.swap(x.theSinks);
225  }
226 
227 private:
228 
236  bool fill(Index s0, bool forward, tcColinePtr first, tcParticleSet & left);
237 
243  void fill(Index i0, bool forward, const ColourSinglet & cs, Index i1);
244 
249  thePieces.push_back(StringPiece());
250  theSinks.push_back(Junction());
251  theSources.push_back(Junction());
252  return nPieces();
253  }
254 
260  Junction addJunction(Index s0, bool forward);
261 
262 public:
263 
267  class ColourSingletException: public Exception {};
270 private:
271 
276 
280  vector<StringPiece> thePieces;
281 
285  vector<Junction> theSources;
286 
290  vector<Junction> theSinks;
291 
292 };
293 
294 }
295 
296 #endif /* ThePEG_ColourSinglet_H */