herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
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 */
ACDCGenerator::ACDCGen
Herwig::MPISampler
This class inherits from SampleBase and implements the Auto Compensating Divide-and-Conquer phase spa...
Definition:
MPISampler.h:38
Herwig::MPISampler::SamplerType
ACDCGenerator::ACDCGen< UseRandom, tProHdlPtr > SamplerType
Typedef the underlying ACDCGen class.
Definition:
MPISampler.h:43
Herwig::MPISampler::generate
virtual double generate()
Generarate a new phase space point and return a weight associated with it.
Herwig::MPISampler::persistentOutput
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
Herwig::MPISampler::MPISampler
MPISampler()
The default constructor.
Herwig::MPISampler::MPISampler
MPISampler(const MPISampler &)
The copy constructor.
Herwig::MPISampler::initialize
virtual void initialize()
Initialize the sampler, possibly doing presampling of the phase space.
Herwig::MPISampler::integratedXSec
virtual CrossSection integratedXSec() const
Return the total integrated cross section determined from the Monte Carlo sampling so far.
Herwig::MPISampler::theEps
double theEps
The smallest possible division allowed.
Definition:
MPISampler.h:233
Herwig::MPISampler::Init
static void Init()
The standard Init function used to initialize the interfaces.
Herwig::MPISampler::setProcessHandler
void setProcessHandler(tProHdlPtr mpih)
Method to set the connected ProcessHandler pointer.
Herwig::MPISampler::dofinish
virtual void dofinish()
Finalize this object.
Herwig::MPISampler::operator=
MPISampler & operator=(const MPISampler &)=delete
Private and non-existent assignment operator.
Herwig::MPISampler::rejectLast
virtual void rejectLast()
Reject the last chosen phase space point.
Herwig::MPISampler::integratedXSecErr
virtual CrossSection integratedXSecErr() const
Return the error on the total integrated cross section determined from the Monte Carlo sampling so fa...
Herwig::MPISampler::sumWeights2
virtual double sumWeights2() const
Return the sum of the weights squared returned by generate() so far (of the events that were not reje...
Herwig::MPISampler::~MPISampler
virtual ~MPISampler()
The destructor.
Herwig::MPISampler::theMargin
double theMargin
The factor controlling the loss of efficiency when compensating.
Definition:
MPISampler.h:238
Herwig::MPISampler::theSampler
SamplerType theSampler
The actual sampler object.
Definition:
MPISampler.h:223
Herwig::MPISampler::doinitrun
virtual void doinitrun()
Initialize this object.
Herwig::MPISampler::maxXSec
virtual CrossSection maxXSec() const
Return the overestimated integrated cross section.
Herwig::MPISampler::doupdate
virtual void doupdate()
Check sanity of the object during the setup phase.
Herwig::MPISampler::fullclone
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
Herwig::MPISampler::doinit
virtual void doinit()
Initialize this object after the setup phase before saving an EventGenerator to disk.
Herwig::MPISampler::theProcessHandler
tProHdlPtr theProcessHandler
The ProcessHandler that calls us.
Definition:
MPISampler.h:228
Herwig::MPISampler::clone
virtual IBPtr clone() const
Make a simple clone of this object.
Herwig::MPISampler::persistentInput
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
Herwig::MPISampler::theNTry
int theNTry
The number of points to use to find initial average.
Definition:
MPISampler.h:243
Herwig::MPISampler::rebind
virtual void rebind(const TranslationMap &trans)
Rebind pointer to other Interfaced objects.
Herwig::MPISampler::lastBin
virtual int lastBin() const
ACDCSampler is able to sample several different functions separately.
Herwig::MPISampler::sumWeights
virtual double sumWeights() const
Return the sum of the weights returned by generate() so far (of the events that were not rejeted).
Herwig::MPISampler::getReferences
virtual IVector getReferences()
Return a vector of all pointers to Interfaced objects used in this object.
ThePEG::Exception
ThePEG::PersistentIStream
ThePEG::PersistentOStream
ThePEG::Rebinder
ThePEG::SamplerBase
ThePEG::UseRandom
ACDCGenerator
DVector
vector< double > DVector
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
SpinorType::v
@ v
ThePEG::ParticleID::d
d
ThePEG::Units
ThePEG
ThePEG::IBPtr
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
ThePEG::IVector
vector< IBPtr > IVector
ACDCGenerator::ACDCFncTraits::value
static double value(const FncPtr &f, const DVector &x)
ACDCGenerator::ACDCRandomTraits::rndInt
static long rndInt(Rnd *r, long x)
ACDCGenerator::ACDCRandomTraits::rnd
static double rnd(Rnd *r)
ACDCGenerator::ACDCRandomTraits::rndBool
static bool rndBool(Rnd *r, double x)
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6