1 #include "CLHEP/Random/RandFlat.h"
2 #include "CLHEP/Random/RandGaussQ.h"
3 #include "CLHEP/Random/RandPoissonQ.h"
8 #include <gsl/gsl_sf_erf.h>
9 #include <gsl/gsl_sf_result.h>
14 for (
unsigned int i = 0;
i < 512; ++
i)
16 for (
unsigned int i = 0;
i < 768; ++
i)
24 std::map<
int,
float, std::less<int>> &theMap,
25 CLHEP::HepRandomEngine *engine) {
31 std::cerr <<
"GaussianTailNoiseGenerator::could not compute gaussian tail "
32 "probability for the threshold chosen"
35 float probabilityLeft =
result.val;
36 float meanNumberOfNoisyChannels = probabilityLeft * NumberOfchannels;
38 CLHEP::RandPoissonQ randPoissonQ(*engine, meanNumberOfNoisyChannels);
39 int numberOfNoisyChannels = randPoissonQ.fire();
42 for (
int i = 0;
i < numberOfNoisyChannels;
i++) {
44 int theChannelNumber = (
int)CLHEP::RandFlat::shoot(engine, NumberOfchannels);
50 theMap[theChannelNumber] =
noise;
59 CLHEP::HepRandomEngine *engine) {
65 std::cerr <<
"GaussianTailNoiseGenerator::could not compute gaussian tail "
66 "probability for the threshold chosen"
68 double probabilityLeft =
result.val;
69 double meanNumberOfNoisyChannels = probabilityLeft * NumberOfchannels;
71 CLHEP::RandPoissonQ randPoissonQ(*engine, meanNumberOfNoisyChannels);
72 int numberOfNoisyChannels = randPoissonQ.fire();
74 if (numberOfNoisyChannels > NumberOfchannels)
75 numberOfNoisyChannels = NumberOfchannels;
78 theVector.reserve(numberOfNoisyChannels);
82 for (
int i = 0;
i < numberOfNoisyChannels;
i++) {
108 std::vector<double> &theVector,
109 CLHEP::HepRandomEngine *engine) {
115 unsigned int numberOfchannels = theVector.size();
116 for (
unsigned int i = 0;
i < numberOfchannels; ++
i) {
117 if (theVector[
i] == 0)
118 theVector[
i] = CLHEP::RandGaussQ::shoot(engine, 0., noiseRMS);
123 int numberOfchannels,
124 CLHEP::HepRandomEngine *engine) {
125 if (numberOfNoisyChannels > numberOfchannels)
126 numberOfNoisyChannels = numberOfchannels;
128 if (numberOfchannels == 768)
130 int theChannelNumber;
131 for (
int j = 0;
j < numberOfNoisyChannels; ++
j) {
132 theChannelNumber = (
int)CLHEP::RandFlat::shoot(engine, numberOfchannels -
j) +
j;
136 array[theChannelNumber] =
b;
143 CLHEP::HepRandomEngine *engine) {
148 double s =
a / sigma;
158 x = CLHEP::RandGaussQ::shoot(engine, 0., 1.0);
172 u = CLHEP::RandFlat::shoot(engine);
174 v = CLHEP::RandFlat::shoot(engine);