herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
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
21namespace Herwig {
22using namespace ThePEG;
23using Helicity::VertexBasePtr;
24
26typedef pair<long, long> IDPair;
27
29typedef pair<bool, bool> BPair;
30
32typedef VertexBasePtr VBPtr;
33
35typedef pair<VBPtr, VBPtr> VBPair;
36
38typedef pair<unsigned int, double> CFPair;
39
44struct 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
67
70
73
76
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),
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
155inline 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
170inline 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 */
-*- C++ -*-
pair< bool, bool > BPair
Pair of bool's.
Definition: HPDiagram.h:27
pair< unsigned int, double > CFPair
Pair of int,double.
Definition: HPDiagram.h:36
pair< long, long > IDPair
Pair of particle ids.
Definition: HPDiagram.h:24
VertexBasePtr VBPtr
Convenient typedef of VertexBasePtr.
Definition: HPDiagram.h:30
pair< VBPtr, VBPtr > VBPair
Pair of VertexBasePtrs.
Definition: HPDiagram.h:33
PersistentIStream & operator>>(PersistentIStream &is, HandlerGroup< HDLR > &hg)
bool operator==(const LorentzVector< Value > &a, const LorentzVector< Value > &b)
IEnum< T > ienum(T &t)
OEnum< T > oenum(const T &t)
ThePEG::Ptr< ParticleData >::pointer PDPtr
ostream & operator<<(ostream &, const Collision &)
The NBDiagram struct contains information about a decay that has been automatically generated.
A simple vertex for the N-body diagram.
OrderedParticles outgoing
Outgoing particles.
VertexBasePtr vertex
The vertex.
tPDPtr incoming
Incoming particle.
list< pair< PDPtr, NBVertex > > vertices
The vertices.
The TBDiagram struct contains information about a decay that has been automatically generated by Thr...
Definition: TBDiagram.h:44
TBDiagram()
Standard Constructor.
Definition: TBDiagram.h:50
bool sameDecay(const TBDiagram &x) const
Test whether this and x are the same decay.
Definition: TBDiagram.h:96
TBDiagram(const NBDiagram &diagram)
Constructor from NBDiagram.
Definition: TBDiagram.h:115
long outgoing
Outgoing particle from first vertex.
Definition: TBDiagram.h:69
IDPair outgoingPair
Outgoing particle id's fropm resonance.
Definition: TBDiagram.h:72
TBDiagram(long a, long b, IDPair c)
Constructor taking ids as arguments.
Definition: TBDiagram.h:56
Channel channelType
Enum of channel type.
Definition: TBDiagram.h:81
VBPair vertices
The two vertices for the diagram.
Definition: TBDiagram.h:78
vector< CFPair > largeNcColourFlow
Store colour flow at information.
Definition: TBDiagram.h:87
Channel
Enumeration for channel type.
Definition: TBDiagram.h:47
long incoming
Incoming particle id's.
Definition: TBDiagram.h:66
vector< long > ids
Store the ids in a vector for easy use of comparison operator.
Definition: TBDiagram.h:90
vector< CFPair > colourFlow
Store colour flow at information.
Definition: TBDiagram.h:84
PDPtr intermediate
ParticleData pointer to intermediate, null for 4-point vertices.
Definition: TBDiagram.h:75