CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GaussNoiseFP420.cc
Go to the documentation of this file.
1 // File: GaussNoiseFP420.cc
3 // Date: 12.2006
4 // Description: GaussNoiseFP420 for FP420
5 // Modifications:
9 #include "CLHEP/Random/RandGauss.h"
10 
11 GaussNoiseFP420::GaussNoiseFP420(int ns, float nrms, float th, bool aNpixel, int verbosity):
12  numPixels(ns), noiseRMS(nrms), threshold(th), addNoisyPixels(aNpixel), verbosi(verbosity){}
13 
14 
17 
19 
20  // Add noise on non-hit pixels
21  std::map<int,float,std::less<int> > generatedNoise;
22 
23  // int numberOfPixels = (numRows * numColumns);// numPixels=numberOfPixels
24 
25 
27  gen.generate(numPixels,threshold,noiseRMS,generatedNoise);// threshold is thePixelThreshold
28 
29  // noise for channels with signal:
30  // ----------------------------
31 
32  for (PileUpFP420::signal_map_type::const_iterator si = in.begin();
33  si != in.end() ; si++){
34 
35  if(verbosi>0) {
36  std::cout << " ***GaussNoiseFP420: before noise:" << std::endl;
37  std::cout << " for si->first= " << si->first << " _signal[si->first]= " << _signal[si->first] << " si->second= " << si->second << std::endl;
38  }
39  // define Gaussian noise centered at 0. with sigma = noiseRMS:
40  float noise( CLHEP::RandGauss::shoot(0.,noiseRMS) );
41  // float noise = CLHEP::RandGaussQ::shoot(0.,theNoiseInElectrons) ;
42  // add noise to each channel with signal:
43  _signal[si->first] = si->second + noise;
44 
45  if(verbosi>0) {
46  std::cout << " ***GaussNoiseFP420: after noise added = " << noise << std::endl;
47  std::cout << "after noise added the _signal[si->first]= " << _signal[si->first] << std::endl;
48  }
49  }
50 
51  // //
52  if(addNoisyPixels){ // Option to skip noise in non-hit pixels
53  // Noise on the other channels:
54  typedef std::map<int,float,std::less<int> >::iterator MI;
55  for(MI p = generatedNoise.begin(); p != generatedNoise.end(); p++){
56  if(_signal[(*p).first] == 0) {
57  _signal[(*p).first] += (*p).second;
58  }
59  }//for(MI
60  }
61 
62  // or:
63  // //
64  /*
65  if(addNoisyPixels){ // Option to skip noise in non-hit pixels
66  // Noise on the other channels:
67  typedef std::map<int,float,std::less<int> >::iterator MI;
68  for(MI p = generatedNoise.begin(); p != generatedNoise.end(); p++){
69  int iy = ((*p).first) / numRows;
70  int ix = ((*p).first) - (iy*numRows);
71  // Keep for a while for testing.
72  if( iy < 0 || iy > (numColumns-1) )
73  LogWarning ("Pixel Geometry") << " error in iy " << iy ;
74  if( ix < 0 || ix > (numRows-1) )
75  LogWarning ("Pixel Geometry") << " error in ix " << ix ;
76  int chan = PixelDigi::pixelToChannel(ix, iy);
77  LogDebug ("Pixel Digitizer")<<" Storing noise = " << (*mapI).first << " " << (*mapI).second
78  << " " << ix << " " << iy << " " << chan ;
79  if(_signal[chan] == 0){
80  _signal[(*p).first] += (*p).second;
81  }//if
82  }//for(MI
83  }
84  */
85  // //
86  // //
87 
88 
89  //
90  return _signal;
91  //
92 }
93 //
94 
95 
96 
97 
PileUpFP420::signal_map_type addNoise(const PileUpFP420::signal_map_type &)
GaussNoiseFP420(int ns, float nrms, float th, bool aNpixel, int verbosity)
void generate(int NumberOfchannels, float threshold, float noiseRMS, std::map< int, float, std::less< int > > &theMap)
std::map< int, Amplitude, std::less< int > > signal_map_type
Definition: PileUpFP420.h:15
tuple cout
Definition: gather_cfg.py:121