ThePEG  1.8.0
Tree2toNDiagram.h
1 // -*- C++ -*-
2 //
3 // Tree2toNDiagram.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_Tree2toNDiagram_H
10 #define ThePEG_Tree2toNDiagram_H
11 // This is the declaration of the Tree2toNDiagram class.
12 
13 #include "ThePEG/MatrixElement/DiagramBase.h"
14 #include "ThePEG/MatrixElement/ColourLines.h"
15 #include "ThePEG/Handlers/StandardXComb.fh"
16 #include "Tree2toNDiagram.xh"
17 
18 namespace ThePEG {
19 
61 
62 public:
63 
65  typedef cPDVector::size_type size_type;
67  typedef multiset<tcPDPtr> PDMSet;
68 
69 public:
70 
77  : theNSpace(0), theNOutgoing(0), nextOrig(0) {}
78 
83 
88  explicit Tree2toNDiagram(int space)
89  : theNSpace(space), theNOutgoing(0), nextOrig(-1) {}
91 
92 public:
93 
99  nextOrig = o - 1;
100  if ( o < 0 ) check();
101  return *this;
102  }
103 
107  Tree2toNDiagram & operator,(PDPtr pd) { return add(pd); }
108 
112  Tree2toNDiagram & operator,(cPDPtr pd) { return add(pd); }
113 
117  Tree2toNDiagram & operator,(tPDPtr pd) { return add(pd); }
118 
122  Tree2toNDiagram & operator,(tcPDPtr pd) { return add(pd); }
123 
131  virtual tPVector construct(SubProPtr sb, const StandardXComb &,
132  const ColourLines &) const;
133 
137  tcPDPair incoming() const;
138 
142  const cPDVector & allPartons() const { return thePartons; }
143 
147  tcPDVector outgoing() const;
148 
153  tcPDVector external() const;
154 
158  int parent(int i) const { return theParents[i]; }
159 
163  pair<int,int> children(int) const;
164 
168  int nSpace() const { return theNSpace; }
169 
173  int nOutgoing() const { return theNOutgoing; }
174 
175 private:
176 
180  void check();
181 
186  if ( thePartons.size() >= theNSpace ) throw Tree2toNDiagramError();
187  theParents.push_back(thePartons.size() - 1);
188  thePartons.push_back(pd);
189  }
193  void addTimelike(tcPDPtr);
194 
198  void addTimelike(tcPDPtr, size_type origin);
199 
204 
205 public:
206 
210  virtual bool isSame(tcDiagPtr) const;
211 
217  virtual bool isSame(tcDiagPtr, map<int,int>&) const;
218 
222  bool equals(Ptr<Tree2toNDiagram>::tcptr, int start=0, int startCmp=0) const;
223 
228  map<int,int>&,
229  int start=0, int startCmp=0) const;
230 
241  int mergeEmission(int emitter, int id, map<int,int>& remap);
242 
247  int externalId(int id) const;
248 
253  int diagramId(int id) const;
254 
255 public:
256 
263  void persistentOutput(PersistentOStream & os) const;
264 
270  void persistentInput(PersistentIStream & is, int version);
272 
273 private:
274 
279 
284 
288  int nextOrig;
289 
294 
298  vector<int> theParents;
299 
300 private:
301 
306 
311 
312 };
313 
314 }
315 
316 namespace ThePEG {
317 
324 template <>
325 struct BaseClassTrait<Tree2toNDiagram,1>: public ClassTraitsType {
327  typedef DiagramBase NthBase;
328 };
329 
334 template <>
335 struct ClassTraits<Tree2toNDiagram>: public ClassTraitsBase<Tree2toNDiagram> {
337  static string className() { return "ThePEG::Tree2toNDiagram"; }
338 };
339 
342 }
343 
344 #endif /* ThePEG_Tree2toNDiagram_H */