CMS 3D CMS Logo

SiGaussianTailNoiseAdder.cc
Go to the documentation of this file.
2 #include "CLHEP/Random/RandGaussQ.h"
3 
5  : threshold(th), genNoise(new GaussianTailNoiseGenerator()) {}
6 
8 
9 void SiGaussianTailNoiseAdder::addNoise(std::vector<float> &in,
10  size_t &minChannel,
11  size_t &maxChannel,
12  int numStrips,
13  float noiseRMS,
14  CLHEP::HepRandomEngine *engine) const {
15  std::vector<std::pair<int, float> > generatedNoise;
16  genNoise->generate(numStrips, threshold, noiseRMS, generatedNoise, engine);
17 
18  // noise on strips with signal:
19  for (size_t iChannel = minChannel; iChannel < maxChannel; iChannel++) {
20  if (in[iChannel] != 0) {
21  in[iChannel] += CLHEP::RandGaussQ::shoot(engine, 0., noiseRMS);
22  }
23  }
24 
25  // Noise on the other strips
26  typedef std::vector<std::pair<int, float> >::const_iterator VI;
27  for (VI p = generatedNoise.begin(); p != generatedNoise.end(); p++) {
28  if (in[(*p).first] == 0) {
29  in[(*p).first] += (*p).second;
30  }
31  }
32 }
33 
34 void SiGaussianTailNoiseAdder::addNoiseVR(std::vector<float> &in,
35  std::vector<float> &noiseRMS,
36  CLHEP::HepRandomEngine *engine) const {
37  // Add noise
38  // Full Gaussian noise is added everywhere
39  for (size_t iChannel = 0; iChannel != in.size(); iChannel++) {
40  if (noiseRMS[iChannel] > 0.)
41  in[iChannel] += CLHEP::RandGaussQ::shoot(engine, 0., noiseRMS[iChannel]);
42  }
43 }
44 
45 void SiGaussianTailNoiseAdder::addPedestals(std::vector<float> &in, std::vector<float> &ped) const {
46  for (size_t iChannel = 0; iChannel != in.size(); iChannel++) {
47  if (ped[iChannel] > 0.)
48  in[iChannel] += ped[iChannel];
49  }
50 }
51 
52 void SiGaussianTailNoiseAdder::addCMNoise(std::vector<float> &in,
53  float cmnRMS,
54  std::vector<bool> &badChannels,
55  CLHEP::HepRandomEngine *engine) const {
56  int nAPVs = in.size() / 128;
57  std::vector<float> CMNv;
58  CMNv.reserve(nAPVs);
59  for (int APVn = 0; APVn < nAPVs; ++APVn)
60  CMNv.push_back(CLHEP::RandGaussQ::shoot(engine, 0., cmnRMS));
61  for (size_t iChannel = 0; iChannel != in.size(); iChannel++) {
62  if (!badChannels[iChannel])
63  in[iChannel] += CMNv[(int)(iChannel / 128)];
64  }
65 }
66 
67 void SiGaussianTailNoiseAdder::addBaselineShift(std::vector<float> &in, std::vector<bool> &badChannels) const {
68  size_t nAPVs = in.size() / 128;
69  std::vector<float> vShift;
70  double apvCharge, apvMult;
71 
72  size_t iChannel;
73  for (size_t APVn = 0; APVn < nAPVs; ++APVn) {
74  apvMult = 0;
75  apvCharge = 0;
76  for (iChannel = APVn * 128; iChannel != APVn * 128 + 128; ++iChannel) {
77  if (in[iChannel] > 0) {
78  ++apvMult;
79  apvCharge += in[iChannel];
80  }
81  if (apvMult == 0)
82  vShift.push_back(0);
83  else
84  vShift.push_back(apvCharge / apvMult);
85  }
86  }
87 
88  for (iChannel = 0; iChannel != in.size(); ++iChannel) {
89  if (!badChannels[iChannel])
90  in[iChannel] -= vShift[(int)(iChannel / 128)];
91  }
92 }
SiGaussianTailNoiseAdder::SiGaussianTailNoiseAdder
SiGaussianTailNoiseAdder(float)
Definition: SiGaussianTailNoiseAdder.cc:4
SiGaussianTailNoiseAdder::addCMNoise
void addCMNoise(std::vector< float > &, float, std::vector< bool > &, CLHEP::HepRandomEngine *) const override
Definition: SiGaussianTailNoiseAdder.cc:52
SiGaussianTailNoiseAdder::addNoise
void addNoise(std::vector< float > &, size_t &, size_t &, int, float, CLHEP::HepRandomEngine *) const override
Definition: SiGaussianTailNoiseAdder.cc:9
GaussianTailNoiseGenerator
Definition: GaussianTailNoiseGenerator.h:24
SiGaussianTailNoiseAdder::addNoiseVR
void addNoiseVR(std::vector< float > &, std::vector< float > &, CLHEP::HepRandomEngine *) const override
Definition: SiGaussianTailNoiseAdder.cc:34
SiGaussianTailNoiseAdder::threshold
const float threshold
Definition: SiGaussianTailNoiseAdder.h:29
SiGaussianTailNoiseAdder::addBaselineShift
void addBaselineShift(std::vector< float > &, std::vector< bool > &) const override
Definition: SiGaussianTailNoiseAdder.cc:67
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
recoMuon::in
Definition: RecoMuonEnumerators.h:6
createfilelist.int
int
Definition: createfilelist.py:10
SiGaussianTailNoiseAdder::addPedestals
void addPedestals(std::vector< float > &, std::vector< float > &) const override
Definition: SiGaussianTailNoiseAdder.cc:45
SiGaussianTailNoiseAdder::genNoise
std::unique_ptr< GaussianTailNoiseGenerator > genNoise
Definition: SiGaussianTailNoiseAdder.h:30
SiGaussianTailNoiseAdder::~SiGaussianTailNoiseAdder
~SiGaussianTailNoiseAdder() override
Definition: SiGaussianTailNoiseAdder.cc:7
SiGaussianTailNoiseAdder.h
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430