Go to the documentation of this file.00001
00002
00003
00004
00005
00007 #include "SimRomanPot/SimFP420/interface/GaussNoiseFP420.h"
00008 #include "SimRomanPot/SimFP420/interface/GaussNoiseProducerFP420.h"
00009 #include "CLHEP/Random/RandGauss.h"
00010
00011 GaussNoiseFP420::GaussNoiseFP420(int ns, float nrms, float th, bool aNpixel, int verbosity):
00012 numPixels(ns), noiseRMS(nrms), threshold(th), addNoisyPixels(aNpixel), verbosi(verbosity){}
00013
00014
00015 PileUpFP420::signal_map_type
00016 GaussNoiseFP420::addNoise(PileUpFP420::signal_map_type in){
00017
00018 PileUpFP420::signal_map_type _signal;
00019
00020
00021 std::map<int,float,std::less<int> > generatedNoise;
00022
00023
00024
00025
00026 GaussNoiseProducerFP420 gen;
00027 gen.generate(numPixels,threshold,noiseRMS,generatedNoise);
00028
00029
00030
00031
00032 for (PileUpFP420::signal_map_type::const_iterator si = in.begin();
00033 si != in.end() ; si++){
00034
00035 if(verbosi>0) {
00036 std::cout << " ***GaussNoiseFP420: before noise:" << std::endl;
00037 std::cout << " for si->first= " << si->first << " _signal[si->first]= " << _signal[si->first] << " si->second= " << si->second << std::endl;
00038 }
00039
00040 float noise( CLHEP::RandGauss::shoot(0.,noiseRMS) );
00041
00042
00043 _signal[si->first] = si->second + noise;
00044
00045 if(verbosi>0) {
00046 std::cout << " ***GaussNoiseFP420: after noise added = " << noise << std::endl;
00047 std::cout << "after noise added the _signal[si->first]= " << _signal[si->first] << std::endl;
00048 }
00049 }
00050
00051
00052 if(addNoisyPixels){
00053
00054 typedef std::map<int,float,std::less<int> >::iterator MI;
00055 for(MI p = generatedNoise.begin(); p != generatedNoise.end(); p++){
00056 if(_signal[(*p).first] == 0) {
00057 _signal[(*p).first] += (*p).second;
00058 }
00059 }
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 return _signal;
00091
00092 }
00093
00094
00095
00096
00097