File: ColourLine.h

package info (click to toggle)
thepeg 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 9,312 kB
  • ctags: 11,509
  • sloc: cpp: 57,129; sh: 11,315; java: 3,212; lisp: 1,402; makefile: 830; ansic: 58; perl: 3
file content (315 lines) | stat: -rw-r--r-- 9,074 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
// -*- C++ -*-
//
// ColourLine.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_ColourLine_H
#define ThePEG_ColourLine_H
// This is the declaration of the ColourLine class.

#include "EventConfig.h"
#include "ThePEG/Utilities/ClassDescription.h"
#include "ThePEG/EventRecord/ColourSinglet.h"

namespace ThePEG {

/**
 * The ColourLine class represents colour lines connecting
 * <code>Particle</code>s. A <code>ColourLine</code> keeps track on
 * the particles connected to it. To connect a particle to a colour
 * line the <code>addColoured()</code> and
 * <code>addAntiColoured()</code> functions should be used - these
 * will automatically set up the Particle correctly. There is no
 * method in a Particle to directly set its colour lines.
 *
 * If a colour line stems from a colour source or ends in a colour
 * sink, it is possible to obtain the neighbouring colour lines. This
 * is also the way junction strings and sinks and sources are
 * implemented.
 *
 * @see Particle
 * @see ColourBase
 */
class ColourLine: public EventRecordBase {

public:

  /** @name Creation functions. */
  //@{
  /**
   * Create a colour line. Set a pair of colour - anticolour particles
   * in a newly created colour line.
   */
  static tColinePtr create(tPPtr col, tPPtr anti);

  /**
   * Create a colour line. Set a particle for which the created object
   * is a (anti-)colour line .
   * @param p the particle to be connected.
   * @param anti if true, the created object is the anti-colour line
   * of \a p.
   */
  static tColinePtr create(tPPtr p, bool anti = false);

  /**
   * Create a colour line. Set a particle for which the created object
   * is a anti-colour line .
   * @param p the particle to be connected.
   */
  static tColinePtr createAnti(tPPtr p) { return create(p, true); }

  /**
   * Create a coloue line which is a connector between two junctions,
   * a source junction with neigboring colour lines \a son1 and \a
   * son2 and a sink junction with neigboring colour lines \a sin1 and
   * \a sin2.
   */
  static tColinePtr create(tColinePtr son1, tColinePtr son2,
			   tColinePtr sin1, tColinePtr sin2);
  //@}

  /**
   * Destructor.
   */
  virtual ~ColourLine();

public:

  /** @name Access particles connected to the colour line. */
  //@{
  /**
   * Return the vectors of particles connected to this line with their
   * colours.
   */
  const tPVector & coloured() const { return theColoured; }

  /**
   * Return the vectors of particles connected to this line with their
   * anti-colours.
   */
  const tPVector & antiColoured() const { return theAntiColoured; }

  /**
   * Return the first particle on this colour line. Returns null if
   * this line stems from a colour source. If the particle is
   * outgoing, its anti colour is connected, otherwise its colour is
   * connected.
   */
  tPPtr startParticle() const;

  /**
   * Return the last particle on this colour line. Returns null if
   * this line ends in a colour sink. If the particle is outgoing, its
   * colour is connected, otherwise its anti colour is connected.
   */
  tPPtr endParticle() const;

  //@}

  /** @name Add and remove particles in a colour line. */
  //@{
  /**
   * Add a particle having this as a anti-colour line.
   */
  void addAntiColoured(tPPtr);

  /**
   * Add a particle having this as a (anti-)colour line.
   * @param p the particle to be connected.
   * @param anti if true, this is the anti-colour line of \a p.
   */
  void addColoured(tPPtr p, bool anti = false);

  /**
   * Add a particle having this as a anti-colour line at a given index.
   */
  void addAntiColouredIndexed(tPPtr p, int index);

  /**
   * Add a particle having this as a (anti-)colour line at a given index.
   * @param p the particle to be connected.
   * @param anti if true, this is the anti-colour line of \a p.
   */
  void addColouredIndexed(tPPtr p, int index, bool anti=false);

  /**
   * Remove a particle having this as an anti-colour line.
   */
  void removeAntiColoured(tPPtr);

  /**
   * Remove a particle having this as a (anti-)colour line.
   * @param p the particle to be removed.
   * @param anti if true, this is the anti-colour line of \a p.
   */
  void removeColoured(tPPtr p, bool anti = false);

  //@}

  /** @name Functions for junction strings. */
  //@{
  /**
   * If this colour line ends in a colour sink, these two colour lines
   * ends in the same.
   */
  tColinePair sinkNeighbours() const { return theSinkNeighbours; }

  /**
   * If this colour line stems from a colour source (sink), these two colour
   * lines stems from (ends in) the same.
   * @param anti if true return sinkNeighbours().
   */
  tColinePair sourceNeighbours(bool anti = false) const {
    return anti? theSinkNeighbours: theSourceNeighbours;
  }

  /**
   * Add two colour lines as neighbours to this line. Afterwards all
   * three will end in the same sink. Also the neighbors are set up
   * correspondingly.
   */
  void setSinkNeighbours(tColinePtr l1, tColinePtr l2) {
    theSinkNeighbours.second = l1->theSinkNeighbours.second = l2;
    l2->theSinkNeighbours.second = theSinkNeighbours.first = l1;
    l1->theSinkNeighbours.first = l2->theSinkNeighbours.first = this;
  }

  /**
   * Add two colour lines as neighbours to this line. Afterwards all
   * three will stem from the same source. Also the neighbors are set
   * up correspondingly.
   */
  void setSourceNeighbours(tColinePtr l1, tColinePtr l2) {
    theSourceNeighbours.second = l1->theSourceNeighbours.second = l2;
    l2->theSourceNeighbours.second = theSourceNeighbours.first = l1;
    l1->theSourceNeighbours.first = l2->theSourceNeighbours.first = this;
  }

  //@}

  /**
   * Join with the given ColourLine. The colour of the given \a line
   * is joined so that it will flow into this line, ie. the
   * anti-coloured particle in the end of the \a line will become
   * connected to the coloured particle in the of this line.  After
   * the joining the given \a line will not be connected to
   * anything.
   */
  bool join(ColinePtr line);

  /**
   * Return the first (anti-)coloured parton among the given range of
   * particles which is on this colour line.
   */
  template <typename Iterator>
  typename std::iterator_traits<Iterator>::value_type
  getColouredParticle(Iterator first, Iterator last, bool anti = false) const {
    typedef typename std::iterator_traits<Iterator>::value_type ParticlePointer;
    for ( ; first != last; ++first )
      if ( (**first).coloured() && (**first).hasColourLine(this, anti) )
	return *first;
    return ParticlePointer();
  }

  /**
   * Write out information about this colour line to the stream.
   */
  void write(ostream & os, tcEventPtr event, bool anti) const;

public:

  /**
   * Standard function for writing to a persistent stream.
   */
  void persistentOutput(PersistentOStream &) const;

  /**
   * Standard function for reading from a persistent stream.
   */
  void persistentInput(PersistentIStream &, int);

private:

  /**
   * The particles connecting to this colour line, following the
   * incoming colour flow.
   */
  tPVector theColoured;

  /**
   * The particles connecting to this colour line, following the
   * outgoing colour flow.
   */
  tPVector theAntiColoured;

  /**
   * If this colour line stems from a colour source, these two colour
   * lines stems from the same.
   */
  tColinePair theSourceNeighbours;

  /**
   * If this colour line ends in a colour sink, these two colour lines
   * ends in the same.
   */
  tColinePair theSinkNeighbours;

  /**
   * Colour lines which are connectors between two junctions do not
   * have a particle which owns it, instead it is owned by one of the
   * source neighbours.
   */
  vector<ColinePtr> orphanedConnectors;

private:

  /**
   * Describe a concrete class with persistent data.
   */
  static ClassDescription<ColourLine> initColourLine;

  /**
   *  Private and non-existent assignment operator.
   */
  ColourLine & operator=(const ColourLine &);

};

}


namespace ThePEG {

/** @cond TRAITSPECIALIZATIONS */

/**
 * The following template specialization informs ThePEG about the
 * base class of ColourLine.
 */
template <>
struct BaseClassTrait<ColourLine,1>: public ClassTraitsType {
  /** Typedef of the first base class of ColourLine. */
  typedef EventRecordBase NthBase;
};

/**
 * The following template specialization informs ThePEG about the
 * name of this class and the shared object where it is defined.
 */
template <>
struct ClassTraits<ColourLine>: public ClassTraitsBase<ColourLine> {
  /** Return the class name. */
  static string className() { return "ThePEG::ColourLine"; }
  /** Return the name of the shared library to be loaded to get
   * access to this class. */
  static string library() { return "ColourLine.so"; }
};

/** @endcond */

}

#endif /* ThePEG_ColourLine_H */