89 CLHEP::HepRandomEngine* rndmEngine)
94 const double fastPeriod =
m_settings->fastElectronicsNoisePulseDistance();
97 const double slowPeriod =
m_settings->slowPeriodicNoisePulseDistance();
110 double timeOfNextPulse;
111 unsigned int binindex;
117 for (
unsigned int i(0); i < nbins; ++i) {
122 timeOfNextPulse = 0.5 * fastPeriod;
124 binindex =
static_cast<unsigned int>(timeOfNextPulse*invbinwidth);
125 if (binindex >= nbins)
break;
126 m_tmpArray[binindex] += CLHEP::RandGaussZiggurat::shoot(rndmEngine, 0., 1.);
127 timeOfNextPulse += fastPeriod;
131 for (
unsigned int i(0); i < nbins; ++i) {
133 if ( limit > nbins ) limit = nbins;
134 for (
unsigned int j(i); j < limit; ++j) {
141 for (
unsigned int i(0); i < nbins; ++i) {
147 timeOfNextPulse = 0.5 * slowPeriod;
149 binindex =
static_cast<unsigned int>(timeOfNextPulse*invbinwidth);
150 if (binindex >= nbins)
break;
151 m_tmpArray[binindex] += CLHEP::RandGaussZiggurat::shoot(rndmEngine, 0., 1.);
152 timeOfNextPulse += slowPeriod;
156 for (
unsigned int i(0); i < nbins; ++i) {
158 if (limit > nbins) limit = nbins;
159 for (
unsigned int j(i); j < limit; ++j) {
200 double noiseamplitude,
201 CLHEP::HepRandomEngine *rndmEngine) {
213 static const unsigned int n_slowperiodic_shift = 26;
214 static const int slowperiodic_constshift = -2;
215 static const double slowperiodic_shift_prob_comul[n_slowperiodic_shift] =
216 {0.08, 0.16, 0.24, 0.32, 0.40, 0.48, 0.56, 0.64, 0.66, 0.68,
217 0.70, 0.72, 0.74, 0.76, 0.78, 0.80, 0.82, 0.84, 0.86, 0.88,
218 0.90, 0.92, 0.94, 0.96, 0.98, 1.00};
221 const unsigned int nsignalbins(signal.size());
225 int offset_slowperiodic(CLHEP::RandFlat::shootInt(rndmEngine,
227 - nsignalbins-n_slowperiodic_shift
228 - slowperiodic_constshift));
231 offset_slowperiodic -= slowperiodic_constshift;
233 const double rand(CLHEP::RandFlat::shoot(rndmEngine, 0., 1.));
234 for (
unsigned int i(0); i < n_slowperiodic_shift; ++i) {
235 if ( rand < slowperiodic_shift_prob_comul[i] ) {
236 offset_slowperiodic -= i;
242 if (offset_slowperiodic<0)
246 for (
unsigned int i(0); i<nsignalbins; ++i) {
247 signal[i] += noiseamplitude *
void getSamplesOfMaxLTOverNoiseAmp(std::vector< float > &maxLTOverNoiseAmp, unsigned long nsamplings, CLHEP::HepRandomEngine *rndmEngine)
From generated (and cached) noise samples, this function returns in vector maxLTOverNoiseAmp the maxi...
double getMax(unsigned int firstbinslowsignal, unsigned int firstbinfastsignal, unsigned int binsinwindow)
Get max amplitude of noise signal from weighted sum of fast and slow varying noise in period.