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) {
198 const double& noiseamplitude,
199 CLHEP::HepRandomEngine *rndmEngine) {
211 static const unsigned int n_slowperiodic_shift = 26;
212 static const int slowperiodic_constshift = -2;
213 static const double slowperiodic_shift_prob_comul[n_slowperiodic_shift] =
214 {0.08, 0.16, 0.24, 0.32, 0.40, 0.48, 0.56, 0.64, 0.66, 0.68,
215 0.70, 0.72, 0.74, 0.76, 0.78, 0.80, 0.82, 0.84, 0.86, 0.88,
216 0.90, 0.92, 0.94, 0.96, 0.98, 1.00};
219 const unsigned int nsignalbins(signal.size());
223 int offset_slowperiodic(CLHEP::RandFlat::shootInt(rndmEngine,
225 - nsignalbins-n_slowperiodic_shift
226 - slowperiodic_constshift));
229 offset_slowperiodic -= slowperiodic_constshift;
231 const double rand(CLHEP::RandFlat::shoot(rndmEngine, 0., 1.));
232 for (
unsigned int i(0); i < n_slowperiodic_shift; ++i) {
233 if ( rand < slowperiodic_shift_prob_comul[i] ) {
234 offset_slowperiodic -= i;
240 if (offset_slowperiodic<0)
244 for (
unsigned int i(0); i<nsignalbins; ++i) {
245 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, const unsigned int &binsinwindow)
Get max amplitude of noise signal from weighted sum of fast and slow varying noise in period.