CMS 3D CMS Logo

Public Member Functions | Private Attributes

GaussNoiseFP420 Class Reference

#include <GaussNoiseFP420.h>

Inheritance diagram for GaussNoiseFP420:
GNoiseFP420

List of all members.

Public Member Functions

PileUpFP420::signal_map_type addNoise (PileUpFP420::signal_map_type)
 GaussNoiseFP420 (int ns, float nrms, float th, bool aNpixel, int verbosity)
void setNumPixels (int in)
void setThreshold (float in)

Private Attributes

bool addNoisyPixels
float noiseRMS
int numPixels
float threshold
int verbosi

Detailed Description

Definition at line 7 of file GaussNoiseFP420.h.


Constructor & Destructor Documentation

GaussNoiseFP420::GaussNoiseFP420 ( int  ns,
float  nrms,
float  th,
bool  aNpixel,
int  verbosity 
)

Definition at line 11 of file GaussNoiseFP420.cc.

                                                                                         :
  numPixels(ns), noiseRMS(nrms), threshold(th), addNoisyPixels(aNpixel), verbosi(verbosity){}

Member Function Documentation

PileUpFP420::signal_map_type GaussNoiseFP420::addNoise ( PileUpFP420::signal_map_type  in) [virtual]

Implements GNoiseFP420.

Definition at line 16 of file GaussNoiseFP420.cc.

References addNoisyPixels, gather_cfg::cout, relval_steps::gen(), GaussNoiseProducerFP420::generate(), noiseRMS, numPixels, AlCaHLTBitMon_ParallelJobs::p, threshold, and verbosi.

Referenced by FP420DigiMain::run().

                                                      {
  
  PileUpFP420::signal_map_type _signal;  
  
  // Add noise on non-hit pixels
  std::map<int,float,std::less<int> > generatedNoise;
  
  //  int numberOfPixels = (numRows * numColumns);// numPixels=numberOfPixels
  
  
  GaussNoiseProducerFP420 gen;
  gen.generate(numPixels,threshold,noiseRMS,generatedNoise);// threshold is thePixelThreshold
  
  // noise for channels with signal:
  // ----------------------------
  
  for (PileUpFP420::signal_map_type::const_iterator si  = in.begin();
       si != in.end()  ; si++){
    
    if(verbosi>0) {
      std::cout << " ***GaussNoiseFP420:  before noise:" << std::endl;
      std::cout << " for si->first=  " << si->first  << "    _signal[si->first]=  " << _signal[si->first] << "        si->second=      " << si->second  << std::endl;
    }
    // define Gaussian noise centered at 0. with sigma = noiseRMS:
    float noise( CLHEP::RandGauss::shoot(0.,noiseRMS) );           
    //    float noise  = CLHEP::RandGaussQ::shoot(0.,theNoiseInElectrons) ;
    // add noise to each channel with signal:
    _signal[si->first] = si->second + noise;
    
    if(verbosi>0) {
      std::cout << " ***GaussNoiseFP420: after noise added  = " << noise  << std::endl;
      std::cout << "after noise added the _signal[si->first]=  " << _signal[si->first] << std::endl;
    }
  }
  
  //                                                                                                    //
  if(addNoisyPixels){  // Option to skip noise in non-hit pixels
    // Noise on the other channels:
    typedef std::map<int,float,std::less<int> >::iterator MI;
    for(MI p = generatedNoise.begin(); p != generatedNoise.end(); p++){
      if(_signal[(*p).first] == 0) {
        _signal[(*p).first] += (*p).second;
      }
    }//for(MI
  }
  
  // or:
  //                                                                        //
  /*
    if(addNoisyPixels){  // Option to skip noise in non-hit pixels
    // Noise on the other channels:
    typedef std::map<int,float,std::less<int> >::iterator MI;
    for(MI p = generatedNoise.begin(); p != generatedNoise.end(); p++){
    int iy = ((*p).first) / numRows;
    int ix = ((*p).first) - (iy*numRows);
    // Keep for a while for testing.
    if( iy < 0 || iy > (numColumns-1) ) 
    LogWarning ("Pixel Geometry") << " error in iy " << iy ;
    if( ix < 0 || ix > (numRows-1) )
    LogWarning ("Pixel Geometry")  << " error in ix " << ix ;
    int chan = PixelDigi::pixelToChannel(ix, iy);
    LogDebug ("Pixel Digitizer")<<" Storing noise = " << (*mapI).first << " " << (*mapI).second 
    << " " << ix << " " << iy << " " << chan ;
    if(_signal[chan] == 0){
    _signal[(*p).first] += (*p).second;
    }//if
    }//for(MI
    }
  */    
  //                                                                        //
  //                                                                                                    //
  
  
  //
  return _signal;
  //
}
void GaussNoiseFP420::setNumPixels ( int  in) [inline]

Definition at line 12 of file GaussNoiseFP420.h.

References recoMuon::in, and numPixels.

void GaussNoiseFP420::setThreshold ( float  in) [inline]

Definition at line 13 of file GaussNoiseFP420.h.

References recoMuon::in, and threshold.


Member Data Documentation

Definition at line 19 of file GaussNoiseFP420.h.

Referenced by addNoise().

float GaussNoiseFP420::noiseRMS [private]

Definition at line 17 of file GaussNoiseFP420.h.

Referenced by addNoise().

Definition at line 16 of file GaussNoiseFP420.h.

Referenced by addNoise(), and setNumPixels().

float GaussNoiseFP420::threshold [private]

Definition at line 18 of file GaussNoiseFP420.h.

Referenced by addNoise(), and setThreshold().

int GaussNoiseFP420::verbosi [private]

Definition at line 20 of file GaussNoiseFP420.h.

Referenced by addNoise().