CMS 3D CMS Logo

List of all members | Public Member Functions
GaussNoiseProducerFP420 Class Reference

#include <GaussNoiseProducerFP420.h>

Public Member Functions

 GaussNoiseProducerFP420 ()
 
void generate (int NumberOfchannels, float threshold, float noiseRMS, std::map< int, float, std::less< int >> &theMap)
 
 ~GaussNoiseProducerFP420 ()
 

Detailed Description

Definition at line 6 of file GaussNoiseProducerFP420.h.

Constructor & Destructor Documentation

GaussNoiseProducerFP420::GaussNoiseProducerFP420 ( )
inline

Definition at line 8 of file GaussNoiseProducerFP420.h.

8 {}
GaussNoiseProducerFP420::~GaussNoiseProducerFP420 ( )
inline

Member Function Documentation

void GaussNoiseProducerFP420::generate ( int  NumberOfchannels,
float  threshold,
float  noiseRMS,
std::map< int, float, std::less< int >> &  theMap 
)

Definition at line 18 of file GaussNoiseProducerFP420.cc.

References MessageLogger_cfi::cerr, mps_fire::i, createfilelist::int, mps_fire::result, and mps_update::status.

Referenced by GaussNoiseFP420::addNoise(), and ~GaussNoiseProducerFP420().

21  {
22  // estimale mean number of noisy channels with amplidudes above $AdcThreshold$
23 
24  // Gauss is centered at 0 with sigma=1
25  // Gaussian tail probability higher threshold(=5sigma for instance):
26  gsl_sf_result result;
27  int status = gsl_sf_erf_Q_e(threshold, &result);
28  // MP
29  // if (status != 0) throw DetLogicError("GaussNoiseProducerFP420::could not
30  // compute gaussian tail probability for the threshold chosen");
31  if (status != 0)
32  std::cerr << "GaussNoiseProducerFP420::could not compute gaussian tail "
33  "probability for the threshold chosen"
34  << std::endl;
35  float probabilityLeft = result.val;
36 
37  // with known probability higher threshold compute number of noisy channels
38  // distributed in Poisson:
39  float meanNumberOfNoisyChannels = probabilityLeft * NumberOfchannels;
40  int numberOfNoisyChannels = CLHEP::RandPoisson::shoot(meanNumberOfNoisyChannels);
41 
42  // draw noise at random according to Gaussian tail
43 
44  // initialise default gsl uniform generator engine
45  static gsl_rng const *const mt19937 = gsl_rng_alloc(gsl_rng_mt19937);
46 
47  float lowLimit = threshold * noiseRMS;
48  for (int i = 0; i < numberOfNoisyChannels; i++) {
49  // Find a random channel number
50  int theChannelNumber = (int)CLHEP::RandFlat::shootInt(NumberOfchannels);
51 
52  // Find random noise value: random mt19937 over Gaussian tail above
53  // threshold:
54  float noise = gsl_ran_gaussian_tail(mt19937, lowLimit, noiseRMS);
55 
56  // Fill in map
57  theMap[theChannelNumber] = noise;
58  }
59 }