herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.2.1
Sampling
BinSampler.h
1
// -*- C++ -*-
2
//
3
// BinSampler.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_BinSampler_H
10
#define Herwig_BinSampler_H
11
//
12
// This is the declaration of the BinSampler class.
13
//
14
15
#include "ThePEG/Handlers/StandardEventHandler.h"
16
#include "ThePEG/Utilities/Exception.h"
17
#include "ThePEG/Repository/UseRandom.h"
18
19
#include "MultiIterationStatistics.h"
20
#include "Remapper.h"
21
22
namespace
Herwig
{
23
24
using namespace
ThePEG
;
25
26
class
GeneralSampler;
27
38
class
BinSampler
:
public
Herwig::MultiIterationStatistics
{
39
40
public
:
41
47
BinSampler
();
48
52
virtual
~
BinSampler
();
54
55
public
:
56
60
Ptr<BinSampler>::ptr
cloneMe
()
const
{
61
return
dynamic_ptr_cast<Ptr<BinSampler>::ptr>(clone());
62
}
63
64
public
:
65
69
double
evaluate(vector<double> p,
70
bool
remap =
true
);
71
76
double
bias
()
const
{
return
theBias; }
77
81
void
bias
(
double
b) { theBias = b; }
82
86
void
eventHandler
(tStdEHPtr eh) { theEventHandler = eh; }
87
91
tStdEHPtr
eventHandler
()
const
{
return
theEventHandler; }
92
96
void
sampler(Ptr<GeneralSampler>::tptr);
97
101
Ptr<GeneralSampler>::tptr sampler()
const
;
102
106
int
bin
()
const
{
return
theBin; }
107
111
void
bin
(
int
b) { theBin = b; }
112
116
string
process()
const
;
117
121
string
shortprocess()
const
;
122
126
string
id()
const
;
127
131
const
vector<double>&
lastPoint
()
const
{
return
theLastPoint; }
132
136
vector<double>&
lastPoint
() {
return
theLastPoint; }
137
141
double
referenceWeight
()
const
{
return
theReferenceWeight; }
142
146
void
referenceWeight
(
double
w) { theReferenceWeight = w; }
147
154
virtual
bool
canUnweight
()
const
{
return
true
; }
155
161
virtual
bool
adaptsOnTheFly
()
const
{
return
false
; }
162
167
virtual
bool
compensating
()
const
{
return
false
; }
168
172
bool
weighted
()
const
{
return
theWeighted; }
173
177
void
doWeighted
(
bool
yes =
true
) { theWeighted = yes; }
178
182
struct
NextIteration
{};
183
188
virtual
double
generate
();
189
193
void
fillRemappers(
bool
progress);
194
198
void
saveRemappers()
const
;
199
203
void
saveIntegrationData()
const
;
204
208
virtual
void
saveGrid
()
const
{}
209
213
void
readIntegrationData();
214
218
void
setupRemappers(
bool
progress);
219
224
void
runIteration(
unsigned
long
n,
bool
progress);
225
229
virtual
void
adapt
() {}
230
234
virtual
void
initialize(
bool
progress);
235
239
bool
initialized
()
const
{
return
theInitialized; }
240
244
void
isInitialized
() { theInitialized =
true
; }
245
249
bool
integrated
()
const
{
return
theIntegrated; }
250
254
bool
remappersFilled
()
const
{
return
theRemappersFilled; }
255
259
virtual
bool
existsGrid
()
const
{
return
false
; }
260
264
bool
hasGrids
()
const
{
return
theHasGrids; }
265
269
void
didReadGrids
() { theHasGrids =
true
; }
270
274
virtual
void
finalize(
bool
);
275
280
virtual
CrossSection
integratedXSec
()
const
{
281
return
averageWeight()*nanobarn;
282
}
283
288
virtual
CrossSection
integratedXSecErr
()
const
{
289
return
sqrt
(abs(averageWeightVariance()))*nanobarn;
290
}
291
297
struct
RandomNumberHistogram
{
298
302
double
lower
;
303
307
map<double,double >
bins
;
308
309
map<double,double > binsw1;
313
RandomNumberHistogram
(
double
low = 0.0,
314
double
up = 1.,
315
unsigned
int
nbins = 20);
316
320
void
book
(
double
inv,
double
weight) {
321
map<double,double>::iterator b = bins.upper_bound(inv);
322
if
( b == bins.end() )
return
;
323
b->second = b->second+weight;
324
map<double,double>::iterator b2 = binsw1.upper_bound(inv);
325
if
( b2 == binsw1.end() )
return
;
326
b2->second = b2->second+1.;
327
328
}
329
333
void
dump(
const
std::string& folder,
const
std::string& prefix,
const
std::string& process,
const
int
NR)
const
;
334
335
336
};
337
338
typedef
pair<string,size_t > RandomNumberIndex;
339
340
map<RandomNumberIndex,pair<RandomNumberHistogram,double> > RandomNumberHistograms;
341
342
public
:
343
347
int
dimension
()
const
{
return
theEventHandler->nDim(bin()); }
348
352
unsigned
long
initialPoints
()
const
{
return
theInitialPoints; }
353
357
void
initialPoints
(
unsigned
long
n) { theInitialPoints = n; }
358
362
size_t
nIterations
()
const
{
return
theNIterations; }
363
367
void
nIterations
(
size_t
n) { theNIterations = n; }
368
373
void
enhancementFactor
(
double
f) { theEnhancementFactor = f; }
374
379
double
enhancementFactor
()
const
{
return
theEnhancementFactor; }
380
384
string
randomNumberString
()
const
{
return
theRandomNumbers;}
385
393
double
kappa
()
const
{
return
theKappa;}
394
395
public
:
396
403
void
persistentOutput(
PersistentOStream
& os)
const
;
404
410
void
persistentInput(
PersistentIStream
& is,
int
version);
412
419
static
void
Init();
420
421
protected
:
422
429
virtual
IBPtr
clone()
const
;
430
435
virtual
IBPtr
fullclone()
const
;
437
438
439
// If needed, insert declarations of virtual function defined in the
440
// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
441
442
private
:
443
447
double
theBias
;
448
452
bool
theWeighted
;
453
457
unsigned
long
theInitialPoints
;
458
462
size_t
theNIterations
;
463
467
double
theEnhancementFactor
;
468
473
bool
theNonZeroInPresampling
;
474
480
bool
theHalfPoints
;
481
487
int
theMaxNewMax
;
488
492
double
theReferenceWeight
;
493
497
int
theBin
;
498
502
bool
theInitialized
;
503
507
vector<double>
theLastPoint
;
508
512
tStdEHPtr
theEventHandler
;
513
517
Ptr<GeneralSampler>::tptr
theSampler
;
518
522
string
theRandomNumbers
;
523
527
map<size_t,Remapper>
remappers
;
528
532
unsigned
long
theRemapperPoints
;
533
537
bool
theRemapChannelDimension
;
538
542
unsigned
long
theLuminosityMapperBins
;
543
547
unsigned
long
theGeneralMapperBins
;
548
552
double
theRemapperMinSelection
;
553
557
bool
theIntegrated
;
558
562
bool
theRemappersFilled
;
563
567
bool
theHasGrids
;
568
569
570
578
double
theKappa
;
579
580
private
:
581
586
BinSampler
& operator=(
const
BinSampler
&) =
delete
;
587
588
};
589
590
}
591
592
#endif
/* Herwig_BinSampler_H */
Herwig::BinSampler::theInitialized
bool theInitialized
Wether or not this sampler has already been initialized.
Definition:
BinSampler.h:502
Herwig::BinSampler::theLuminosityMapperBins
unsigned long theLuminosityMapperBins
The number of bins to be used for luminosity dimensions.
Definition:
BinSampler.h:542
Herwig::BinSampler::RandomNumberHistogram::lower
double lower
The lower bound.
Definition:
BinSampler.h:302
Herwig::BinSampler::saveGrid
virtual void saveGrid() const
Save grid data.
Definition:
BinSampler.h:208
Herwig::BinSampler::RandomNumberHistogram::bins
map< double, double > bins
The bins, indexed by upper bound.
Definition:
BinSampler.h:307
Herwig::BinSampler::theWeighted
bool theWeighted
True, if weighted events should be generated.
Definition:
BinSampler.h:452
Herwig::BinSampler::theHalfPoints
bool theHalfPoints
Switch to require that we get half of the points in each iteration below the maximum weight of the it...
Definition:
BinSampler.h:480
Herwig::BinSampler::adapt
virtual void adapt()
Adapt this sampler after an iteration has been run.
Definition:
BinSampler.h:229
ThePEG::PersistentIStream
sqrt
double sqrt(int x)
Herwig::BinSampler::theIntegrated
bool theIntegrated
True, if integration has already be performed.
Definition:
BinSampler.h:557
Herwig::BinSampler::compensating
virtual bool compensating() const
If this sampler features a compensation algorithm, return true if more events need to be generated to...
Definition:
BinSampler.h:167
Herwig::BinSampler::integrated
bool integrated() const
Return true, if integration has already been performed.
Definition:
BinSampler.h:249
Herwig::BinSampler::referenceWeight
double referenceWeight() const
Return the reference weight to be used.
Definition:
BinSampler.h:141
Herwig::BinSampler::theRemapChannelDimension
bool theRemapChannelDimension
True if channels should get a remapper.
Definition:
BinSampler.h:537
Herwig::BinSampler::didReadGrids
void didReadGrids()
Indicate that this sampler has already read grid data.
Definition:
BinSampler.h:269
Herwig::BinSampler::theBin
int theBin
The bin to be sampled.
Definition:
BinSampler.h:497
Herwig::BinSampler::bias
void bias(double b)
Set the bias with which this sampler is selected.
Definition:
BinSampler.h:81
Herwig::BinSampler::referenceWeight
void referenceWeight(double w)
Set the reference weight to be used.
Definition:
BinSampler.h:146
ThePEG::PersistentOStream
Herwig::BinSampler::hasGrids
bool hasGrids() const
Return true, if this sampler has already read grid data.
Definition:
BinSampler.h:264
Herwig::BinSampler::theReferenceWeight
double theReferenceWeight
The reference weight to be used.
Definition:
BinSampler.h:492
ThePEG::IBPtr
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
Herwig::BinSampler::theHasGrids
bool theHasGrids
True, if this sampler has already read grid data.
Definition:
BinSampler.h:567
Herwig::BinSampler::theEnhancementFactor
double theEnhancementFactor
Factor to enhance the number of points for the next iteration.
Definition:
BinSampler.h:467
Herwig::BinSampler::enhancementFactor
double enhancementFactor() const
Return the factor to enhance the number of points for the next iteration.
Definition:
BinSampler.h:379
Herwig::BinSampler::theRemappersFilled
bool theRemappersFilled
True, if remappers have been set up.
Definition:
BinSampler.h:562
ThePEG
Herwig::BinSampler::theLastPoint
vector< double > theLastPoint
The last generated point.
Definition:
BinSampler.h:507
Herwig::BinSampler::integratedXSecErr
virtual CrossSection integratedXSecErr() const
Return the error on the total integrated cross section determined from the Monte Carlo sampling so fa...
Definition:
BinSampler.h:288
Herwig::BinSampler::theMaxNewMax
int theMaxNewMax
The maximum number of allowed new maxima, in combination with HalfPoints, in order to prevent unstabl...
Definition:
BinSampler.h:487
Herwig::BinSampler::bin
void bin(int b)
Set the bin.
Definition:
BinSampler.h:111
Herwig::BinSampler::NextIteration
Exception to be thrown if cross section information should be updated.
Definition:
BinSampler.h:182
Herwig::BinSampler::canUnweight
virtual bool canUnweight() const
Return true, if this sampler can provide unweighted events; if the proposal density is not an overest...
Definition:
BinSampler.h:154
Herwig::BinSampler::theRemapperPoints
unsigned long theRemapperPoints
The number of points to be used for initial filling of the remappers.
Definition:
BinSampler.h:532
Herwig::BinSampler::randomNumberString
string randomNumberString() const
Return the folder for the random number plots.
Definition:
BinSampler.h:384
Herwig::BinSampler::theEventHandler
tStdEHPtr theEventHandler
The event handler to be used.
Definition:
BinSampler.h:512
Herwig::BinSampler::initialPoints
unsigned long initialPoints() const
Return the number of points to be used for initial integration.
Definition:
BinSampler.h:352
Herwig::BinSampler::kappa
double kappa() const
In the AlmostUnweighted mode we do not need to unweight the events to the reference weight...
Definition:
BinSampler.h:393
Herwig::BinSampler::theKappa
double theKappa
In the AlmostUnweighted mode we do not need to unweight the events to the reference weight...
Definition:
BinSampler.h:578
Herwig::BinSampler::theNIterations
size_t theNIterations
The number of iterations to be considered for initialization.
Definition:
BinSampler.h:462
Herwig::BinSampler::remappers
map< size_t, Remapper > remappers
Remapper objects indexed by dimension.
Definition:
BinSampler.h:527
Herwig::BinSampler::initialized
bool initialized() const
Return true, if this sampler has already been initialized.
Definition:
BinSampler.h:239
Herwig::BinSampler
BinSampler samples XCombs bins. This default implementation performs flat MC integration.
Definition:
BinSampler.h:38
Herwig::BinSampler::RandomNumberHistogram
Define the key for the collinear subtraction data.
Definition:
BinSampler.h:297
Herwig::MultiIterationStatistics
Monte Carlo statistics for multiple iterations.
Definition:
MultiIterationStatistics.h:27
Herwig::BinSampler::theRandomNumbers
string theRandomNumbers
Folder for the random number plots.
Definition:
BinSampler.h:522
Herwig::BinSampler::doWeighted
void doWeighted(bool yes=true)
Indicate that weighted events should be generated.
Definition:
BinSampler.h:177
Herwig::BinSampler::lastPoint
const vector< double > & lastPoint() const
Return the last generated point.
Definition:
BinSampler.h:131
Herwig::BinSampler::RandomNumberHistogram::book
void book(double inv, double weight)
Book an event.
Definition:
BinSampler.h:320
Herwig::BinSampler::existsGrid
virtual bool existsGrid() const
Return true, if grid data exists for this sampler.
Definition:
BinSampler.h:259
Herwig::BinSampler::theInitialPoints
unsigned long theInitialPoints
The number of points to use for initial integration.
Definition:
BinSampler.h:457
Herwig::BinSampler::lastPoint
vector< double > & lastPoint()
Access the last generated point.
Definition:
BinSampler.h:136
Herwig::BinSampler::theRemapperMinSelection
double theRemapperMinSelection
The minimum selection probability for remapper bins.
Definition:
BinSampler.h:552
Herwig::BinSampler::theGeneralMapperBins
unsigned long theGeneralMapperBins
The number of bins to be used for any other dimension.
Definition:
BinSampler.h:547
Herwig::BinSampler::eventHandler
tStdEHPtr eventHandler() const
Return the event handler.
Definition:
BinSampler.h:91
Herwig::BinSampler::initialPoints
void initialPoints(unsigned long n)
Set the number of points to be used for initial integration.
Definition:
BinSampler.h:357
Herwig::BinSampler::isInitialized
void isInitialized()
Indicate that this sampler has already been initialized.
Definition:
BinSampler.h:244
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::BinSampler::theNonZeroInPresampling
bool theNonZeroInPresampling
Switch to count only non zero weights in presampling.
Definition:
BinSampler.h:473
Herwig::BinSampler::theSampler
Ptr< GeneralSampler >::tptr theSampler
The containing sampler.
Definition:
BinSampler.h:517
Herwig::BinSampler::adaptsOnTheFly
virtual bool adaptsOnTheFly() const
Return true, if this sampler adapts on the fly while generating events.
Definition:
BinSampler.h:161
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
Herwig::BinSampler::integratedXSec
virtual CrossSection integratedXSec() const
Return the total integrated cross section determined from the Monte Carlo sampling so far...
Definition:
BinSampler.h:280
Herwig::BinSampler::nIterations
size_t nIterations() const
Return the number of iterations to be considered for initialization.
Definition:
BinSampler.h:362
Herwig::BinSampler::bin
int bin() const
Return the bin.
Definition:
BinSampler.h:106
Herwig::BinSampler::theBias
double theBias
The bias with which this sampler is selected.
Definition:
BinSampler.h:447
Herwig::BinSampler::eventHandler
void eventHandler(tStdEHPtr eh)
Set the event handler.
Definition:
BinSampler.h:86
Herwig::BinSampler::cloneMe
Ptr< BinSampler >::ptr cloneMe() const
Clone this object.
Definition:
BinSampler.h:60
Herwig::BinSampler::nIterations
void nIterations(size_t n)
Set the number of iterations to be considered for initialization.
Definition:
BinSampler.h:367
Herwig::BinSampler::enhancementFactor
void enhancementFactor(double f)
Set the factor to enhance the number of points for the next iteration.
Definition:
BinSampler.h:373
Herwig::BinSampler::dimension
int dimension() const
Return the dimension.
Definition:
BinSampler.h:347
Herwig::BinSampler::bias
double bias() const
Return the bias with which this sampler is selected.
Definition:
BinSampler.h:76
Herwig::BinSampler::remappersFilled
bool remappersFilled() const
Return true, if remappers have been set up.
Definition:
BinSampler.h:254
Herwig::BinSampler::weighted
bool weighted() const
Return true, if weighted events should be generated.
Definition:
BinSampler.h:172
Generated on Sat Apr 11 2020 14:50:28 for Herwig by
1.8.13