Main Page
Namespaces
Classes
Package Documentation
FastSimulation
Utilities
src
GaussianTail.cc
Go to the documentation of this file.
1
#include "
FastSimulation/Utilities/interface/GaussianTail.h
"
2
#include "
FastSimulation/Utilities/interface/RandomEngineAndDistribution.h
"
3
4
#include <cmath>
5
GaussianTail::GaussianTail
(
double
sigma,
double
threshold
) :
6
sigma_(sigma),
7
threshold_(threshold)
8
{
9
s_
=
threshold_
/
sigma_
;
10
ssquare_
=
s_
*
s_
;
11
}
12
13
GaussianTail::~GaussianTail
()
14
{
15
;
16
}
17
18
double
GaussianTail::shoot
(
RandomEngineAndDistribution
const
*
random
)
const
19
{
20
// in the zero suppresion case, s is usually >2
21
if
(
s_
>1.)
22
{
23
/* Use the "supertail" deviates from the last two steps
24
* of Marsaglia's rectangle-wedge-tail method, as described
25
* in Knuth, v2, 3rd ed, pp 123-128. (See also exercise 11, p139,
26
* and the solution, p586.)
27
*/
28
29
double
u,
v
,
x
;
30
31
do
32
{
33
u = random->
flatShoot
();
34
do
35
{
36
v = random->
flatShoot
();
37
}
38
while
(v == 0.0);
39
x =
std::sqrt
(
ssquare_
- 2 *
std::log
(v));
40
}
41
while
(x * u >
s_
);
42
return
x *
sigma_
;
43
}
44
else
45
{
46
/* For small s, use a direct rejection method. The limit s < 1
47
can be adjusted to optimise the overall efficiency
48
*/
49
50
double
x
;
51
52
do
53
{
54
x = random->
gaussShoot
();
55
}
56
while
(x <
s_
);
57
return
x *
sigma_
;
58
}
59
}
GaussianTail::s_
double s_
Definition:
GaussianTail.h:28
GaussianTail::threshold_
double threshold_
Definition:
GaussianTail.h:27
RandomEngineAndDistribution::flatShoot
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition:
RandomEngineAndDistribution.h:29
random
TRandom random
Definition:
MVATrainer.cc:138
findQualityFiles.v
v
Definition:
findQualityFiles.py:177
GaussianTail::shoot
double shoot(RandomEngineAndDistribution const *) const
Definition:
GaussianTail.cc:18
electronIdCutBased_cfi.threshold
threshold
Definition:
electronIdCutBased_cfi.py:6
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:18
GaussianTail::GaussianTail
GaussianTail(double sigma=1., double threshold=2.)
Definition:
GaussianTail.cc:5
GaussianTail::sigma_
double sigma_
Definition:
GaussianTail.h:26
cmsBatch.log
log
Definition:
cmsBatch.py:341
RandomEngineAndDistribution::gaussShoot
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition:
RandomEngineAndDistribution.h:33
RandomEngineAndDistribution.h
GaussianTail::ssquare_
double ssquare_
Definition:
GaussianTail.h:29
GaussianTail.h
GaussianTail::~GaussianTail
~GaussianTail()
Definition:
GaussianTail.cc:13
DDAxes::x
RandomEngineAndDistribution
Definition:
RandomEngineAndDistribution.h:18
Generated for CMSSW Reference Manual by
1.8.11