2 #include "CLHEP/Random/RandGaussQ.h"
14 CLHEP::HepRandomEngine *engine)
const {
15 std::vector<std::pair<int, float> > generatedNoise;
19 for (
size_t iChannel = minChannel; iChannel < maxChannel; iChannel++) {
20 if (
in[iChannel] != 0) {
21 in[iChannel] += CLHEP::RandGaussQ::shoot(engine, 0., noiseRMS);
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;
35 std::vector<float> &noiseRMS,
36 CLHEP::HepRandomEngine *engine)
const {
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]);
46 for (
size_t iChannel = 0; iChannel !=
in.size(); iChannel++) {
47 if (ped[iChannel] > 0.)
48 in[iChannel] += ped[iChannel];
54 std::vector<bool> &badChannels,
55 CLHEP::HepRandomEngine *engine)
const {
56 int nAPVs =
in.size() / 128;
57 std::vector<float> CMNv;
58 for (
int APVn = 0; APVn < nAPVs; ++APVn)
59 CMNv.push_back(CLHEP::RandGaussQ::shoot(engine, 0., cmnRMS));
60 for (
size_t iChannel = 0; iChannel !=
in.size(); iChannel++) {
61 if (!badChannels[iChannel])
62 in[iChannel] += CMNv[(
int)(iChannel / 128)];
67 size_t nAPVs =
in.size() / 128;
68 std::vector<float> vShift;
69 double apvCharge, apvMult;
72 for (
size_t APVn = 0; APVn < nAPVs; ++APVn) {
75 for (iChannel = APVn * 128; iChannel != APVn * 128 + 128; ++iChannel) {
76 if (
in[iChannel] > 0) {
78 apvCharge +=
in[iChannel];
83 vShift.push_back(apvCharge / apvMult);
87 for (iChannel = 0; iChannel !=
in.size(); ++iChannel) {
88 if (!badChannels[iChannel])
89 in[iChannel] -= vShift[(
int)(iChannel / 128)];