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