CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 10 of file GaussNoiseProducerFP420.h.

10 {}
GaussNoiseProducerFP420::~GaussNoiseProducerFP420 ( )
inline

Definition at line 11 of file GaussNoiseProducerFP420.h.

11 {}

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 dtNoiseDBValidation_cfg::cerr, i, HLT_25ns14e33_v1_cff::noise, query::result, and ntuplemaker::status.

Referenced by GaussNoiseFP420::addNoise().

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