herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
TBDiagram.h
1 // -*- C++ -*-
2 //
3 // TBDiagram.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4 // Copyright (C) 2002-2019 The Herwig Collaboration
5 //
6 // Herwig 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 HERWIG_TBDiagram_H
10 #define HERWIG_TBDiagram_H
11 //
12 // This is the declaration of the TBDiagram struct.
13 //
14 
15 #include "ThePEG/Persistency/PersistentOStream.h"
16 #include "ThePEG/Persistency/PersistentIStream.h"
17 #include "ThePEG/Helicity/Vertex/VertexBase.h"
18 #include "ThePEG/Utilities/EnumIO.h"
19 #include "PrototypeVertex.h"
20 
21 namespace Herwig {
22 using namespace ThePEG;
23 using Helicity::VertexBasePtr;
24 
26 typedef pair<long, long> IDPair;
27 
29 typedef pair<bool, bool> BPair;
30 
32 typedef VertexBasePtr VBPtr;
33 
35 typedef pair<VBPtr, VBPtr> VBPair;
36 
38 typedef pair<unsigned int, double> CFPair;
39 
44 struct TBDiagram {
45 
47  enum Channel {UNDEFINED = -1, channel23=0, channel13=1, channel12=2, fourPoint=3};
48 
51  : incoming(0), outgoing(0), outgoingPair(make_pair(0, 0)),
52  channelType(UNDEFINED), colourFlow(0), ids(4, 0)
53  {}
54 
56  TBDiagram(long a, long b, IDPair c)
57  : incoming(a), outgoing(b), outgoingPair(c),
58  channelType(UNDEFINED), colourFlow(0), ids(4, 0) {
59  ids[0] = a;
60  ids[1] = b;
61  ids[2] = c.first;
62  ids[3] = c.second;
63  }
64 
66  long incoming;
67 
69  long outgoing;
70 
72  IDPair outgoingPair;
73 
76 
78  VBPair vertices;
79 
82 
84  mutable vector<CFPair> colourFlow;
85 
87  mutable vector<CFPair> largeNcColourFlow;
88 
90  vector<long> ids;
91 
96  bool sameDecay(const TBDiagram & x) const {
97  if(ids[0] != x.ids[0]) return false;
98  bool used[4]={false,false,false,false};
99  for(unsigned int ix=1;ix<4;++ix) {
100  bool found=false;
101  for(unsigned int iy=1;iy<4;++iy) {
102  if(used[iy]) continue;
103  if(ids[ix]==x.ids[iy]) {
104  used[iy]=true;
105  found=true;
106  break;
107  }
108  }
109  if(!found) return false;
110  }
111  return true;
112  }
113 
115  TBDiagram(const NBDiagram & diagram)
116  : channelType(UNDEFINED),
117  colourFlow (diagram.colourFlow),
118  largeNcColourFlow(diagram.largeNcColourFlow), ids(4,0) {
119  incoming = diagram.incoming->id();
120  if(diagram.vertices.size()==2) {
121  const NBVertex & child = (++diagram.vertices.begin())->second;
122  outgoing = diagram.vertices.begin()->first->id();
123  unsigned int iloc=0;
124  for(OrderedParticles::const_iterator it = child.outgoing.begin();
125  it!=child.outgoing.end();++it) {
126  if (iloc==0) outgoingPair.first = (**it).id();
127  else if (iloc==1) outgoingPair.second = (**it).id();
128  ++iloc;
129  }
130  intermediate = child.incoming;
131  vertices.second = child.vertex;
132  }
133  else {
134  unsigned int iloc=0;
135  for(OrderedParticles::const_iterator it = diagram.outgoing.begin();
136  it!=diagram.outgoing.end();++it) {
137  if(iloc==0) outgoing = (**it).id();
138  else if (iloc==1) outgoingPair.first = (**it).id();
139  else if (iloc==2) outgoingPair.second = (**it).id();
140  ++iloc;
141  }
142  }
143  vertices.first = diagram.vertex;
144  ids[0] = incoming;
145  ids[1] = outgoing;
146  ids[2] = outgoingPair.first;
147  ids[3] = outgoingPair.second;
148  }
149 
150 };
151 
155 inline bool operator==(const TBDiagram & x, const TBDiagram & y) {
156  if( x.incoming != y.incoming) return false;
157  if( x.outgoing != y.outgoing) return false;
158  if( x.intermediate != y.intermediate) return false;
159  if( x.vertices != y.vertices ) return false;
160  if( (x.outgoingPair.first == y.outgoingPair.first &&
161  x.outgoingPair.second == y.outgoingPair.second ) ||
162  (x.outgoingPair.first == y.outgoingPair.second &&
163  x.outgoingPair.second == y.outgoingPair.first ) ) return true;
164  else return false;
165 }
166 
170 inline ostream & operator<<(ostream & os, const TBDiagram & diag) {
171  os << diag.incoming << " -> ";
172  os << diag.outgoing << " + ( ";
173  if(diag.intermediate) os << diag.intermediate->id();
174  os << " ) -> ";
175  os << diag.outgoingPair.first << " " << diag.outgoingPair.second
176  << " channel: " << diag.channelType << " ";
177  for(size_t cf = 0; cf < diag.colourFlow.size(); ++cf)
178  os << "(" << diag.colourFlow[cf].first << ","
179  <<diag.colourFlow[cf].second << ")";
180  os << '\n';
181  return os;
182 }
183 
190  const TBDiagram & x) {
191  os << x.incoming << x.outgoing << x.outgoingPair << x.intermediate
192  << x.vertices << oenum(x.channelType) << x.colourFlow
193  << x.largeNcColourFlow << x.ids;
194  return os;
195 }
196 
203  TBDiagram & x) {
204  is >> x.incoming >> x.outgoing >> x.outgoingPair >> x.intermediate
205  >> x.vertices >> ienum(x.channelType) >> x.colourFlow
206  >> x.largeNcColourFlow >> x.ids;
207  return is;
208 }
209 
210 }
211 
212 #endif /* HERWIG_TBDiagram_H */
PDPtr intermediate
ParticleData pointer to intermediate, null for 4-point vertices.
Definition: TBDiagram.h:75
TBDiagram(const NBDiagram &diagram)
Constructor from NBDiagram.
Definition: TBDiagram.h:115
IEnum< T > ienum(T &t)
list< pair< PDPtr, NBVertex > > vertices
The vertices.
bool operator==(const HPDiagram &x, const HPDiagram &y)
Test whether two diagrams are identical.
Definition: HPDiagram.h:98
pair< long, long > IDPair
Pair of particle ids.
Definition: HPDiagram.h:24
bool sameDecay(const TBDiagram &x) const
Test whether this and x are the same decay.
Definition: TBDiagram.h:96
Channel channelType
Enum of channel type.
Definition: TBDiagram.h:81
vector< CFPair > largeNcColourFlow
Store colour flow at information.
Definition: TBDiagram.h:87
vector< long > ids
Store the ids in a vector for easy use of comparison operator.
Definition: TBDiagram.h:90
ostream & operator<<(ostream &, const DecayIntegrator &)
Output information on the DecayIntegrator for debugging purposes.
pair< VBPtr, VBPtr > VBPair
Pair of VertexBasePtrs.
Definition: HPDiagram.h:33
VBPair vertices
The two vertices for the diagram.
Definition: TBDiagram.h:78
pair< unsigned int, double > CFPair
Pair of int,double.
Definition: HPDiagram.h:36
long outgoing
Outgoing particle from first vertex.
Definition: TBDiagram.h:69
OEnum< T > oenum(const T &t)
A simple vertex for the N-body diagram.
vector< CFPair > colourFlow
Store colour flow at information.
Definition: TBDiagram.h:84
PersistentIStream & operator>>(PersistentIStream &is, map< ShowerInteraction, T, Cmp, A > &m)
Read a map with ShowerInteraction as the key.
The NBDiagram struct contains information about a decay that has been automatically generated...
ThePEG::Ptr< ParticleData >::pointer PDPtr
tPDPtr incoming
Incoming particle.
VertexBasePtr vertex
The vertex.
VertexBasePtr VBPtr
Convenient typedef of VertexBasePtr.
Definition: HPDiagram.h:30
The TBDiagram struct contains information about a decay that has been automatically generated by Thr...
Definition: TBDiagram.h:44
TBDiagram(long a, long b, IDPair c)
Constructor taking ids as arguments.
Definition: TBDiagram.h:56
OrderedParticles outgoing
Outgoing particles.
pair< bool, bool > BPair
Pair of bool&#39;s.
Definition: HPDiagram.h:27
IDPair outgoingPair
Outgoing particle id&#39;s fropm resonance.
Definition: TBDiagram.h:72
-*- C++ -*-
long incoming
Incoming particle id&#39;s.
Definition: TBDiagram.h:66
Channel
Enumeration for channel type.
Definition: TBDiagram.h:47
TBDiagram()
Standard Constructor.
Definition: TBDiagram.h:50