herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
MatrixElement
Matchbox
Utility
Tree2toNGenerator.h
1
// -*- C++ -*-
2
//
3
// Tree2toNGenerator.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_Tree2toNGenerator_H
10
#define Herwig_Tree2toNGenerator_H
11
//
12
// This is the declaration of the Tree2toNGenerator class.
13
//
14
15
#include "ThePEG/Handlers/HandlerBase.h"
16
#include "ThePEG/Helicity/Vertex/VertexBase.h"
17
#include "ThePEG/MatrixElement/Tree2toNDiagram.h"
18
19
#include "ThePEG/Persistency/PersistentOStream.h"
20
#include "ThePEG/Persistency/PersistentIStream.h"
21
22
namespace
Herwig
{
23
24
using namespace
ThePEG
;
25
35
class
Tree2toNGenerator
:
public
HandlerBase
{
36
37
public
:
38
42
Tree2toNGenerator
();
43
44
public
:
45
49
vector<Ptr<Tree2toNDiagram>::ptr>
generate
(
const
PDVector
&,
50
unsigned
int
orderInGs,
51
unsigned
int
orderInGem);
52
53
typedef
vector<Ptr<Helicity::VertexBase>::ptr> VertexVector;
54
58
VertexVector&
vertices
() {
return
theVertices
; }
59
63
const
VertexVector&
vertices
()
const
{
return
theVertices
; }
64
68
PDVector
&
excludeInternal
() {
return
theExcludeInternal
; }
69
73
const
PDVector
&
excludeInternal
()
const
{
return
theExcludeInternal
; }
74
75
public
:
76
83
void
persistentOutput
(
PersistentOStream
& os)
const
;
84
90
void
persistentInput
(
PersistentIStream
& is,
int
version);
92
99
static
void
Init
();
100
101
public
:
102
106
struct
Vertex
{
107
113
vector<Vertex>
children
;
114
118
PDPtr
parent
;
119
123
bool
spacelike
;
124
128
int
externalId
;
129
133
int
parentId
;
134
138
Vertex
()
139
:
spacelike
(false),
externalId
(-1),
parentId
(-1) {}
140
144
void
print
(ostream& os,
const
string
& prefix =
""
)
const
{
145
os << prefix <<
parent
->PDGName()
146
<<
"["
<< (
spacelike
?
"s"
:
"t"
) <<
"] ("
;
147
if
(
externalId
< 0 )
148
os <<
"x)\n"
;
149
else
150
os <<
externalId
<<
")\n"
;
151
if
( !
children
.empty() ) {
152
os << prefix <<
"|__\n"
;
153
children
[0].print(os,prefix +
"| "
);
154
os << prefix <<
"|__\n"
;
155
children
[1].print(os,prefix +
"| "
);
156
}
157
}
158
162
int
nspace
()
const
{
163
if
(
children
.empty() )
164
return
1;
165
int
ret = 1;
166
ret +=
children
[0].nspace();
167
return
ret;
168
}
169
174
void
update
(
Tree2toNDiagram
& diag,
175
map<
int
,pair<int,PDPtr> >&
outgoing
,
176
int
& lastUsed) {
177
if
(
externalId
== 0 ) {
178
assert(lastUsed==0);
179
++lastUsed;
180
diag.operator,(
parent
);
181
children
[0].parentId = lastUsed;
182
children
[1].parentId = lastUsed;
183
children
[0].update(diag,
outgoing
,lastUsed);
184
children
[1].update(diag,
outgoing
,lastUsed);
185
for
( map<
int
,pair<int,PDPtr> >::iterator out =
186
outgoing
.begin(); out !=
outgoing
.end(); ++out ) {
187
diag.operator,(out->second.first);
188
diag.operator,(out->second.second);
189
}
190
return
;
191
}
192
if
(
spacelike
) {
193
++lastUsed;
194
diag.operator,(
parent
);
195
if
(
externalId
== 1 )
196
return
;
197
children
[0].parentId = lastUsed;
198
children
[1].parentId = lastUsed;
199
children
[0].update(diag,
outgoing
,lastUsed);
200
children
[1].update(diag,
outgoing
,lastUsed);
201
return
;
202
}
203
if
(
children
.empty() ) {
204
outgoing
[
externalId
] =
205
make_pair(
parentId
,
parent
);
206
return
;
207
}
208
diag.operator,(
parentId
);
209
diag.operator,(
parent
);
210
++lastUsed;
211
children
[0].parentId = lastUsed;
212
children
[1].parentId = lastUsed;
213
children
[0].update(diag,
outgoing
,lastUsed);
214
children
[1].update(diag,
outgoing
,lastUsed);
215
}
216
220
Tree2toNDiagram
generate
(
int
id
) {
221
int
nsp =
nspace
();
222
Tree2toNDiagram
res(nsp);
223
int
diagid = 0;
224
map<int,pair<int,PDPtr> > out;
225
update
(res,out,diagid);
226
res.operator,(-id);
227
return
res;
228
}
229
230
};
231
235
list<vector<Vertex> >
cluster
(
const
vector<Vertex>& children,
236
unsigned
int
orderInGs,
237
unsigned
int
orderInGem)
const
;
238
242
list<vector<Vertex> >
clusterAll
(
const
list<vector<Vertex> >& current,
243
unsigned
int
orderInGs,
244
unsigned
int
orderInGem)
const
;
245
249
list<vector<Vertex> >
clusterAll
(
const
PDVector
& external,
250
unsigned
int
orderInGs,
251
unsigned
int
orderInGem);
252
256
struct
LineMatcher
{
257
261
set<tcPDPtr>
particles
;
262
266
pair<int,int>
range
;
267
271
int
count
;
272
276
LineMatcher
()
277
:
range
(0,0),
count
(0) {}
278
282
LineMatcher
(
const
PDVector
& p,
283
const
pair<int,int>& r)
284
:
range
(r),
count
(0) {
285
copy(p.begin(),p.end(),
inserter
(
particles
,
particles
.begin()));
286
}
287
291
void
rebind
(
Tree2toNGenerator
* g) {
292
set<tcPDPtr> oldp =
particles
;
293
particles
.clear();
294
for
( set<tcPDPtr>::const_iterator p = oldp.begin();
295
p != oldp.end(); ++p )
296
particles
.insert(g->getParticleData((**p).id()));
297
}
298
302
void
reset
() {
303
count
= 0;
304
}
305
309
void
add
(
tcPDPtr
p,
int
n) {
310
if
(
particles
.find(p) ==
particles
.end() )
311
return
;
312
count
+= n;
313
}
314
318
bool
check
()
const
{
319
return
320
count
>=
range
.first &&
count
<=
range
.second;
321
}
322
323
};
324
325
protected
:
326
333
virtual
IBPtr
clone
()
const
;
334
339
virtual
IBPtr
fullclone
()
const
;
341
342
343
// If needed, insert declarations of virtual function defined in the
344
// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
345
346
private
:
347
351
VertexVector
theVertices
;
352
356
PDVector
theExcludeInternal
;
357
361
unsigned
int
maxOrderGs
;
362
366
unsigned
int
maxOrderGem
;
367
371
bool
prepared
;
372
376
VertexVector
theExcludeVertices
;
377
381
vector<LineMatcher>
spaceLikeAllowed
;
382
386
vector<LineMatcher>
timeLikeAllowed
;
387
391
PDVector
theRestrictLines
;
392
396
string
doSpaceLikeRange
(
string
);
397
401
string
doTimeLikeRange
(
string
);
402
406
string
doClearRestrictLines
(
string
);
407
408
private
:
409
414
Tree2toNGenerator
&
operator=
(
const
Tree2toNGenerator
&) =
delete
;
415
416
};
417
418
inline
PersistentOStream
&
operator<<
(
PersistentOStream
& os,
const
Tree2toNGenerator::LineMatcher
& m) {
419
os << m.
particles
<< m.
range
<< m.
count
;
420
return
os;
421
}
422
423
inline
PersistentIStream
&
operator>>
(
PersistentIStream
& is, Tree2toNGenerator::LineMatcher& m) {
424
is >> m.particles >> m.range >> m.count;
425
return
is;
426
}
427
428
}
429
430
#endif
/* Herwig_Tree2toNGenerator_H */
Herwig::Tree2toNGenerator
Generate Tree2toNDiagrams for a given process.
Definition:
Tree2toNGenerator.h:35
Herwig::Tree2toNGenerator::prepared
bool prepared
Wether or not the generator has been prepared.
Definition:
Tree2toNGenerator.h:371
Herwig::Tree2toNGenerator::doSpaceLikeRange
string doSpaceLikeRange(string)
Command to set an allowed range of spacelike internal lines.
Herwig::Tree2toNGenerator::theExcludeInternal
PDVector theExcludeInternal
The particles to be excluded from internal lines.
Definition:
Tree2toNGenerator.h:356
Herwig::Tree2toNGenerator::spaceLikeAllowed
vector< LineMatcher > spaceLikeAllowed
Minimal and maximal occurences of spacelike internal lines.
Definition:
Tree2toNGenerator.h:381
Herwig::Tree2toNGenerator::vertices
const VertexVector & vertices() const
Return the vertices.
Definition:
Tree2toNGenerator.h:63
Herwig::Tree2toNGenerator::doTimeLikeRange
string doTimeLikeRange(string)
Command to set an allowed range of timelike internal lines.
Herwig::Tree2toNGenerator::timeLikeAllowed
vector< LineMatcher > timeLikeAllowed
Minimal and maximal occurences of timelike internal lines.
Definition:
Tree2toNGenerator.h:386
Herwig::Tree2toNGenerator::fullclone
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
Herwig::Tree2toNGenerator::theRestrictLines
PDVector theRestrictLines
The next particle for which internal lines need to be restricted.
Definition:
Tree2toNGenerator.h:391
Herwig::Tree2toNGenerator::cluster
list< vector< Vertex > > cluster(const vector< Vertex > &children, unsigned int orderInGs, unsigned int orderInGem) const
For the given set of trees determine all allowed clusterings.
Herwig::Tree2toNGenerator::clusterAll
list< vector< Vertex > > clusterAll(const list< vector< Vertex > > ¤t, unsigned int orderInGs, unsigned int orderInGem) const
For the given set of outgoing lines cluster recursively.
Herwig::Tree2toNGenerator::clone
virtual IBPtr clone() const
Make a simple clone of this object.
Herwig::Tree2toNGenerator::generate
vector< Ptr< Tree2toNDiagram >::ptr > generate(const PDVector &, unsigned int orderInGs, unsigned int orderInGem)
Generate all diagrams for the given process.
Herwig::Tree2toNGenerator::maxOrderGem
unsigned int maxOrderGem
Maximum order in gem to consider.
Definition:
Tree2toNGenerator.h:366
Herwig::Tree2toNGenerator::theVertices
VertexVector theVertices
The vertices to be used.
Definition:
Tree2toNGenerator.h:351
Herwig::Tree2toNGenerator::theExcludeVertices
VertexVector theExcludeVertices
The vertices to be excluded.
Definition:
Tree2toNGenerator.h:376
Herwig::Tree2toNGenerator::Tree2toNGenerator
Tree2toNGenerator()
The default constructor.
Herwig::Tree2toNGenerator::vertices
VertexVector & vertices()
Access the vertices.
Definition:
Tree2toNGenerator.h:58
Herwig::Tree2toNGenerator::maxOrderGs
unsigned int maxOrderGs
Maximum order in gs to consider.
Definition:
Tree2toNGenerator.h:361
Herwig::Tree2toNGenerator::persistentOutput
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
Herwig::Tree2toNGenerator::Init
static void Init()
The standard Init function used to initialize the interfaces.
Herwig::Tree2toNGenerator::excludeInternal
const PDVector & excludeInternal() const
Return the particles to be excluded from internal lines.
Definition:
Tree2toNGenerator.h:73
Herwig::Tree2toNGenerator::clusterAll
list< vector< Vertex > > clusterAll(const PDVector &external, unsigned int orderInGs, unsigned int orderInGem)
For the given set of outgoing lines cluster recursively.
Herwig::Tree2toNGenerator::doClearRestrictLines
string doClearRestrictLines(string)
Command to clear the restrict lines container.
Herwig::Tree2toNGenerator::excludeInternal
PDVector & excludeInternal()
Access the particles to be excluded from internal lines.
Definition:
Tree2toNGenerator.h:68
Herwig::Tree2toNGenerator::persistentInput
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
Herwig::Tree2toNGenerator::operator=
Tree2toNGenerator & operator=(const Tree2toNGenerator &)=delete
The assignment operator is private and must never be called.
ThePEG::HandlerBase
ThePEG::InterfacedBase::update
void update()
ThePEG::PersistentIStream
ThePEG::PersistentOStream
ThePEG::Tree2toNDiagram
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
ThePEG::Helicity::outgoing
outgoing
ThePEG
ThePEG::operator>>
PersistentIStream & operator>>(PersistentIStream &is, HandlerGroup< HDLR > &hg)
ThePEG::PDVector
vector< PDPtr > PDVector
ThePEG::IBPtr
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
ThePEG::tcPDPtr
ThePEG::Ptr< ParticleData >::transient_const_pointer tcPDPtr
ThePEG::PDPtr
ThePEG::Ptr< ParticleData >::pointer PDPtr
ThePEG::operator<<
ostream & operator<<(ostream &, const Collision &)
ThePEG::inserter
std::insert_iterator< Cont > inserter(Cont &c)
Herwig::Tree2toNGenerator::LineMatcher
Helper for topology restrictions.
Definition:
Tree2toNGenerator.h:256
Herwig::Tree2toNGenerator::LineMatcher::add
void add(tcPDPtr p, int n)
Count the given multiplicity.
Definition:
Tree2toNGenerator.h:309
Herwig::Tree2toNGenerator::LineMatcher::LineMatcher
LineMatcher(const PDVector &p, const pair< int, int > &r)
Construct given particles and a range.
Definition:
Tree2toNGenerator.h:282
Herwig::Tree2toNGenerator::LineMatcher::LineMatcher
LineMatcher()
Default constructor.
Definition:
Tree2toNGenerator.h:276
Herwig::Tree2toNGenerator::LineMatcher::range
pair< int, int > range
The range allowed.
Definition:
Tree2toNGenerator.h:266
Herwig::Tree2toNGenerator::LineMatcher::count
int count
The current count.
Definition:
Tree2toNGenerator.h:271
Herwig::Tree2toNGenerator::LineMatcher::particles
set< tcPDPtr > particles
The group of lines to be considered.
Definition:
Tree2toNGenerator.h:261
Herwig::Tree2toNGenerator::LineMatcher::check
bool check() const
Ceck if restrictions are met.
Definition:
Tree2toNGenerator.h:318
Herwig::Tree2toNGenerator::LineMatcher::rebind
void rebind(Tree2toNGenerator *g)
Rebind the particle data pointers.
Definition:
Tree2toNGenerator.h:291
Herwig::Tree2toNGenerator::LineMatcher::reset
void reset()
Reset this matcher.
Definition:
Tree2toNGenerator.h:302
Herwig::Tree2toNGenerator::Vertex
A node in internally used trees.
Definition:
Tree2toNGenerator.h:106
Herwig::Tree2toNGenerator::Vertex::parent
PDPtr parent
The incoming line at this node.
Definition:
Tree2toNGenerator.h:118
Herwig::Tree2toNGenerator::Vertex::print
void print(ostream &os, const string &prefix="") const
Debug printout.
Definition:
Tree2toNGenerator.h:144
Herwig::Tree2toNGenerator::Vertex::update
void update(Tree2toNDiagram &diag, map< int, pair< int, PDPtr > > &outgoing, int &lastUsed)
Update diagram returning a map of external ids to diagram id parents.
Definition:
Tree2toNGenerator.h:174
Herwig::Tree2toNGenerator::Vertex::Vertex
Vertex()
The default constructor.
Definition:
Tree2toNGenerator.h:138
Herwig::Tree2toNGenerator::Vertex::children
vector< Vertex > children
The outgoing particles.
Definition:
Tree2toNGenerator.h:113
Herwig::Tree2toNGenerator::Vertex::generate
Tree2toNDiagram generate(int id)
Generate a diagram of given id.
Definition:
Tree2toNGenerator.h:220
Herwig::Tree2toNGenerator::Vertex::nspace
int nspace() const
Count the number of spacelike lines.
Definition:
Tree2toNGenerator.h:162
Herwig::Tree2toNGenerator::Vertex::externalId
int externalId
The external leg id.
Definition:
Tree2toNGenerator.h:128
Herwig::Tree2toNGenerator::Vertex::parentId
int parentId
The parent diagram id.
Definition:
Tree2toNGenerator.h:133
Herwig::Tree2toNGenerator::Vertex::spacelike
bool spacelike
True, if this is spacelike node.
Definition:
Tree2toNGenerator.h:123
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6