herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.2.1
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
44
Tree2toNGenerator
();
45
49
virtual
~
Tree2toNGenerator
();
51
52
public
:
53
57
vector<Ptr<Tree2toNDiagram>::ptr>
generate
(
const
PDVector
&,
58
unsigned
int
orderInGs,
59
unsigned
int
orderInGem);
60
61
typedef
vector<Ptr<Helicity::VertexBase>::ptr> VertexVector;
62
66
VertexVector&
vertices
() {
return
theVertices; }
67
71
const
VertexVector&
vertices
()
const
{
return
theVertices; }
72
76
PDVector
&
excludeInternal
() {
return
theExcludeInternal; }
77
81
const
PDVector
&
excludeInternal
()
const
{
return
theExcludeInternal; }
82
83
public
:
84
91
void
persistentOutput(
PersistentOStream
& os)
const
;
92
98
void
persistentInput(
PersistentIStream
& is,
int
version);
100
107
static
void
Init();
108
109
public
:
110
114
struct
Vertex
{
115
121
vector<Vertex>
children
;
122
126
PDPtr
parent
;
127
131
bool
spacelike
;
132
136
int
externalId
;
137
141
int
parentId
;
142
146
Vertex
()
147
: spacelike(false), externalId(-1), parentId(-1) {}
148
152
void
print
(ostream& os,
const
string
& prefix =
""
)
const
{
153
os << prefix << parent->PDGName()
154
<<
"["
<< (spacelike ?
"s"
:
"t"
) <<
"] ("
;
155
if
( externalId < 0 )
156
os <<
"x)\n"
;
157
else
158
os << externalId <<
")\n"
;
159
if
( !children.empty() ) {
160
os << prefix <<
"|__\n"
;
161
children[0].print(os,prefix +
"| "
);
162
os << prefix <<
"|__\n"
;
163
children[1].print(os,prefix +
"| "
);
164
}
165
}
166
170
int
nspace
()
const
{
171
if
( children.empty() )
172
return
1;
173
int
ret = 1;
174
ret += children[0].nspace();
175
return
ret;
176
}
177
182
void
update
(
Tree2toNDiagram
& diag,
183
map<
int
,pair<int,PDPtr> >& outgoing,
184
int
& lastUsed) {
185
if
( externalId == 0 ) {
186
assert(lastUsed==0);
187
++lastUsed;
188
diag.operator,(parent);
189
children[0].parentId = lastUsed;
190
children[1].parentId = lastUsed;
191
children[0].update(diag,
outgoing
,lastUsed);
192
children[1].update(diag,
outgoing
,lastUsed);
193
for
( map<
int
,pair<int,PDPtr> >::iterator out =
194
outgoing
.begin(); out !=
outgoing
.end(); ++out ) {
195
diag.operator,(out->second.first);
196
diag.operator,(out->second.second);
197
}
198
return
;
199
}
200
if
( spacelike ) {
201
++lastUsed;
202
diag.operator,(parent);
203
if
( externalId == 1 )
204
return
;
205
children[0].parentId = lastUsed;
206
children[1].parentId = lastUsed;
207
children[0].update(diag,
outgoing
,lastUsed);
208
children[1].update(diag,
outgoing
,lastUsed);
209
return
;
210
}
211
if
( children.empty() ) {
212
outgoing
[externalId] =
213
make_pair(parentId,parent);
214
return
;
215
}
216
diag.operator,(parentId);
217
diag.operator,(parent);
218
++lastUsed;
219
children[0].parentId = lastUsed;
220
children[1].parentId = lastUsed;
221
children[0].update(diag,
outgoing
,lastUsed);
222
children[1].update(diag,
outgoing
,lastUsed);
223
}
224
228
Tree2toNDiagram
generate
(
int
id
) {
229
int
nsp = nspace();
230
Tree2toNDiagram
res(nsp);
231
int
diagid = 0;
232
map<int,pair<int,PDPtr> > out;
233
update(res,out,diagid);
234
res.operator,(-id);
235
return
res;
236
}
237
238
};
239
243
list<vector<Vertex> > cluster(
const
vector<Vertex>& children,
244
unsigned
int
orderInGs,
245
unsigned
int
orderInGem)
const
;
246
250
list<vector<Vertex> > clusterAll(
const
list<vector<Vertex> >& current,
251
unsigned
int
orderInGs,
252
unsigned
int
orderInGem)
const
;
253
257
list<vector<Vertex> > clusterAll(
const
PDVector
& external,
258
unsigned
int
orderInGs,
259
unsigned
int
orderInGem);
260
264
struct
LineMatcher
{
265
269
set<tcPDPtr>
particles
;
270
274
pair<int,int>
range
;
275
279
int
count
;
280
284
LineMatcher
()
285
: range(0,0), count(0) {}
286
290
LineMatcher
(
const
PDVector
& p,
291
const
pair<int,int>& r)
292
: range(r), count(0) {
293
copy(p.begin(),p.end(),
inserter
(particles,particles.begin()));
294
}
295
299
void
rebind
(
Tree2toNGenerator
* g) {
300
set<tcPDPtr> oldp = particles;
301
particles.clear();
302
for
( set<tcPDPtr>::const_iterator p = oldp.begin();
303
p != oldp.end(); ++p )
304
particles.insert(g->
getParticleData
((**p).id()));
305
}
306
310
void
reset
() {
311
count = 0;
312
}
313
317
void
add
(
tcPDPtr
p,
int
n) {
318
if
( particles.find(p) == particles.end() )
319
return
;
320
count += n;
321
}
322
326
bool
check
()
const
{
327
return
328
count >= range.first && count <= range.second;
329
}
330
331
};
332
333
protected
:
334
341
virtual
IBPtr
clone()
const
;
342
347
virtual
IBPtr
fullclone()
const
;
349
350
351
// If needed, insert declarations of virtual function defined in the
352
// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
353
354
private
:
355
359
VertexVector
theVertices
;
360
364
PDVector
theExcludeInternal
;
365
369
unsigned
int
maxOrderGs
;
370
374
unsigned
int
maxOrderGem
;
375
379
bool
prepared
;
380
384
VertexVector
theExcludeVertices
;
385
389
vector<LineMatcher>
spaceLikeAllowed
;
390
394
vector<LineMatcher>
timeLikeAllowed
;
395
399
PDVector
theRestrictLines
;
400
404
string
doSpaceLikeRange(
string
);
405
409
string
doTimeLikeRange(
string
);
410
414
string
doClearRestrictLines(
string
);
415
416
private
:
417
422
Tree2toNGenerator
& operator=(
const
Tree2toNGenerator
&) =
delete
;
423
424
};
425
426
inline
PersistentOStream
&
operator<<
(
PersistentOStream
& os,
const
Tree2toNGenerator::LineMatcher
& m) {
427
os << m.
particles
<< m.
range
<< m.
count
;
428
return
os;
429
}
430
431
inline
PersistentIStream
&
operator>>
(
PersistentIStream
& is,
Tree2toNGenerator::LineMatcher
& m) {
432
is >> m.
particles
>> m.
range
>> m.
count
;
433
return
is;
434
}
435
436
}
437
438
#endif
/* Herwig_Tree2toNGenerator_H */
ThePEG::PersistentIStream
Herwig::Tree2toNGenerator::LineMatcher::check
bool check() const
Ceck if restrictions are met.
Definition:
Tree2toNGenerator.h:326
Herwig::Tree2toNGenerator::maxOrderGem
unsigned int maxOrderGem
Maximum order in gem to consider.
Definition:
Tree2toNGenerator.h:374
Herwig::Tree2toNGenerator::LineMatcher::LineMatcher
LineMatcher(const PDVector &p, const pair< int, int > &r)
Construct given particles and a range.
Definition:
Tree2toNGenerator.h:290
ThePEG::Tree2toNDiagram
Herwig::Tree2toNGenerator::LineMatcher::reset
void reset()
Reset this matcher.
Definition:
Tree2toNGenerator.h:310
ThePEG::PersistentOStream
ThePEG::IBPtr
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
Herwig::Tree2toNGenerator::theRestrictLines
PDVector theRestrictLines
The next particle for which internal lines need to be restricted.
Definition:
Tree2toNGenerator.h:399
Herwig::Tree2toNGenerator::Vertex::Vertex
Vertex()
The default constructor.
Definition:
Tree2toNGenerator.h:146
ThePEG
Herwig::Tree2toNGenerator::spaceLikeAllowed
vector< LineMatcher > spaceLikeAllowed
Minimal and maximal occurences of spacelike internal lines.
Definition:
Tree2toNGenerator.h:389
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:182
inserter
std::insert_iterator< Cont > inserter(Cont &c)
Herwig::Tree2toNGenerator::LineMatcher::rebind
void rebind(Tree2toNGenerator *g)
Rebind the particle data pointers.
Definition:
Tree2toNGenerator.h:299
Herwig::Tree2toNGenerator
Generate Tree2toNDiagrams for a given process.
Definition:
Tree2toNGenerator.h:35
Herwig::Tree2toNGenerator::Vertex::parent
PDPtr parent
The incoming line at this node.
Definition:
Tree2toNGenerator.h:126
ThePEG::Helicity::outgoing
outgoing
Herwig::operator<<
ostream & operator<<(ostream &, const DecayIntegrator &)
Output information on the DecayIntegrator for debugging purposes.
Herwig::Tree2toNGenerator::theExcludeInternal
PDVector theExcludeInternal
The particles to be excluded from internal lines.
Definition:
Tree2toNGenerator.h:364
Herwig::Tree2toNGenerator::Vertex::print
void print(ostream &os, const string &prefix="") const
Debug printout.
Definition:
Tree2toNGenerator.h:152
Herwig::Tree2toNGenerator::LineMatcher::range
pair< int, int > range
The range allowed.
Definition:
Tree2toNGenerator.h:274
ThePEG::Interfaced::getParticleData
PDPtr getParticleData(PID) const
Herwig::operator>>
PersistentIStream & operator>>(PersistentIStream &is, map< ShowerInteraction, T, Cmp, A > &m)
Read a map with ShowerInteraction as the key.
Definition:
GeneralTwoBodyDecayer.h:288
Herwig::Tree2toNGenerator::LineMatcher::count
int count
The current count.
Definition:
Tree2toNGenerator.h:279
ThePEG::tcPDPtr
ThePEG::Ptr< ParticleData >::transient_const_pointer tcPDPtr
Herwig::Tree2toNGenerator::Vertex
A node in internally used trees.
Definition:
Tree2toNGenerator.h:114
Herwig::Tree2toNGenerator::timeLikeAllowed
vector< LineMatcher > timeLikeAllowed
Minimal and maximal occurences of timelike internal lines.
Definition:
Tree2toNGenerator.h:394
ThePEG::PDPtr
ThePEG::Ptr< ParticleData >::pointer PDPtr
Herwig::Tree2toNGenerator::excludeInternal
const PDVector & excludeInternal() const
Return the particles to be excluded from internal lines.
Definition:
Tree2toNGenerator.h:81
Herwig::Tree2toNGenerator::theExcludeVertices
VertexVector theExcludeVertices
The vertices to be excluded.
Definition:
Tree2toNGenerator.h:384
Herwig::Tree2toNGenerator::theVertices
VertexVector theVertices
The vertices to be used.
Definition:
Tree2toNGenerator.h:359
ThePEG::HandlerBase
Herwig::RandomHelpers::generate
pair< double, double > generate(const Generator< Density > &gen, double r)
Generate a random variable and return its weight.
Definition:
RandomHelpers.h:182
Herwig::Tree2toNGenerator::prepared
bool prepared
Wether or not the generator has been prepared.
Definition:
Tree2toNGenerator.h:379
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
Herwig::Tree2toNGenerator::LineMatcher::add
void add(tcPDPtr p, int n)
Count the given multiplicity.
Definition:
Tree2toNGenerator.h:317
Herwig::Tree2toNGenerator::Vertex::parentId
int parentId
The parent diagram id.
Definition:
Tree2toNGenerator.h:141
ThePEG::PDVector
vector< PDPtr > PDVector
Herwig::Tree2toNGenerator::Vertex::nspace
int nspace() const
Count the number of spacelike lines.
Definition:
Tree2toNGenerator.h:170
Herwig::Tree2toNGenerator::maxOrderGs
unsigned int maxOrderGs
Maximum order in gs to consider.
Definition:
Tree2toNGenerator.h:369
Herwig::Tree2toNGenerator::Vertex::spacelike
bool spacelike
True, if this is spacelike node.
Definition:
Tree2toNGenerator.h:131
Herwig::Tree2toNGenerator::Vertex::generate
Tree2toNDiagram generate(int id)
Generate a diagram of given id.
Definition:
Tree2toNGenerator.h:228
Herwig::Tree2toNGenerator::LineMatcher::particles
set< tcPDPtr > particles
The group of lines to be considered.
Definition:
Tree2toNGenerator.h:269
Herwig::Tree2toNGenerator::Vertex::externalId
int externalId
The external leg id.
Definition:
Tree2toNGenerator.h:136
Herwig::Tree2toNGenerator::LineMatcher::LineMatcher
LineMatcher()
Default constructor.
Definition:
Tree2toNGenerator.h:284
Herwig::Tree2toNGenerator::vertices
const VertexVector & vertices() const
Return the vertices.
Definition:
Tree2toNGenerator.h:71
Herwig::Tree2toNGenerator::vertices
VertexVector & vertices()
Access the vertices.
Definition:
Tree2toNGenerator.h:66
Herwig::Tree2toNGenerator::Vertex::children
vector< Vertex > children
The outgoing particles.
Definition:
Tree2toNGenerator.h:121
Herwig::Tree2toNGenerator::excludeInternal
PDVector & excludeInternal()
Access the particles to be excluded from internal lines.
Definition:
Tree2toNGenerator.h:76
Herwig::Tree2toNGenerator::LineMatcher
Helper for topology restrictions.
Definition:
Tree2toNGenerator.h:264
Generated on Sat Apr 11 2020 14:50:32 for Herwig by
1.8.13