herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.2.1
Sampling
GeneralSampler.h
1
// -*- C++ -*-
2
//
3
// GeneralSampler.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_GeneralSampler_H
10
#define Herwig_GeneralSampler_H
11
//
12
// This is the declaration of the GeneralSampler class.
13
//
14
15
#include "ThePEG/Handlers/SamplerBase.h"
16
#include "BinSampler.h"
17
18
namespace
Herwig
{
19
20
using namespace
ThePEG
;
21
31
class
GeneralSampler
:
public
SamplerBase
{
32
33
public
:
34
40
GeneralSampler
();
41
45
virtual
~
GeneralSampler
();
47
48
public
:
49
56
virtual
void
initialize();
57
62
virtual
double
generate
();
63
67
virtual
void
rejectLast();
68
74
virtual
int
lastBin
()
const
{
return
lastSampler() ? lastSampler()->bin() : 0; }
75
80
virtual
CrossSection
integratedXSec
()
const
{
81
currentCrossSections();
82
return
theIntegratedXSec;
83
}
84
89
virtual
CrossSection
integratedXSecErr
()
const
{
90
currentCrossSections();
91
return
theIntegratedXSecErr;
92
}
93
97
virtual
CrossSection
maxXSec
()
const
{
98
if
( theAddUpSamplers )
99
return
SamplerBase::maxXSec
();
100
return
theMaxWeight*nanobarn;
101
}
102
107
virtual
double
sumWeights
()
const
{
return
theSumWeights; }
108
113
virtual
double
sumWeights2
()
const
{
return
theSumWeights2; }
114
118
virtual
double
attempts
()
const
{
119
if
( theAddUpSamplers )
120
return
SamplerBase::attempts
();
121
return
theAttempts;
122
}
123
127
double
accepts
()
const
{
return
theAccepts; }
128
130
134
const
map<double,Ptr<BinSampler>::ptr>&
samplers
()
const
{
return
theSamplers; }
135
139
Ptr<BinSampler>::ptr
binSampler
()
const
{
return
theBinSampler; }
140
144
Ptr<BinSampler>::tptr
lastSampler
()
const
{
return
theLastSampler; }
145
149
bool
weighted
()
const
{
return
eventHandler()->weighted(); }
150
154
virtual
bool
almostUnweighted
()
const
{
return
theAlmostUnweighted; }
155
156
public
:
157
161
const
XML::Element
&
grids
()
const
{
return
theGrids; }
162
166
XML::Element
&
grids
() {
return
theGrids; }
167
171
void
writeGrids()
const
;
172
176
void
readGrids();
177
181
unsigned
int
integrationJobsCreated
() {
182
return
theIntegrationJobsCreated;
183
}
184
189
virtual
void
prepare();
190
191
protected
:
192
196
map<double,Ptr<BinSampler>::ptr>&
samplers
() {
return
theSamplers; }
197
201
void
lastSampler
(Ptr<BinSampler>::tptr s) { theLastSampler = s; }
202
206
void
currentCrossSections()
const
;
207
211
void
updateSamplers();
212
213
public
:
214
221
void
persistentOutput(
PersistentOStream
& os)
const
;
222
228
void
persistentInput(
PersistentIStream
& is,
int
version);
230
237
static
void
Init();
238
239
protected
:
240
247
virtual
IBPtr
clone()
const
;
248
253
virtual
IBPtr
fullclone()
const
;
255
256
257
// If needed, insert declarations of virtual function defined in the
258
// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
259
260
261
protected
:
262
268
virtual
void
doinit();
269
274
virtual
void
doinitrun();
275
280
virtual
void
dofinish();
281
291
virtual
void
rebind(
const
TranslationMap
& trans);
292
298
virtual
IVector
getReferences();
299
300
private
:
301
305
bool
theVerbose
;
306
310
XML::Element
theGrids
;
311
315
Ptr<BinSampler>::ptr
theBinSampler
;
316
320
map<double,Ptr<BinSampler>::ptr>
theSamplers
;
321
325
Ptr<BinSampler>::tptr
theLastSampler
;
326
330
mutable
CrossSection
theIntegratedXSec
;
331
335
mutable
CrossSection
theIntegratedXSecErr
;
336
342
size_t
theUpdateAfter
;
343
348
mutable
size_t
crossSectionCalls
;
349
354
mutable
bool
gotCrossSections
;
355
359
double
theSumWeights
;
360
364
double
theSumWeights2
;
365
369
double
theAttempts
;
370
374
double
theAccepts
;
375
379
double
theMaxWeight
;
380
385
bool
theAddUpSamplers
;
386
393
bool
theGlobalMaximumWeight
;
394
400
bool
theFlatSubprocesses
;
401
405
bool
isSampling
;
406
410
double
theMinSelection
;
411
416
bool
runCombinationData
;
417
421
bool
theAlmostUnweighted
;
422
426
unsigned
long
maximumExceeds
;
427
431
double
maximumExceededBy
;
432
438
double
correctWeights
;
439
445
double
theMaxEnhancement
;
446
450
bool
didReadGrids
;
451
455
bool
theParallelIntegration
;
456
460
unsigned
int
theIntegratePerJob
;
461
465
unsigned
int
theIntegrationJobs
;
466
470
unsigned
int
theIntegrationJobsCreated
;
471
475
bool
justAfterIntegrate
;
476
480
bool
theWriteGridsOnFinish
;
481
482
private
:
483
488
GeneralSampler
& operator=(
const
GeneralSampler
&) =
delete
;
489
490
};
491
492
}
493
494
#endif
/* Herwig_GeneralSampler_H */
Herwig::GeneralSampler
A GeneralSampler class.
Definition:
GeneralSampler.h:31
ThePEG::PersistentIStream
Herwig::GeneralSampler::gotCrossSections
bool gotCrossSections
True, if currentCrossSections has been called since the last call to generate.
Definition:
GeneralSampler.h:354
Herwig::GeneralSampler::theVerbose
bool theVerbose
Whether or not additional information should be printed to cout.
Definition:
GeneralSampler.h:305
Herwig::GeneralSampler::lastSampler
void lastSampler(Ptr< BinSampler >::tptr s)
Set the last selected bin sampler.
Definition:
GeneralSampler.h:201
Herwig::GeneralSampler::almostUnweighted
virtual bool almostUnweighted() const
Return true if this sampler is generating almost unweighted events.
Definition:
GeneralSampler.h:154
Herwig::GeneralSampler::theBinSampler
Ptr< BinSampler >::ptr theBinSampler
The bin sampler to use.
Definition:
GeneralSampler.h:315
ThePEG::PersistentOStream
Herwig::GeneralSampler::theIntegratedXSec
CrossSection theIntegratedXSec
The integrated cross section.
Definition:
GeneralSampler.h:330
Herwig::GeneralSampler::theIntegratedXSecErr
CrossSection theIntegratedXSecErr
The integrated cross section error.
Definition:
GeneralSampler.h:335
ThePEG::IBPtr
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
Herwig::GeneralSampler::theIntegrationJobs
unsigned int theIntegrationJobs
The maximum number of integration jobs to be created.
Definition:
GeneralSampler.h:465
Herwig::GeneralSampler::samplers
map< double, Ptr< BinSampler >::ptr > & samplers()
Access the samplers.
Definition:
GeneralSampler.h:196
ThePEG::Rebinder
Herwig::GeneralSampler::theParallelIntegration
bool theParallelIntegration
True, if parallel subprocess integration should be enabled.
Definition:
GeneralSampler.h:455
ThePEG
Herwig::GeneralSampler::theUpdateAfter
size_t theUpdateAfter
The number of events after which cross sections should truly be updated.
Definition:
GeneralSampler.h:342
Herwig::GeneralSampler::maxXSec
virtual CrossSection maxXSec() const
Return the overestimated integrated cross section.
Definition:
GeneralSampler.h:97
Herwig::GeneralSampler::sumWeights2
virtual double sumWeights2() const
Return the sum of the weights squaredreturned by generate() so far (of the events that were not rejet...
Definition:
GeneralSampler.h:113
Herwig::GeneralSampler::weighted
bool weighted() const
True if we should do weighted events.
Definition:
GeneralSampler.h:149
Herwig::GeneralSampler::grids
XML::Element & grids()
Access the XML element containing the grids.
Definition:
GeneralSampler.h:166
Herwig::GeneralSampler::theMaxWeight
double theMaxWeight
The maximum weight encountered.
Definition:
GeneralSampler.h:379
Herwig::GeneralSampler::runCombinationData
bool runCombinationData
True, if information for combining unnormalized runs should be printed out.
Definition:
GeneralSampler.h:416
Herwig::GeneralSampler::didReadGrids
bool didReadGrids
True, if grids have already been read.
Definition:
GeneralSampler.h:450
Herwig::GeneralSampler::theMaxEnhancement
double theMaxEnhancement
Enhancement factor to the maximum weight.
Definition:
GeneralSampler.h:445
Herwig::GeneralSampler::theSamplers
map< double, Ptr< BinSampler >::ptr > theSamplers
The selector map for the bin samplers.
Definition:
GeneralSampler.h:320
Herwig::GeneralSampler::theLastSampler
Ptr< BinSampler >::tptr theLastSampler
The last selected bin sampler.
Definition:
GeneralSampler.h:325
Herwig::GeneralSampler::theIntegrationJobsCreated
unsigned int theIntegrationJobsCreated
The number of integration jobs which were actually created.
Definition:
GeneralSampler.h:470
Herwig::GeneralSampler::theAttempts
double theAttempts
The number of attempts.
Definition:
GeneralSampler.h:369
Herwig::GeneralSampler::justAfterIntegrate
bool justAfterIntegrate
Indicate that initialization is only reading a grid.
Definition:
GeneralSampler.h:475
Herwig::GeneralSampler::theAddUpSamplers
bool theAddUpSamplers
True, if cross sections are to be combined from each sampler individually.
Definition:
GeneralSampler.h:385
ThePEG::SamplerBase
Herwig::GeneralSampler::maximumExceeds
unsigned long maximumExceeds
Number of points which exceeded the maximum.
Definition:
GeneralSampler.h:426
ThePEG::SamplerBase::attempts
virtual double attempts() const
Herwig::GeneralSampler::theWriteGridsOnFinish
bool theWriteGridsOnFinish
True, if grids should be written at the end of a run.
Definition:
GeneralSampler.h:480
Herwig::GeneralSampler::theMinSelection
double theMinSelection
A minimum selection probability for each sampler.
Definition:
GeneralSampler.h:410
Herwig::GeneralSampler::theGlobalMaximumWeight
bool theGlobalMaximumWeight
True, if the global maximum weight should be used as reference.
Definition:
GeneralSampler.h:393
Herwig::GeneralSampler::theSumWeights2
double theSumWeights2
The sum of weights squared.
Definition:
GeneralSampler.h:364
Herwig::GeneralSampler::integrationJobsCreated
unsigned int integrationJobsCreated()
Return the number of integration jobs which were actually created.
Definition:
GeneralSampler.h:181
ThePEG::SamplerBase::maxXSec
virtual CrossSection maxXSec() const
Herwig::GeneralSampler::maximumExceededBy
double maximumExceededBy
The average relative deviation from the maximum weight.
Definition:
GeneralSampler.h:431
Herwig::GeneralSampler::attempts
virtual double attempts() const
Return the number of attempts.
Definition:
GeneralSampler.h:118
Herwig::GeneralSampler::isSampling
bool isSampling
True, if we are generating events.
Definition:
GeneralSampler.h:405
Herwig::GeneralSampler::lastBin
virtual int lastBin() const
If the sampler is able to sample several different functions separately, this function should return ...
Definition:
GeneralSampler.h:74
Herwig::GeneralSampler::grids
const XML::Element & grids() const
Return the XML element containing the grids.
Definition:
GeneralSampler.h:161
Herwig::GeneralSampler::samplers
const map< double, Ptr< BinSampler >::ptr > & samplers() const
Return the samplers.
Definition:
GeneralSampler.h:134
Herwig::GeneralSampler::theIntegratePerJob
unsigned int theIntegratePerJob
The number of subprocesses to integrate per job.
Definition:
GeneralSampler.h:460
XML::Element
Element represents a (tree of) XML elements.
Definition:
Element.h:56
Herwig::GeneralSampler::integratedXSecErr
virtual CrossSection integratedXSecErr() const
Return the error on the total integrated cross section determined from the Monte Carlo sampling so fa...
Definition:
GeneralSampler.h:89
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::GeneralSampler::lastSampler
Ptr< BinSampler >::tptr lastSampler() const
Return the last selected bin sampler.
Definition:
GeneralSampler.h:144
Herwig::GeneralSampler::theAlmostUnweighted
bool theAlmostUnweighted
True, if we should perform an almost unweighted sampling.
Definition:
GeneralSampler.h:421
Herwig::GeneralSampler::theAccepts
double theAccepts
The number of accepts.
Definition:
GeneralSampler.h:374
Herwig::GeneralSampler::integratedXSec
virtual CrossSection integratedXSec() const
Return the total integrated cross section determined from the Monte Carlo sampling so far...
Definition:
GeneralSampler.h:80
Herwig::GeneralSampler::accepts
double accepts() const
Return the number of accepts.
Definition:
GeneralSampler.h:127
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
Herwig::GeneralSampler::theFlatSubprocesses
bool theFlatSubprocesses
True, if subprocesses should be selected flat.
Definition:
GeneralSampler.h:400
Herwig::GeneralSampler::correctWeights
double correctWeights
The correct cross section as one would exspect with almostUnweighted.
Definition:
GeneralSampler.h:438
Herwig::GeneralSampler::binSampler
Ptr< BinSampler >::ptr binSampler() const
Return the bin sampler.
Definition:
GeneralSampler.h:139
ThePEG::IVector
vector< IBPtr > IVector
Herwig::GeneralSampler::crossSectionCalls
size_t crossSectionCalls
The number of calls to currentCrossSections since the last update.
Definition:
GeneralSampler.h:348
Herwig::GeneralSampler::sumWeights
virtual double sumWeights() const
Return the sum of the weights returned by generate() so far (of the events that were not rejeted)...
Definition:
GeneralSampler.h:107
Herwig::GeneralSampler::theSumWeights
double theSumWeights
The sum of weights.
Definition:
GeneralSampler.h:359
Herwig::GeneralSampler::theGrids
XML::Element theGrids
The XML element containing the grids.
Definition:
GeneralSampler.h:310
Generated on Sat Apr 11 2020 14:50:29 for Herwig by
1.8.13