herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.2.1
UnderlyingEvent
MPISampler.h
1
// -*- C++ -*-
2
//
3
// MPISampler.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_MPISampler_H
10
#define Herwig_MPISampler_H
11
// This is the declaration of the MPISampler class.
12
13
#include "ThePEG/Handlers/SamplerBase.h"
14
#include "ThePEG/ACDC/ACDCGen.h"
15
#include "ThePEG/Repository/RandomGenerator.h"
16
#include "ThePEG/Repository/UseRandom.h"
17
#include "ThePEG/Utilities/SimplePhaseSpace.xh"
18
#include "MPISampler.fh"
19
20
#include "ProcessHandler.h"
21
22
namespace
Herwig
{
23
24
using namespace
ThePEG
;
25
38
class
MPISampler
:
public
SamplerBase
{
39
40
public
:
41
43
typedef
ACDCGenerator::ACDCGen<UseRandom,tProHdlPtr>
SamplerType
;
44
50
inline
MPISampler
();
51
55
inline
MPISampler
(
const
MPISampler
&);
56
60
virtual
~
MPISampler
();
62
63
public
:
64
71
inline
void
setProcessHandler(tProHdlPtr mpih);
72
77
virtual
void
initialize();
78
83
virtual
double
generate
();
84
90
virtual
int
lastBin()
const
;
91
95
virtual
void
rejectLast();
96
101
virtual
CrossSection integratedXSec()
const
;
102
107
virtual
CrossSection integratedXSecErr()
const
;
108
112
virtual
CrossSection maxXSec()
const
;
113
118
virtual
double
sumWeights()
const
;
119
124
virtual
double
sumWeights2()
const
;
126
127
public
:
128
135
void
persistentOutput(
PersistentOStream
& os)
const
;
136
142
void
persistentInput(
PersistentIStream
& is,
int
version);
144
151
static
void
Init();
152
153
protected
:
154
161
inline
virtual
IBPtr
clone()
const
;
162
167
inline
virtual
IBPtr
fullclone()
const
;
168
170
171
protected
:
172
178
inline
virtual
void
doupdate();
179
185
inline
virtual
void
doinit();
186
191
virtual
void
doinitrun();
192
197
virtual
void
dofinish();
198
199
208
inline
virtual
void
rebind(
const
TranslationMap
& trans)
209
;
210
215
inline
virtual
IVector
getReferences();
217
218
private
:
219
223
SamplerType
theSampler
;
224
228
tProHdlPtr
theProcessHandler
;
229
233
double
theEps
;
234
238
double
theMargin
;
239
243
int
theNTry
;
244
245
protected
:
246
250
struct
ACDCStillCompensating:
public
Exception
{};
251
254
struct
EventInitNoXSec:
public
Exception
{};
255
259
struct
EventLoopException:
public
Exception
{};
262
private
:
263
267
MPISampler
& operator=(
const
MPISampler
&) =
delete
;
268
269
};
270
271
}
272
273
namespace
ACDCGenerator
{
274
280
template
<>
281
struct
ACDCFncTraits<Herwig::tProHdlPtr>:
public
ACDCTraitsType {
283
typedef
Herwig::tProHdlPtr tProHdlPtr;
288
static
inline
double
value(
const
tProHdlPtr & mpih,
const
DVector
& x) {
289
using namespace
ThePEG::Units
;
290
try
{
291
return
mpih->dSigDR(x)/nanobarn;
292
}
293
catch
( ThePEG::ImpossibleKinematics &
v
) {
294
breakThePEG();
295
}
296
catch
( std::exception & e ) {
297
breakThePEG();
298
}
299
catch
( ... ) {
300
breakThePEG();
301
}
302
return
0.0;
303
}
304
305
};
306
309
template
<>
310
struct
ACDCRandomTraits<ThePEG::
UseRandom
>:
public
ACDCTraitsType {
312
typedef
ThePEG::UseRandom
UseRandom
;
313
317
static
inline
double
rnd(UseRandom *) {
return
UseRandom::rnd
(); }
318
322
static
inline
double
rnd(UseRandom * r,
double
xl,
double
xu) {
323
return
xl + (xu - xl)*rnd(r);
324
}
325
337
template
<
typename
InputIterator,
typename
OutputIterator>
338
static
inline
void
rnd(UseRandom * r,
339
InputIterator l, InputIterator lend,
340
InputIterator u, OutputIterator res) {
341
for
( ; l != lend; ++l ) *res++ = *l + (*u++ - *l)*rnd(r);
342
}
343
348
template
<
typename
OutputIterator>
349
static
inline
void
rnd(UseRandom * r,
int
D, OutputIterator res) {
350
for
(
int
d = 0; d < D; ++d ) *res++ = rnd(r);
351
}
352
356
static
inline
bool
rndBool(UseRandom,
double
x) {
357
return
UseRandom::rndbool
(x);
358
}
359
363
static
inline
bool
rndBool(UseRandom *,
double
x,
double
y) {
364
return
UseRandom::rndbool
(x, y);
365
}
366
370
static
inline
long
rndInt(UseRandom *,
long
x) {
371
return
UseRandom::irnd
(x);
372
}
373
374
};
375
378
}
379
380
#include "MPISampler.icc"
381
382
#endif
/* Herwig_MPISampler_H */
ThePEG::PersistentIStream
ACDCGenerator::ACDCGen< UseRandom, tProHdlPtr >
ThePEG::PersistentOStream
ThePEG::UseRandom
ThePEG::IBPtr
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
ThePEG::Rebinder
ThePEG
ThePEG::UseRandom::rnd
static double rnd()
Herwig::MPISampler::theProcessHandler
tProHdlPtr theProcessHandler
The ProcessHandler that calls us.
Definition:
MPISampler.h:228
ThePEG::DVector
vector< double > DVector
Herwig::MPISampler::theSampler
SamplerType theSampler
The actual sampler object.
Definition:
MPISampler.h:223
ThePEG::UseRandom::rndbool
static bool rndbool(double p=0.5)
ThePEG::SamplerBase
Herwig::MPISampler::theMargin
double theMargin
The factor controlling the loss of efficiency when compensating.
Definition:
MPISampler.h:238
ThePEG::UseRandom::irnd
static long irnd(long xu=2)
Herwig::MPISampler::theEps
double theEps
The smallest possible division allowed.
Definition:
MPISampler.h:233
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
ThePEG::Exception
SpinorType::v
Herwig::MPISampler
This class inherits from SampleBase and implements the Auto Compensating Divide-and-Conquer phase spa...
Definition:
MPISampler.h:38
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
ThePEG::IVector
vector< IBPtr > IVector
Herwig::MPISampler::theNTry
int theNTry
The number of points to use to find initial average.
Definition:
MPISampler.h:243
ThePEG::Units
Herwig::MPISampler::SamplerType
ACDCGenerator::ACDCGen< UseRandom, tProHdlPtr > SamplerType
Typedef the underlying ACDCGen class.
Definition:
MPISampler.h:43
ACDCGenerator
Generated on Sat Apr 11 2020 14:50:31 for Herwig by
1.8.13