#include <SimGeneral/NoiseGenerators/interface/GaussianTailNoiseGenerator.h>
Public Member Functions | |
GaussianTailNoiseGenerator (CLHEP::HepRandomEngine &eng) | |
void | generate (int NumberOfchannels, float threshold, float noiseRMS, std::vector< std::pair< int, float > > &) |
void | generate (int NumberOfchannels, float threshold, float noiseRMS, std::map< int, float > &theMap) |
double | generate_gaussian_tail (const double, const double) |
void | generateRaw (int NumberOfchannels, float noiseRMS, std::vector< std::pair< int, float > > &) |
Private Attributes | |
CLHEP::RandFlat | flatDistribution_ |
CLHEP::RandGaussQ | gaussDistribution_ |
CLHEP::RandPoissonQ | poissonDistribution_ |
The generated noise :
Initial author : Veronique Lefebure 08.10.98
according to the FORTRAN code tgreset.F from Pascal Vanlaer
Fills in a map < channel number, generated noise >
Definition at line 28 of file GaussianTailNoiseGenerator.h.
GaussianTailNoiseGenerator::GaussianTailNoiseGenerator | ( | CLHEP::HepRandomEngine & | eng | ) |
Definition at line 11 of file GaussianTailNoiseGenerator.cc.
00011 : 00012 gaussDistribution_(eng), 00013 poissonDistribution_(eng), 00014 flatDistribution_(eng) 00015 { 00016 }
void GaussianTailNoiseGenerator::generate | ( | int | NumberOfchannels, | |
float | threshold, | |||
float | noiseRMS, | |||
std::vector< std::pair< int, float > > & | theVector | |||
) |
Definition at line 48 of file GaussianTailNoiseGenerator.cc.
References TestMuL1L2Filter_cff::cerr, flatDistribution_, generate_gaussian_tail(), i, int, and poissonDistribution_.
00051 { 00052 // Compute number of channels with noise above threshold 00053 // Gaussian tail probability 00054 gsl_sf_result result; 00055 int status = gsl_sf_erf_Q_e(threshold, &result); 00056 00057 if (status != 0) std::cerr<<"GaussianTailNoiseGenerator::could not compute gaussian tail probability for the threshold chosen"<<std::endl; 00058 00059 double probabilityLeft = result.val; 00060 double meanNumberOfNoisyChannels = probabilityLeft * NumberOfchannels; 00061 int numberOfNoisyChannels = poissonDistribution_.fire(meanNumberOfNoisyChannels); 00062 00063 theVector.reserve(numberOfNoisyChannels); 00064 float lowLimit = threshold * noiseRMS; 00065 for (int i = 0; i < numberOfNoisyChannels; i++) { 00066 00067 // Find a random channel number 00068 int theChannelNumber = (int)flatDistribution_.fire(NumberOfchannels); 00069 00070 // Find random noise value 00071 double noise = generate_gaussian_tail(lowLimit, noiseRMS); 00072 00073 // Fill in the vector 00074 theVector.push_back(std::pair<int, float>(theChannelNumber, noise)); 00075 } 00076 }
void GaussianTailNoiseGenerator::generate | ( | int | NumberOfchannels, | |
float | threshold, | |||
float | noiseRMS, | |||
std::map< int, float > & | theMap | |||
) |
Referenced by SiPixelDigitizerAlgorithm::add_noise(), and SiGaussianTailNoiseAdder::addNoise().
double GaussianTailNoiseGenerator::generate_gaussian_tail | ( | const | double, | |
const | double | |||
) |
Definition at line 91 of file GaussianTailNoiseGenerator.cc.
References flatDistribution_, gaussDistribution_, funct::log(), s, funct::sqrt(), v, and x.
Referenced by generate().
00091 { 00092 /* Returns a gaussian random variable larger than a 00093 * This implementation does one-sided upper-tailed deviates. 00094 */ 00095 00096 double s = a/sigma; 00097 00098 if (s < 1){ 00099 /* 00100 For small s, use a direct rejection method. The limit s < 1 00101 can be adjusted to optimise the overall efficiency 00102 */ 00103 double x; 00104 00105 do{ 00106 x = gaussDistribution_.fire(0.,1.0); 00107 } 00108 while (x < s); 00109 return x * sigma; 00110 00111 }else{ 00112 00113 /* Use the "supertail" deviates from the last two steps 00114 * of Marsaglia's rectangle-wedge-tail method, as described 00115 * in Knuth, v2, 3rd ed, pp 123-128. (See also exercise 11, p139, 00116 * and the solution, p586.) 00117 */ 00118 00119 double u, v, x; 00120 00121 do{ 00122 u = flatDistribution_.fire(); 00123 do{ 00124 v = flatDistribution_.fire(); 00125 }while (v == 0.0); 00126 x = sqrt(s * s - 2 * log(v)); 00127 } 00128 while (x * u > s); 00129 return x * sigma; 00130 } 00131 }
void GaussianTailNoiseGenerator::generateRaw | ( | int | NumberOfchannels, | |
float | noiseRMS, | |||
std::vector< std::pair< int, float > > & | theVector | |||
) |
Definition at line 78 of file GaussianTailNoiseGenerator.cc.
References gaussDistribution_, and i.
Referenced by SiGaussianTailNoiseAdder::createRaw().
00080 { 00081 theVector.reserve(NumberOfchannels); 00082 for (int i = 0; i < NumberOfchannels; i++) { 00083 // Find random noise value 00084 float noise = gaussDistribution_.fire(0.,noiseRMS); 00085 // Fill in the vector 00086 theVector.push_back(std::pair<int, float>(i,noise)); 00087 } 00088 }
CLHEP::RandFlat GaussianTailNoiseGenerator::flatDistribution_ [private] |
Definition at line 56 of file GaussianTailNoiseGenerator.h.
Referenced by generate(), and generate_gaussian_tail().
CLHEP::RandGaussQ GaussianTailNoiseGenerator::gaussDistribution_ [private] |
Definition at line 54 of file GaussianTailNoiseGenerator.h.
Referenced by generate_gaussian_tail(), and generateRaw().
CLHEP::RandPoissonQ GaussianTailNoiseGenerator::poissonDistribution_ [private] |