thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Handlers
SamplerBase.h
1
// -*- C++ -*-
2
//
3
// SamplerBase.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_SamplerBase_H
10
#define ThePEG_SamplerBase_H
11
// This is the declaration of the SamplerBase class.
12
13
#include "ThePEG/Interface/Interfaced.h"
14
#include "SamplerBase.fh"
15
#include "ThePEG/Handlers/StandardEventHandler.fh"
16
// #include "SamplerBase.xh"
17
18
namespace
ThePEG
{
19
35
class
SamplerBase
:
public
Interfaced
{
36
37
public
:
38
41
45
SamplerBase
()
46
:
Interfaced
(),
47
theIntegrationList
(
""
) {}
48
52
virtual
~SamplerBase
();
54
55
public
:
56
62
void
setEventHandler
(tStdEHPtr eh) {
theEventHandler
= eh; }
63
70
virtual
void
initialize
() = 0;
71
76
virtual
void
prepare
() {}
77
82
virtual
double
generate
() = 0;
83
87
virtual
void
rejectLast
() = 0;
88
92
const
vector<double> &
lastPoint
()
const
{
return
theLastPoint
; }
93
99
virtual
int
lastBin
()
const
{
return
0; }
100
105
virtual
CrossSection
integratedXSec
()
const
= 0;
106
111
virtual
CrossSection
integratedXSecErr
()
const
= 0;
112
120
virtual
CrossSection
maxXSec
()
const
{
121
if
(
sumWeights2
() <= 0.0 )
return
ZERO
;
122
return
integratedXSec
()*
attempts
()/
sumWeights
();
123
}
124
132
virtual
double
attempts
()
const
{
133
CrossSection
sigma =
integratedXSec
();
134
CrossSection
esigma =
integratedXSecErr
();
135
double
sw =
sumWeights
();
double
sw2 =
sumWeights2
();
136
if
( sw2 <= 0.0 )
return
0.0;
137
return
138
sqr
(sw)*(
sqr
(esigma)-
sqr
(sigma))/(
sqr
(sw)*
sqr
(esigma) - sw2*
sqr
(sigma));
139
}
140
145
virtual
double
sumWeights
()
const
= 0;
146
151
virtual
double
sumWeights2
()
const
= 0;
152
156
virtual
bool
almostUnweighted
()
const
{
return
false
; }
158
161
165
void
integrationList
(
const
string
& newIntegrationList) {
theIntegrationList
= newIntegrationList; }
166
170
const
string
&
integrationList
()
const
{
return
theIntegrationList
; }
171
175
enum
RunLevels
{
176
177
UnknownMode = 0,
178
InitMode,
179
ReadMode,
180
BuildMode,
181
IntegrationMode,
182
RunMode
183
184
};
185
189
static
int
runLevel
() {
190
return
theRunLevel
();
191
}
192
196
static
void
setRunLevel
(
int
level) {
197
theRunLevel
() = level;
198
}
199
203
static
bool
hasSetupFile
() {
204
return
theHasSetupFile
();
205
}
206
210
static
void
setupFileUsed
(
bool
yes =
true
) {
211
theHasSetupFile
() = yes;
212
}
213
218
static
long
seed
() {
219
return
theSeed
();
220
}
221
226
static
void
setSeed
(
long
s) {
227
theSeed
() = s;
228
}
229
233
static
unsigned
int
integratePerJob
() {
234
return
theIntegratePerJob
();
235
}
236
240
static
void
setIntegratePerJob
(
unsigned
int
s) {
241
theIntegratePerJob
() = s;
242
}
243
247
static
unsigned
int
integrationJobs
() {
248
return
theIntegrationJobs
();
249
}
250
254
static
void
setIntegrationJobs
(
unsigned
int
s) {
255
theIntegrationJobs
() = s;
256
}
257
259
260
protected
:
261
265
vector<double> &
lastPoint
() {
return
theLastPoint
; }
266
270
tStdEHPtr
eventHandler
()
const
{
return
theEventHandler
; }
271
272
public
:
273
280
void
persistentOutput
(
PersistentOStream
& os)
const
;
281
287
void
persistentInput
(
PersistentIStream
& is,
int
version);
289
293
static
void
Init
();
294
295
private
:
296
300
tStdEHPtr
theEventHandler
;
301
305
vector<double>
theLastPoint
;
306
310
string
theIntegrationList
;
311
315
static
int
&
theRunLevel
() {
316
static
int
lvl = UnknownMode;
317
return
lvl;
318
}
319
323
static
bool
&
theHasSetupFile
() {
324
static
bool
flag =
false
;
325
return
flag;
326
}
327
332
static
long
&
theSeed
() {
333
static
long
s = 0;
334
return
s;
335
}
336
340
static
unsigned
int
&
theIntegratePerJob
() {
341
static
unsigned
int
s = 0;
342
return
s;
343
}
344
348
static
unsigned
int
&
theIntegrationJobs
() {
349
static
unsigned
int
s = 0;
350
return
s;
351
}
352
353
private
:
354
358
static
AbstractClassDescription<SamplerBase>
initSamplerBase
;
359
363
SamplerBase
&
operator=
(
const
SamplerBase
&) =
delete
;
364
365
};
366
367
}
368
369
370
namespace
ThePEG
{
371
378
template
<>
379
struct
BaseClassTrait<SamplerBase,1>:
public
ClassTraitsType {
381
typedef
Interfaced
NthBase
;
382
};
383
388
template
<>
389
struct
ClassTraits<SamplerBase>:
public
ClassTraitsBase<SamplerBase> {
391
static
string
className
() {
return
"ThePEG::SamplerBase"
; }
392
393
};
394
397
}
398
399
#endif
/* ThePEG_SamplerBase_H */
ThePEG::AbstractClassDescription
A concreate implementation of ClassDescriptionBase describing an abstract class with persistent data.
Definition:
ClassDescription.h:282
ThePEG::Interfaced
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition:
Interfaced.h:38
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::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::SamplerBase::theSeed
static long & theSeed()
The seed that has been used for this run to disentangle grids whihch have been adapted further.
Definition:
SamplerBase.h:332
ThePEG::SamplerBase::prepare
virtual void prepare()
An external hook to prepare the sampler for generating events, e.g.
Definition:
SamplerBase.h:76
ThePEG::SamplerBase::setIntegratePerJob
static void setIntegratePerJob(unsigned int s)
Set the number of subprocesses to be integrated per job.
Definition:
SamplerBase.h:240
ThePEG::SamplerBase::integrationList
void integrationList(const string &newIntegrationList)
Set a file containing a list of subprocesses to integrate.
Definition:
SamplerBase.h:165
ThePEG::SamplerBase::~SamplerBase
virtual ~SamplerBase()
Destructor.
ThePEG::SamplerBase::seed
static long seed()
Return the seed that has been used for this run to disentangle grids whihch have been adapted further...
Definition:
SamplerBase.h:218
ThePEG::SamplerBase::theHasSetupFile
static bool & theHasSetupFile()
True, if a setupfile is in use.
Definition:
SamplerBase.h:323
ThePEG::SamplerBase::attempts
virtual double attempts() const
Return the number of attempts.
Definition:
SamplerBase.h:132
ThePEG::SamplerBase::almostUnweighted
virtual bool almostUnweighted() const
Return true if this sampler is generating almost unweighted events.
Definition:
SamplerBase.h:156
ThePEG::SamplerBase::theIntegrationList
string theIntegrationList
A file containing a list of subprocesses to integrate.
Definition:
SamplerBase.h:310
ThePEG::SamplerBase::rejectLast
virtual void rejectLast()=0
Reject the last chosen phase space point.
ThePEG::SamplerBase::setEventHandler
void setEventHandler(tStdEHPtr eh)
Set the event handler for which the function StandardEventHandler::dSigDR(const vector<double> &) fun...
Definition:
SamplerBase.h:62
ThePEG::SamplerBase::hasSetupFile
static bool hasSetupFile()
Return true, if a setupfile is in use.
Definition:
SamplerBase.h:203
ThePEG::SamplerBase::sumWeights
virtual double sumWeights() const =0
Return the sum of the weights returned by generate() so far (of the events that were not rejeted).
ThePEG::SamplerBase::lastPoint
vector< double > & lastPoint()
Return the last generated phase space point.
Definition:
SamplerBase.h:265
ThePEG::SamplerBase::eventHandler
tStdEHPtr eventHandler() const
Return the associated event handler.
Definition:
SamplerBase.h:270
ThePEG::SamplerBase::setRunLevel
static void setRunLevel(int level)
Set the run level.
Definition:
SamplerBase.h:196
ThePEG::SamplerBase::theRunLevel
static int & theRunLevel()
The run level.
Definition:
SamplerBase.h:315
ThePEG::SamplerBase::generate
virtual double generate()=0
Generarate a new phase space point and return a weight associated with it.
ThePEG::SamplerBase::initSamplerBase
static AbstractClassDescription< SamplerBase > initSamplerBase
Describe an abstract base class with persistent data.
Definition:
SamplerBase.h:358
ThePEG::SamplerBase::setupFileUsed
static void setupFileUsed(bool yes=true)
Indicate that a setupfile is in use.
Definition:
SamplerBase.h:210
ThePEG::SamplerBase::RunLevels
RunLevels
Enumerate the possible run levels.
Definition:
SamplerBase.h:175
ThePEG::SamplerBase::integrationList
const string & integrationList() const
Return a file containing a list of subprocesses to integrate.
Definition:
SamplerBase.h:170
ThePEG::SamplerBase::integratedXSec
virtual CrossSection integratedXSec() const =0
Return the total integrated cross section determined from the Monte Carlo sampling so far.
ThePEG::SamplerBase::setSeed
static void setSeed(long s)
Set the seed that has been used for this run to disentangle grids whihch have been adapted further.
Definition:
SamplerBase.h:226
ThePEG::SamplerBase::maxXSec
virtual CrossSection maxXSec() const
Return the reference cross section, a.k.a.
Definition:
SamplerBase.h:120
ThePEG::SamplerBase::sumWeights2
virtual double sumWeights2() const =0
Return the sum of the weights squared returned by generate() so far (of the events that were not reje...
ThePEG::SamplerBase::theIntegrationJobs
static unsigned int & theIntegrationJobs()
The maximum number of integration jobs to be created.
Definition:
SamplerBase.h:348
ThePEG::SamplerBase::setIntegrationJobs
static void setIntegrationJobs(unsigned int s)
Set the maximum number of integration jobs to be created.
Definition:
SamplerBase.h:254
ThePEG::SamplerBase::runLevel
static int runLevel()
Return the run level.
Definition:
SamplerBase.h:189
ThePEG::SamplerBase::integratedXSecErr
virtual CrossSection integratedXSecErr() const =0
Return the error on the total integrated cross section determined from the Monte Carlo sampling so fa...
ThePEG::SamplerBase::Init
static void Init()
Standard Init function used to initialize the interfaces.
ThePEG::SamplerBase::persistentInput
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
ThePEG::SamplerBase::theEventHandler
tStdEHPtr theEventHandler
The associated event handler.
Definition:
SamplerBase.h:300
ThePEG::SamplerBase::persistentOutput
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
ThePEG::SamplerBase::lastBin
virtual int lastBin() const
If the sampler is able to sample several different functions separately, this function should return ...
Definition:
SamplerBase.h:99
ThePEG::SamplerBase::integratePerJob
static unsigned int integratePerJob()
Return the number of subprocesses to be integrated per job.
Definition:
SamplerBase.h:233
ThePEG::SamplerBase::theIntegratePerJob
static unsigned int & theIntegratePerJob()
The number of subprocesses to be integrated per job.
Definition:
SamplerBase.h:340
ThePEG::SamplerBase::integrationJobs
static unsigned int integrationJobs()
Return the maximum number of integration jobs to be created.
Definition:
SamplerBase.h:247
ThePEG::SamplerBase::SamplerBase
SamplerBase()
Constructor.
Definition:
SamplerBase.h:45
ThePEG::SamplerBase::operator=
SamplerBase & operator=(const SamplerBase &)=delete
Private and non-existent assignment operator.
ThePEG::SamplerBase::theLastPoint
vector< double > theLastPoint
The last generated phase space point.
Definition:
SamplerBase.h:305
ThePEG::SamplerBase::lastPoint
const vector< double > & lastPoint() const
Return the last generated phase space point.
Definition:
SamplerBase.h:92
ThePEG::SamplerBase::initialize
virtual void initialize()=0
Initialize the the sampler, possibly doing presampling of the phase space.
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::ZERO
constexpr ZeroUnit ZERO
ZERO can be used as zero for any unitful quantity.
Definition:
PhysicalQty.h:35
ThePEG::sqr
constexpr auto sqr(const T &x) -> decltype(x *x)
The square function should really have been included in the standard C++ library.
Definition:
ThePEG.h:117
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
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6