File indexing completed on 2026-08-06 09:24:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef HERWIG_TBDiagram_H
0010 #define HERWIG_TBDiagram_H
0011
0012
0013
0014
0015 #include "ThePEG/Persistency/PersistentOStream.h"
0016 #include "ThePEG/Persistency/PersistentIStream.h"
0017 #include "ThePEG/Helicity/Vertex/VertexBase.h"
0018 #include "ThePEG/Utilities/EnumIO.h"
0019 #include "PrototypeVertex.h"
0020
0021 namespace Herwig {
0022 using namespace ThePEG;
0023 using Helicity::VertexBasePtr;
0024
0025
0026 typedef pair<long, long> IDPair;
0027
0028
0029 typedef pair<bool, bool> BPair;
0030
0031
0032 typedef VertexBasePtr VBPtr;
0033
0034
0035 typedef pair<VBPtr, VBPtr> VBPair;
0036
0037
0038 typedef pair<unsigned int, double> CFPair;
0039
0040
0041
0042
0043
0044 struct TBDiagram {
0045
0046
0047 enum Channel {UNDEFINED = -1, channel23=0, channel13=1, channel12=2, fourPoint=3};
0048
0049
0050 TBDiagram()
0051 : incoming(0), outgoing(0), outgoingPair(make_pair(0, 0)),
0052 channelType(UNDEFINED), colourFlow(0), ids(4, 0)
0053 {}
0054
0055
0056 TBDiagram(long a, long b, IDPair c)
0057 : incoming(a), outgoing(b), outgoingPair(c),
0058 channelType(UNDEFINED), colourFlow(0), ids(4, 0) {
0059 ids[0] = a;
0060 ids[1] = b;
0061 ids[2] = c.first;
0062 ids[3] = c.second;
0063 }
0064
0065
0066 long incoming;
0067
0068
0069 long outgoing;
0070
0071
0072 IDPair outgoingPair;
0073
0074
0075 PDPtr intermediate;
0076
0077
0078 VBPair vertices;
0079
0080
0081 Channel channelType;
0082
0083
0084 mutable vector<CFPair> colourFlow;
0085
0086
0087 mutable vector<CFPair> largeNcColourFlow;
0088
0089
0090 vector<long> ids;
0091
0092
0093
0094
0095
0096 bool sameDecay(const TBDiagram & x) const {
0097 if(ids[0] != x.ids[0]) return false;
0098 bool used[4]={false,false,false,false};
0099 for(unsigned int ix=1;ix<4;++ix) {
0100 bool found=false;
0101 for(unsigned int iy=1;iy<4;++iy) {
0102 if(used[iy]) continue;
0103 if(ids[ix]==x.ids[iy]) {
0104 used[iy]=true;
0105 found=true;
0106 break;
0107 }
0108 }
0109 if(!found) return false;
0110 }
0111 return true;
0112 }
0113
0114
0115 TBDiagram(const NBDiagram & diagram)
0116 : channelType(UNDEFINED),
0117 colourFlow (diagram.colourFlow),
0118 largeNcColourFlow(diagram.largeNcColourFlow), ids(4,0) {
0119 incoming = diagram.incoming->id();
0120 if(diagram.vertices.size()==2) {
0121 const NBVertex & child = (++diagram.vertices.begin())->second;
0122 outgoing = diagram.vertices.begin()->first->id();
0123 unsigned int iloc=0;
0124 for(OrderedParticles::const_iterator it = child.outgoing.begin();
0125 it!=child.outgoing.end();++it) {
0126 if (iloc==0) outgoingPair.first = (**it).id();
0127 else if (iloc==1) outgoingPair.second = (**it).id();
0128 ++iloc;
0129 }
0130 intermediate = child.incoming;
0131 vertices.second = child.vertex;
0132 }
0133 else {
0134 unsigned int iloc=0;
0135 for(OrderedParticles::const_iterator it = diagram.outgoing.begin();
0136 it!=diagram.outgoing.end();++it) {
0137 if(iloc==0) outgoing = (**it).id();
0138 else if (iloc==1) outgoingPair.first = (**it).id();
0139 else if (iloc==2) outgoingPair.second = (**it).id();
0140 ++iloc;
0141 }
0142 }
0143 vertices.first = diagram.vertex;
0144 ids[0] = incoming;
0145 ids[1] = outgoing;
0146 ids[2] = outgoingPair.first;
0147 ids[3] = outgoingPair.second;
0148 }
0149
0150 };
0151
0152
0153
0154
0155 inline bool operator==(const TBDiagram & x, const TBDiagram & y) {
0156 if( x.incoming != y.incoming) return false;
0157 if( x.outgoing != y.outgoing) return false;
0158 if( x.intermediate != y.intermediate) return false;
0159 if( x.vertices != y.vertices ) return false;
0160 if( (x.outgoingPair.first == y.outgoingPair.first &&
0161 x.outgoingPair.second == y.outgoingPair.second ) ||
0162 (x.outgoingPair.first == y.outgoingPair.second &&
0163 x.outgoingPair.second == y.outgoingPair.first ) ) return true;
0164 else return false;
0165 }
0166
0167
0168
0169
0170 inline ostream & operator<<(ostream & os, const TBDiagram & diag) {
0171 os << diag.incoming << " -> ";
0172 os << diag.outgoing << " + ( ";
0173 if(diag.intermediate) os << diag.intermediate->id();
0174 os << " ) -> ";
0175 os << diag.outgoingPair.first << " " << diag.outgoingPair.second
0176 << " channel: " << diag.channelType << " ";
0177 for(size_t cf = 0; cf < diag.colourFlow.size(); ++cf)
0178 os << "(" << diag.colourFlow[cf].first << ","
0179 <<diag.colourFlow[cf].second << ")";
0180 os << '\n';
0181 return os;
0182 }
0183
0184
0185
0186
0187
0188
0189 inline PersistentOStream & operator<<(PersistentOStream & os,
0190 const TBDiagram & x) {
0191 os << x.incoming << x.outgoing << x.outgoingPair << x.intermediate
0192 << x.vertices << oenum(x.channelType) << x.colourFlow
0193 << x.largeNcColourFlow << x.ids;
0194 return os;
0195 }
0196
0197
0198
0199
0200
0201
0202 inline PersistentIStream & operator>>(PersistentIStream & is,
0203 TBDiagram & x) {
0204 is >> x.incoming >> x.outgoing >> x.outgoingPair >> x.intermediate
0205 >> x.vertices >> ienum(x.channelType) >> x.colourFlow
0206 >> x.largeNcColourFlow >> x.ids;
0207 return is;
0208 }
0209
0210 }
0211
0212 #endif