CMS 3D CMS Logo

RPGaussianTailNoiseAdder.cc
Go to the documentation of this file.
3 #include <iostream>
4 #include "CLHEP/Random/RandGauss.h"
5 #include "CLHEP/Random/RandFlat.h"
6 #include "CLHEP/Random/RandBinomial.h"
7 
8 #include <cmath>
9 
10 using namespace std;
11 
13  int numStrips, double theNoiseInElectrons, double theStripThresholdInE, CLHEP::HepRandomEngine &eng, int verbosity)
14  : numStrips_(numStrips),
15  theNoiseInElectrons(theNoiseInElectrons),
16  theStripThresholdInE(theStripThresholdInE),
17  rndEngine_(eng),
18  verbosity_(verbosity) {
20 }
21 
23  simromanpot::strip_charge_map the_strip_charge_map;
24 
25  // noise on strips with signal:
26  for (simromanpot::strip_charge_map::const_iterator i = theSignal.begin(); i != theSignal.end(); ++i) {
27  double noise = CLHEP::RandGauss::shoot(&(rndEngine_), 0.0, theNoiseInElectrons);
28  the_strip_charge_map[i->first] = i->second + noise;
29  if (verbosity_)
30  edm::LogInfo("RPDigiProducer") << "noise added to signal strips: " << noise << "\n";
31  }
32 
33  // noise on the other strips
34  int strips_no_above_threshold =
35  CLHEP::RandBinomial::shoot(&(rndEngine_), (long)numStrips_, strips_above_threshold_prob_);
36 
37  for (int j = 0; j < strips_no_above_threshold; j++) {
38  int strip = CLHEP::RandFlat::shootInt(&(rndEngine_), numStrips_);
39  if (the_strip_charge_map[strip] == 0) {
40  the_strip_charge_map[strip] = 2 * theStripThresholdInE;
41  //only binary decision later, no need to simulate the noise precisely,
42  //enough to know that it exceeds the threshold
43  if (verbosity_)
44  edm::LogInfo("RPDigiProducer") << "nonsignal strips noise :" << strip << " " << the_strip_charge_map[strip]
45  << "\n";
46  }
47  }
48 
49  return the_strip_charge_map;
50 }
simromanpot::strip_charge_map addNoise(const simromanpot::strip_charge_map &theSignal)
RPGaussianTailNoiseAdder(int numStrips, double theNoiseInElectrons, double theStripThresholdInE, CLHEP::HepRandomEngine &eng, int verbosity)
T sqrt(T t)
Definition: SSEVec.h:19
const int verbosity
Log< level::Info, false > LogInfo
std::map< unsigned short, double > strip_charge_map
Definition: RPSimTypes.h:14
CLHEP::HepRandomEngine & rndEngine_