thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Handlers
ACDCSampler.h
1
// -*- C++ -*-
2
//
3
// ACDCSampler.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2019 Leif Lonnblad
5
//
6
// ThePEG 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 ThePEG_ACDCSampler_H
10
#define ThePEG_ACDCSampler_H
11
// This is the declaration of the ACDCSampler class.
12
13
#include "ThePEG/Handlers/SamplerBase.h"
14
#include "ThePEG/ACDC/ACDCGen.h"
15
#include "ThePEG/Handlers/StandardEventHandler.h"
16
#include "ThePEG/Repository/RandomGenerator.h"
17
#include "ThePEG/Repository/UseRandom.h"
18
#include "ThePEG/Utilities/SimplePhaseSpace.xh"
19
20
// #include "ACDCSampler.fh"
21
// #include "ACDCSampler.xh"
22
23
namespace
ThePEG
{
24
34
class
ACDCSampler
:
public
SamplerBase
{
35
36
public
:
37
39
typedef
ACDCGenerator::ACDCGen<UseRandom,tStdEHPtr>
SamplerType
;
40
46
ACDCSampler
() :
theEps
(100*Constants::epsilon),
theMargin
(1.1),
theNTry
(1000) {}
47
51
ACDCSampler
(
const
ACDCSampler
& x)
52
:
SamplerBase
(x),
theSampler
(),
53
theEps
(x.
theEps
),
theMargin
(x.
theMargin
),
54
theNTry
(x.
theNTry
) {}
55
59
virtual
~ACDCSampler
();
61
62
public
:
63
70
virtual
void
initialize
();
71
76
virtual
double
generate
();
77
83
virtual
int
lastBin
()
const
;
84
88
virtual
void
rejectLast
();
89
94
virtual
CrossSection
integratedXSec
()
const
;
95
100
virtual
CrossSection
integratedXSecErr
()
const
;
101
106
virtual
double
sumWeights
()
const
;
107
112
virtual
double
sumWeights2
()
const
;
114
115
public
:
116
123
void
persistentOutput
(
PersistentOStream
& os)
const
;
124
130
void
persistentInput
(
PersistentIStream
& is,
int
version);
132
139
static
void
Init
();
140
141
protected
:
142
149
virtual
IBPtr
clone
()
const
;
150
155
virtual
IBPtr
fullclone
()
const
;
156
158
159
protected
:
160
167
virtual
void
doinitrun
();
168
173
virtual
void
dofinish
();
175
176
private
:
177
181
SamplerType
theSampler
;
182
186
double
theEps
;
187
191
double
theMargin
;
192
196
int
theNTry
;
197
198
protected
:
199
203
struct
ACDCStillCompensating:
public
Exception
{};
204
207
struct
EventInitNoXSec:
public
InitException {};
208
212
struct
EventLoopException:
public
Exception {};
215
private
:
216
220
static
ClassDescription<ACDCSampler>
initACDCSampler
;
221
225
ACDCSampler
&
operator=
(
const
ACDCSampler
&) =
delete
;
226
227
};
228
229
}
230
231
namespace
ThePEG
{
232
239
template
<>
240
struct
BaseClassTrait<ACDCSampler,1>:
public
ClassTraitsType {
242
typedef
SamplerBase
NthBase
;
243
};
244
249
template
<>
250
struct
ClassTraits<ACDCSampler>:
public
ClassTraitsBase<ACDCSampler> {
254
static
string
className
() {
return
"ThePEG::ACDCSampler"
; }
259
static
string
library
() {
return
"ACDCSampler.so"
; }
260
261
};
262
265
}
266
267
namespace
ACDCGenerator
{
268
274
template
<>
275
struct
ACDCFncTraits<
ThePEG
::tStdEHPtr>:
public
ACDCTraitsType {
277
typedef
ThePEG::tStdEHPtr tStdEHPtr;
282
static
inline
double
value
(
const
tStdEHPtr & eh,
const
DVector
& x) {
283
using namespace
ThePEG::Units
;
284
try
{
285
return
eh->dSigDR(x)/nanobarn;
286
}
287
catch
( ThePEG::ImpossibleKinematics & v ) {
288
breakThePEG();
289
}
290
catch
( std::exception & e ) {
291
breakThePEG();
292
}
293
catch
( ... ) {
294
breakThePEG();
295
}
296
return
0.0;
297
}
298
299
};
300
303
template
<>
304
struct
ACDCRandomTraits<
ThePEG
::
UseRandom
>:
public
ACDCTraitsType {
306
typedef
ThePEG::UseRandom
UseRandom
;
307
311
static
inline
double
rnd
(
UseRandom
*) {
return
UseRandom::rnd(); }
312
316
static
inline
double
rnd
(
UseRandom
* r,
double
xl,
double
xu) {
317
return
xl + (xu - xl)*
rnd
(r);
318
}
319
331
template
<
typename
InputIterator,
typename
OutputIterator>
332
static
inline
void
rnd
(
UseRandom
* r,
333
InputIterator l, InputIterator lend,
334
InputIterator u, OutputIterator res) {
335
for
( ; l != lend; ++l ) *res++ = *l + (*u++ - *l)*
rnd
(r);
336
}
337
342
template
<
typename
OutputIterator>
343
static
inline
void
rnd
(
UseRandom
* r,
int
D, OutputIterator res) {
344
for
(
int
d = 0;
d
< D; ++
d
) *res++ =
rnd
(r);
345
}
346
350
static
inline
bool
rndBool
(
UseRandom
,
double
x) {
351
return
UseRandom::rndbool(x);
352
}
353
357
static
inline
bool
rndBool
(
UseRandom
*,
double
x,
double
y) {
358
return
UseRandom::rndbool(x, y);
359
}
360
364
static
inline
long
rndInt
(
UseRandom
*,
long
x) {
365
return
UseRandom::irnd(x);
366
}
367
368
};
369
372
}
373
374
#endif
/* ThePEG_ACDCSampler_H */
ACDCGenerator::ACDCGen
ACDCGen is a general class for sampling multi-dimensional functions.
Definition:
ACDCGen.h:49
ThePEG::ACDCSampler
This class inherits from SampleBase and implements the Auto Compensating Divide-and-Conquer phase spa...
Definition:
ACDCSampler.h:34
ThePEG::ACDCSampler::ACDCSampler
ACDCSampler(const ACDCSampler &x)
The copy constructor.
Definition:
ACDCSampler.h:51
ThePEG::ACDCSampler::sumWeights
virtual double sumWeights() const
Return the sum of the weights returned by generate() so far (of the events that were not rejeted).
ThePEG::ACDCSampler::rejectLast
virtual void rejectLast()
Reject the last chosen phase space point.
ThePEG::ACDCSampler::ACDCSampler
ACDCSampler()
The default constructor.
Definition:
ACDCSampler.h:46
ThePEG::ACDCSampler::clone
virtual IBPtr clone() const
Make a simple clone of this object.
ThePEG::ACDCSampler::persistentOutput
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
ThePEG::ACDCSampler::integratedXSecErr
virtual CrossSection integratedXSecErr() const
Return the error on the total integrated cross section determined from the Monte Carlo sampling so fa...
ThePEG::ACDCSampler::integratedXSec
virtual CrossSection integratedXSec() const
Return the total integrated cross section determined from the Monte Carlo sampling so far.
ThePEG::ACDCSampler::persistentInput
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
ThePEG::ACDCSampler::initialize
virtual void initialize()
Initialize the the sampler, possibly doing presampling of the phase space.
ThePEG::ACDCSampler::theEps
double theEps
The smallest possible division allowed.
Definition:
ACDCSampler.h:186
ThePEG::ACDCSampler::generate
virtual double generate()
Generarate a new phase space point and return a weight associated with it.
ThePEG::ACDCSampler::sumWeights2
virtual double sumWeights2() const
Return the sum of the weights squared returned by generate() so far (of the events that were not reje...
ThePEG::ACDCSampler::dofinish
virtual void dofinish()
Finalize this object.
ThePEG::ACDCSampler::theMargin
double theMargin
The factor controlling the loss of efficiency when compensating.
Definition:
ACDCSampler.h:191
ThePEG::ACDCSampler::lastBin
virtual int lastBin() const
ACDCSampler is able to sample several different functions separately.
ThePEG::ACDCSampler::Init
static void Init()
The standard Init function used to initialize the interfaces.
ThePEG::ACDCSampler::initACDCSampler
static ClassDescription< ACDCSampler > initACDCSampler
Describe a concrete class with persistent data.
Definition:
ACDCSampler.h:220
ThePEG::ACDCSampler::SamplerType
ACDCGenerator::ACDCGen< UseRandom, tStdEHPtr > SamplerType
Typedef the underlying ACDCGen class.
Definition:
ACDCSampler.h:39
ThePEG::ACDCSampler::fullclone
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
ThePEG::ACDCSampler::doinitrun
virtual void doinitrun()
Initialize this object.
ThePEG::ACDCSampler::~ACDCSampler
virtual ~ACDCSampler()
The destructor.
ThePEG::ACDCSampler::theNTry
int theNTry
The number of points to use to find initial average.
Definition:
ACDCSampler.h:196
ThePEG::ACDCSampler::operator=
ACDCSampler & operator=(const ACDCSampler &)=delete
Private and non-existent assignment operator.
ThePEG::ACDCSampler::theSampler
SamplerType theSampler
The actual sampler object.
Definition:
ACDCSampler.h:181
ThePEG::ClassDescription
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data.
Definition:
ClassDescription.h:333
ThePEG::Exception
Exception is the base class for all exceptions to be used in ThePEG.
Definition:
Exception.h:44
ThePEG::PersistentIStream
PersistentIStream is used to read persistent objects from a stream where they were previously written...
Definition:
PersistentIStream.h:48
ThePEG::PersistentOStream
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
Definition:
PersistentOStream.h:51
ThePEG::Pointer::RCPtr
RCPtr is a reference counted (smart) pointer.
Definition:
RCPtr.h:60
ThePEG::Qty< std::ratio< L, DL >, std::ratio< E, DE >, std::ratio< Q, DQ > >
Definition:
PhysicalQty.h:77
ThePEG::SamplerBase
This is the base class for all phase space sampler classes to be used by the EventHandler class to sa...
Definition:
SamplerBase.h:35
ThePEG::UseRandom
This UseRandom class keeps a static stack of RandomGenerator objects which can be used anywhere by an...
Definition:
UseRandom.h:33
ACDCGenerator
The namespace in which all ACDCGen classes are defined.
Definition:
ACDCGen.h:18
ACDCGenerator::DVector
vector< double > DVector
A vector of doubles.
Definition:
ACDCGenConfig.h:58
ThePEG::ParticleID::d
@ d
(d)
Definition:
EnumParticles.h:24
ThePEG::Units
The Units namespace contains the declaration of a number of classes for variables with dimension.
Definition:
Unitsystem.h:35
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ACDCGenerator::ACDCFncTraits::value
static double value(const FncPtr &f, const DVector &x)
Call a function to be sampled by ACDCGen.
Definition:
ACDCTraits.h:34
ACDCGenerator::ACDCRandomTraits::rndInt
static long rndInt(Rnd *r, long x)
Return a random integer in the interval [0,x[.
Definition:
ACDCTraits.h:101
ACDCGenerator::ACDCRandomTraits::rnd
static double rnd(Rnd *r)
Return a flat random number in the interval ]0,1[.
Definition:
ACDCTraits.h:52
ACDCGenerator::ACDCRandomTraits::rndBool
static bool rndBool(Rnd *r, double x)
Return true with probability x.
Definition:
ACDCTraits.h:90
ThePEG::BaseClassTrait::NthBase
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition:
ClassTraits.h:161
ThePEG::ClassTraitsBase::className
static string className()
Return the name of class T.
Definition:
ClassTraits.h:66
ThePEG::ClassTraitsBase::library
static string library()
The name of a file containing the dynamic library where the class T is implemented.
Definition:
ClassTraits.h:85
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6