2 #include "CLHEP/Random/RandPoissonQ.h"
3 #include "CLHEP/Random/RandGaussQ.h"
4 #include "CLHEP/Random/RandFlat.h"
8 #include <gsl/gsl_sf_erf.h>
9 #include <gsl/gsl_sf_result.h>
12 gaussDistribution_(eng),
13 poissonDistribution_(eng),
14 flatDistribution_(eng)
26 std::map<
int,
float, std::less<int> >& theMap ) {
30 int status = gsl_sf_erf_Q_e(threshold, &result);
32 if (status != 0)
std::cerr<<
"GaussianTailNoiseGenerator::could not compute gaussian tail probability for the threshold chosen"<<std::endl;
34 float probabilityLeft = result.val;
35 float meanNumberOfNoisyChannels = probabilityLeft * NumberOfchannels;
38 float lowLimit = threshold * noiseRMS;
39 for (
int i = 0;
i < numberOfNoisyChannels;
i++) {
48 theMap[theChannelNumber] = noise;
57 std::vector<std::pair<int,float> > &theVector ) {
61 int status = gsl_sf_erf_Q_e(threshold, &result);
62 if (status != 0)
std::cerr<<
"GaussianTailNoiseGenerator::could not compute gaussian tail probability for the threshold chosen"<<std::endl;
63 double probabilityLeft = result.val;
64 double meanNumberOfNoisyChannels = probabilityLeft * NumberOfchannels;
66 if(numberOfNoisyChannels>NumberOfchannels) numberOfNoisyChannels=NumberOfchannels;
69 theVector.reserve(numberOfNoisyChannels);
70 float lowLimit = threshold * noiseRMS;
73 for (
int i = 0;
i < numberOfNoisyChannels;
i++) {
77 theVector.push_back(std::pair<int, float>(channels[
i], noise));
98 std::vector<double> &theVector ) {
104 unsigned int numberOfchannels = theVector.size();
105 for (
unsigned int i = 0;
i < numberOfchannels; ++
i) {
112 if(numberOfNoisyChannels>numberOfchannels) numberOfNoisyChannels = numberOfchannels;
115 int theChannelNumber;
116 for(
int j=0;
j<numberOfNoisyChannels;++
j) {
120 array[
j] = array[theChannelNumber];
121 array[theChannelNumber] =
b;
CLHEP::RandFlat flatDistribution_
int * getRandomChannels(int, int)
void generateRaw(float noiseRMS, std::vector< double > &)
double generate_gaussian_tail(const double, const double)
void generate(int NumberOfchannels, float threshold, float noiseRMS, std::map< int, float > &theMap)
GaussianTailNoiseGenerator(CLHEP::HepRandomEngine &eng)
CLHEP::RandGaussQ gaussDistribution_
CLHEP::RandPoissonQ poissonDistribution_