#include <FastSimulation/Utilities/interface/GaussianTail.h>
Public Member Functions | |
GaussianTail (const RandomEngine *engine, double sigma=1., double threshold=2.) | |
void | setParameters (double sigma, double threshold) |
double | shoot () const |
~GaussianTail () | |
Private Attributes | |
const RandomEngine * | random |
double | s_ |
double | sigma_ |
double | ssquare_ |
double | threshold_ |
Definition at line 10 of file GaussianTail.h.
GaussianTail::GaussianTail | ( | const RandomEngine * | engine, | |
double | sigma = 1. , |
|||
double | threshold = 2. | |||
) |
Definition at line 5 of file GaussianTail.cc.
References s_, sigma_, ssquare_, and threshold_.
00006 : 00007 random(engine), 00008 sigma_(sigma), 00009 threshold_(threshold) 00010 { 00011 s_=threshold_/sigma_; 00012 ssquare_ = s_ * s_; 00013 }
GaussianTail::~GaussianTail | ( | ) |
void GaussianTail::setParameters | ( | double | sigma, | |
double | threshold | |||
) | [inline] |
Definition at line 16 of file GaussianTail.h.
References s_, sigma_, ssquare_, and threshold_.
00017 { 00018 sigma_= sigma; 00019 threshold_ = threshold; 00020 s_=threshold_/sigma_; 00021 ssquare_ = s_ * s_; 00022 };
double GaussianTail::shoot | ( | ) | const |
Definition at line 20 of file GaussianTail.cc.
References RandomEngine::flatShoot(), RandomEngine::gaussShoot(), funct::log(), random, s_, sigma_, funct::sqrt(), ssquare_, v, and x.
Referenced by HcalRecHitsMaker::noisifySubdet(), and EcalPreshowerRecHitsMaker::noisifySubdet().
00021 { 00022 // in the zero suppresion case, s is usually >2 00023 if(s_>1.) 00024 { 00025 /* Use the "supertail" deviates from the last two steps 00026 * of Marsaglia's rectangle-wedge-tail method, as described 00027 * in Knuth, v2, 3rd ed, pp 123-128. (See also exercise 11, p139, 00028 * and the solution, p586.) 00029 */ 00030 00031 double u, v, x; 00032 00033 do 00034 { 00035 u = random->flatShoot(); 00036 do 00037 { 00038 v = random->flatShoot(); 00039 } 00040 while (v == 0.0); 00041 x = std::sqrt (ssquare_ - 2 * std::log (v)); 00042 } 00043 while (x * u > s_); 00044 return x * sigma_; 00045 } 00046 else 00047 { 00048 /* For small s, use a direct rejection method. The limit s < 1 00049 can be adjusted to optimise the overall efficiency 00050 */ 00051 00052 double x; 00053 00054 do 00055 { 00056 x = random->gaussShoot(); 00057 } 00058 while (x < s_); 00059 return x * sigma_; 00060 } 00061 }
const RandomEngine* GaussianTail::random [private] |
double GaussianTail::s_ [private] |
Definition at line 31 of file GaussianTail.h.
Referenced by GaussianTail(), setParameters(), and shoot().
double GaussianTail::sigma_ [private] |
Definition at line 29 of file GaussianTail.h.
Referenced by GaussianTail(), setParameters(), and shoot().
double GaussianTail::ssquare_ [private] |
Definition at line 32 of file GaussianTail.h.
Referenced by GaussianTail(), setParameters(), and shoot().
double GaussianTail::threshold_ [private] |