98 art::ServiceHandle<geo::Geometry> geo;
99 art::ServiceHandle<util::SignalShapingServiceSBND> sss;
100 art::ServiceHandle<util::LArFFT> fFFT;
103 size_t view = (size_t)geo->View(chan);
106 auto tempNoiseVec = sss->GetNoiseFactVec();
107 double shapingTime = 2.0;
108 double asicGain = sss->GetASICGain(chan);
110 size_t fNTicks = fFFT->FFTSize();
113 if (fShapingTimeOrder.find( shapingTime ) != fShapingTimeOrder.end() ) {
114 noise_factor = tempNoiseVec[view].at( fShapingTimeOrder.find( shapingTime )->second );
115 noise_factor *= asicGain/4.7;
118 throw cet::exception(
"SBNDNoiseServiceFromHist_service.cc")
120 <<
"Shaping Time recieved from signalshapingservices_sbnd.fcl is not one of the allowed values"
122 <<
"Allowed values: 0.5, 1.0, 2.0, 3.0 us"
128 CLHEP::RandFlat flat(*fNoiseEngine, -1, 1);
131 if (sigs.size() != fNTicks)
132 throw cet::exception(
"SBNDNoiseServiceFromHist_service.cc")
134 <<
"Frequency noise vector length must match fNTicks (FFT size)"
135 <<
" ... " << sigs.size() <<
" != " << fNTicks
140 std::vector<TComplex> noiseFrequency(fNTicks / 2 + 1, 0.);
143 double lofilter = 0.;
145 double rnd[2] = {0.};
148 double binWidth = 1.0 / (fNTicks *
fSampleRate * 1.0e-6);
150 for (
size_t i = 0; i < fNTicks / 2 + 1; ++i) {
152 flat.fireArray(2, rnd, 0, 1);
153 pval = fNoiseHist->GetBinContent(i) * ((1 - fNoiseRand) + 2 * fNoiseRand * rnd[0]) * noise_factor;
154 phase = rnd[1] * 2.*TMath::Pi();
155 TComplex tc(pval * cos(phase), pval * sin(phase));
156 noiseFrequency.at(i) += tc;
161 fFFT->DoInvFFT(noiseFrequency, sigs);
163 noiseFrequency.clear();
168 for (
unsigned int i = 0; i < sigs.size(); ++i) {
169 sigs.at(i) *= 1.*fNTicks;