herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
HPDiagram.h
1 // -*- C++ -*-
2 //
3 // HPDiagram.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_HPDiagram_H
10 #define HERWIG_HPDiagram_H
11 //
12 // This is the declaration of the HPDiagram struct.
13 //
14 
15 #include "ThePEG/Persistency/PersistentOStream.h"
16 #include "ThePEG/Persistency/PersistentIStream.h"
17 #include "ThePEG/Helicity/Vertex/VertexBase.h"
18 
19 namespace Herwig {
20 using namespace ThePEG;
21 using Helicity::VertexBasePtr;
22 
24  typedef pair<long, long> IDPair;
25 
27  typedef pair<bool, bool> BPair;
28 
30  typedef VertexBasePtr VBPtr;
31 
33  typedef pair<VBPtr, VBPtr> VBPair;
34 
36  typedef pair<unsigned int, double> CFPair;
37 
42 struct HPDiagram {
43 
45  enum Channel {UNDEFINED = -1, sChannel, tChannel, fourPoint};
46 
48  HPDiagram() : incoming(make_pair(0, 0)), outgoing(make_pair(0, 0)),
49  ordered(make_pair(true,true)), channelType(UNDEFINED),
50  colourFlow(0), ids(4, 0) {}
51 
53  HPDiagram(IDPair a, IDPair b)
54  : incoming(a), outgoing(b), ordered(make_pair(true,true)),
55  channelType(UNDEFINED), colourFlow(0), ids(4, 0){
56  ids[0] = incoming.first;
57  ids[1] = incoming.second;
58  ids[2] = outgoing.first;
59  ids[3] = outgoing.second;
60  }
61 
63  IDPair incoming;
64 
66  IDPair outgoing;
67 
69  BPair ordered;
70 
73 
75  VBPair vertices;
76 
79 
81  vector<CFPair> colourFlow;
82 
84  vector<long> ids;
85 
90  bool sameProcess(const HPDiagram & x) const {
91  return ( x.incoming == incoming && x.outgoing == outgoing );
92  }
93 };
94 
98  inline bool operator==(const HPDiagram & x, const HPDiagram & y) {
99  // check incoming
100  if( x.incoming != y.incoming) return false;
101  // check type of diagram
102  if( x.channelType != y.channelType ) return false;
103  if( x.outgoing == y.outgoing &&
104  x.ordered == y.ordered ) {
105  // 4 point
106  if(x.channelType==HPDiagram::fourPoint) {
107  // check vertex
108  return x.vertices.first==y.vertices.first;
109  }
110  // all others
111  else {
112  // check vertex
113  if(x.vertices.first != y.vertices.first ||
114  x.vertices.second != y.vertices.second )
115  return false;
116  // check intermediate
117  return x.intermediate == y.intermediate;
118  }
119  }
120  //diagram is also the same if the outgoing particles are
121  //swapped and the ordering is opposite
122  else if( x.outgoing.first != x.outgoing.second &&
123  y.outgoing.first != y.outgoing.second &&
124  x.outgoing.first == y.outgoing.second &&
125  x.outgoing.second == y.outgoing.first &&
126  x.channelType == y.channelType) {
127  // 4 point
128  if(x.channelType==HPDiagram::fourPoint) {
129  // check vertex
130  return x.vertices.first==y.vertices.first;
131  }
132  // t/u channel
133  else if(x.channelType==HPDiagram::tChannel) {
134  // check vertex and intermediate
135  if(x.vertices.first == y.vertices.first &&
136  x.vertices.second == y.vertices.second &&
137  x.intermediate == y.intermediate )
138  return true;
139  tPDPtr inter = x.intermediate;
140  if(inter->CC()) inter = inter->CC();
141  if(x.vertices.first == y.vertices.second &&
142  x.vertices.second == y.vertices.first &&
143  inter == y.intermediate )
144  return true;
145  }
146  // s-channel
147  else {
148  // check vertex
149  if(x.vertices.first != y.vertices.first ||
150  x.vertices.second != y.vertices.second )
151  return false;
152  // check intermediate
153  return x.intermediate == y.intermediate;
154  }
155  }
156  return false;
157  }
158 
163  inline bool operator<(const HPDiagram & x, const HPDiagram & y) {
164  for( size_t i = 0; i < 4; ++i ) {
165  if( x.ids[i] < y.ids[i] )
166  return true;
167  else if( x.ids[i] > y.ids[i] )
168  return false;
169  }
170  return false;
171  }
172 
176  inline ostream & operator<<(ostream & os, const HPDiagram & diag) {
177  os << diag.incoming.first << " " << diag.incoming.second << " -> ";
178  if(diag.intermediate)
179  os << diag.intermediate->id() << " -> ";
180  os << diag.outgoing.first << " " << diag.outgoing.second
181  << " channel: " << diag.channelType << " ";
182  if(diag.channelType == HPDiagram::tChannel)
183  os << "ordering " << diag.ordered.first << " "
184  << diag.ordered.second << " ";
185  for(size_t cf = 0; cf < diag.colourFlow.size(); ++cf)
186  os << "(" << diag.colourFlow[cf].first << ","
187  <<diag.colourFlow[cf].second << ")";
188  os << '\n';
189  return os;
190  }
191 
198  const HPDiagram & x) {
199  os << x.incoming << x.outgoing << x.ordered << x.intermediate
200  << x.vertices << x.channelType << x.colourFlow << x.ids;
201  return os;
202  }
203 
210  HPDiagram & x) {
211  int chan = -1;
212  is >> x.incoming >> x.outgoing >> x.ordered >> x.intermediate
213  >> x.vertices >> chan >> x.colourFlow >> x.ids;
215  return is;
216  }
217 }
218 
219 #endif /* HERWIG_HPDiagram_H */
vector< CFPair > colourFlow
Store colour flow information.
Definition: HPDiagram.h:81
IDPair outgoing
Outgoing particle id&#39;s.
Definition: HPDiagram.h:66
ThePEG::Ptr< ParticleData >::transient_pointer tPDPtr
bool operator==(const HPDiagram &x, const HPDiagram &y)
Test whether two diagrams are identical.
Definition: HPDiagram.h:98
VBPair vertices
The two vertices for the diagram.
Definition: HPDiagram.h:75
pair< long, long > IDPair
Pair of particle ids.
Definition: HPDiagram.h:24
bool operator<(const HPDiagram &x, const HPDiagram &y)
Test whether one diagram is &#39;less&#39; than another.
Definition: HPDiagram.h:163
ostream & operator<<(ostream &, const DecayIntegrator &)
Output information on the DecayIntegrator for debugging purposes.
pair< VBPtr, VBPtr > VBPair
Pair of VertexBasePtrs.
Definition: HPDiagram.h:33
pair< unsigned int, double > CFPair
Pair of int,double.
Definition: HPDiagram.h:36
IDPair incoming
Incoming particle id&#39;s.
Definition: HPDiagram.h:63
BPair ordered
Particle ordering for t-channel diagrams.
Definition: HPDiagram.h:69
PersistentIStream & operator>>(PersistentIStream &is, map< ShowerInteraction, T, Cmp, A > &m)
Read a map with ShowerInteraction as the key.
HPDiagram(IDPair a, IDPair b)
Constructor taking ids as arguments.
Definition: HPDiagram.h:53
ThePEG::Ptr< ParticleData >::pointer PDPtr
VertexBasePtr VBPtr
Convenient typedef of VertexBasePtr.
Definition: HPDiagram.h:30
vector< long > ids
Store the ids in a vector for easy use of comparison operator.
Definition: HPDiagram.h:84
HPDiagram()
Standard Constructor.
Definition: HPDiagram.h:48
Channel channelType
Enum of channel type.
Definition: HPDiagram.h:78
pair< bool, bool > BPair
Pair of bool&#39;s.
Definition: HPDiagram.h:27
-*- C++ -*-
The HPDiagram struct contains information about a 2->2 hard-process that has been automatically gener...
Definition: HPDiagram.h:42
Channel
Enumeration for channel type.
Definition: HPDiagram.h:45
bool sameProcess(const HPDiagram &x) const
Test whether this and x are the same process.
Definition: HPDiagram.h:90
PDPtr intermediate
ParticleData pointer to intermediate, null for 4-point vertices.
Definition: HPDiagram.h:72