thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
ColourLine.h
1 // -*- C++ -*-
2 //
3 // ColourLine.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 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 &) = delete;
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 */
PersistentIStream is used to read persistent objects from a stream where they were previously written...
pair< tColinePtr, tColinePtr > tColinePair
A pair of transient pointers to ColourLine objects.
Definition: Containers.h:148
Define the base class from which all (polymorphic) classes in ThePEG are derived. ...
Definition: ThePEG.h:54
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30
This is the main config header file for the Event classes.
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
void addAntiColouredIndexed(tPPtr p, int index)
Add a particle having this as a anti-colour line at a given index.
ColourLine & operator=(const ColourLine &)=delete
Private and non-existent assignment operator.
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
const tPVector & antiColoured() const
Return the vectors of particles connected to this line with their anti-colours.
Definition: ColourLine.h:93
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:696
void setSourceNeighbours(tColinePtr l1, tColinePtr l2)
Add two colour lines as neighbours to this line.
Definition: ColourLine.h:185
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
tPVector theColoured
The particles connecting to this colour line, following the incoming colour flow. ...
Definition: ColourLine.h:240
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
void setSinkNeighbours(tColinePtr l1, tColinePtr l2)
Add two colour lines as neighbours to this line.
Definition: ColourLine.h:174
void addColoured(tPPtr p, bool anti=false)
Add a particle having this as a (anti-)colour line.
void removeAntiColoured(tPPtr)
Remove a particle having this as an anti-colour line.
void write(ostream &os, tcEventPtr event, bool anti) const
Write out information about this colour line to the stream.
static tColinePtr create(tPPtr col, tPPtr anti)
Create a colour line.
tPPtr startParticle() const
Return the first particle on this colour line.
static tColinePtr createAnti(tPPtr p)
Create a colour line.
Definition: ColourLine.h:62
tColinePair theSinkNeighbours
If this colour line ends in a colour sink, these two colour lines ends in the same.
Definition: ColourLine.h:258
virtual ~ColourLine()
Destructor.
tColinePair sourceNeighbours(bool anti=false) const
If this colour line stems from a colour source (sink), these two colour lines stems from (ends in) th...
Definition: ColourLine.h:165
void removeColoured(tPPtr p, bool anti=false)
Remove a particle having this as a (anti-)colour line.
tColinePair sinkNeighbours() const
If this colour line ends in a colour sink, these two colour lines ends in the same.
Definition: ColourLine.h:158
void addColouredIndexed(tPPtr p, int index, bool anti=false)
Add a particle having this as a (anti-)colour line at a given index.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
void addAntiColoured(tPPtr)
Add a particle having this as a anti-colour line.
tColinePair theSourceNeighbours
If this colour line stems from a colour source, these two colour lines stems from the same...
Definition: ColourLine.h:252
std::iterator_traits< Iterator >::value_type getColouredParticle(Iterator first, Iterator last, bool anti=false) const
Return the first (anti-)coloured parton among the given range of particles which is on this colour li...
Definition: ColourLine.h:209
bool join(ColinePtr line)
Join with the given ColourLine.
vector< ColinePtr > orphanedConnectors
Colour lines which are connectors between two junctions do not have a particle which owns it...
Definition: ColourLine.h:265
void persistentOutput(PersistentOStream &) const
Standard function for writing to a persistent stream.
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134
tPPtr endParticle() const
Return the last particle on this colour line.
The ColourLine class represents colour lines connecting Particles.
Definition: ColourLine.h:36
static ClassDescription< ColourLine > initColourLine
Describe a concrete class with persistent data.
Definition: ColourLine.h:272
tPVector theAntiColoured
The particles connecting to this colour line, following the outgoing colour flow. ...
Definition: ColourLine.h:246
vector< tPPtr > tPVector
A vector of transient pointers to Particle objects.
Definition: Containers.h:82
const tPVector & coloured() const
Return the vectors of particles connected to this line with their colours.
Definition: ColourLine.h:87
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
Definition: ClassTraits.h:52
void persistentInput(PersistentIStream &, int)
Standard function for reading from a persistent stream.