Go to the documentation of this file.00001
00002
00003
00004
00005
00007 #include "SimRomanPot/SimFP420/interface/GaussNoiseProducerFP420.h"
00008 #include "CLHEP/Random/RandPoisson.h"
00009 #include "CLHEP/Random/RandFlat.h"
00010 #include <gsl/gsl_sf_erf.h>
00011 #include <gsl/gsl_sf_result.h>
00012 #include <gsl/gsl_randist.h>
00013 #include <gsl/gsl_rng.h>
00014
00015 extern "C" float freq_(const float& x);
00016 extern "C" float gausin_(const float& x);
00017
00018 void GaussNoiseProducerFP420::generate(int NumberOfchannels,
00019 float threshold,
00020 float noiseRMS,
00021 std::map<int,float, std::less<int> >& theMap )
00022 {
00023
00024
00025
00026
00027
00028 gsl_sf_result result;
00029 int status = gsl_sf_erf_Q_e(threshold, &result);
00030
00031
00032 if (status != 0) std::cerr<<"GaussNoiseProducerFP420::could not compute gaussian tail probability for the threshold chosen"<<std::endl;
00033 float probabilityLeft = result.val;
00034
00035
00036 float meanNumberOfNoisyChannels = probabilityLeft * NumberOfchannels;
00037 int numberOfNoisyChannels = CLHEP::RandPoisson::shoot(meanNumberOfNoisyChannels);
00038
00039
00040
00041
00042 static gsl_rng * mt19937 = gsl_rng_alloc (gsl_rng_mt19937);
00043
00044 float lowLimit = threshold * noiseRMS;
00045 for (int i = 0; i < numberOfNoisyChannels; i++) {
00046
00047
00048 int theChannelNumber = (int) CLHEP::RandFlat::shootInt(NumberOfchannels);
00049
00050
00051 float noise = gsl_ran_gaussian_tail(mt19937, lowLimit, noiseRMS);
00052
00053
00054 theMap[theChannelNumber] = noise;
00055
00056 }
00057 }