8 #include "art/Framework/Services/Registry/ServiceHandle.h"
9 #include "art/Persistency/Provenance/ModuleContext.h"
10 #include "art/Framework/Principal/Event.h"
11 #include "art/Framework/Services/Optional/RandomNumberGenerator.h"
12 #include "art/Utilities/ToolMacros.h"
13 #include "messagefacility/MessageLogger/MessageLogger.h"
14 #include "cetlib_except/exception.h"
17 #include "nurandom/RandomUtils/NuRandomService.h"
22 #include "icarus_signal_processing/Filters/ICARUSFFT.h"
25 #include "CLHEP/Random/RandFlat.h"
26 #include "CLHEP/Random/RandGaussQ.h"
43 void configure(
const fhicl::ParameterSet& pset)
override;
48 CLHEP::HepRandomEngine&,
53 unsigned int)
override;
67 std::unique_ptr<icarus_signal_processing::ICARUSFFT<double>>
fFFT;
89 std::string fullFileName;
90 cet::search_path searchPath(
"FW_SEARCH_PATH");
91 searchPath.find_file(fInputNoiseHistFileName, fullFileName);
93 TFile inputFile(fullFileName.c_str(),
"READ");
95 if (!inputFile.IsOpen())
96 throw cet::exception(
"NoiseFromHist::configure") <<
"Unable to open input file: " << fInputNoiseHistFileName << std::endl;
98 TH1D* histPtr = (TH1D*)inputFile.Get(fHistogramName.c_str());
101 throw cet::exception(
"NoiseFromHist::configure") <<
"Unable to recover desired histogram: " << fHistogramName << std::endl;
105 for(
size_t histIdx = 0; histIdx < size_t(histPtr->GetNbinsX()); histIdx++)
112 auto const clockData = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
113 int numberTimeSamples = clockData.NumberTimeSamples();
115 fFFT = std::make_unique<icarus_signal_processing::ICARUSFFT<double>>(numberTimeSamples);
121 CLHEP::HepRandomEngine&,
128 CLHEP::RandFlat flat(engine,-1,1);
132 if(noise.size() != nFFTTicks)
133 throw cet::exception(
"SimWireICARUS")
135 <<
"Frequency noise vector length must match FFT Ticks (FFT size)"
136 <<
" ... " << noise.size() <<
" != " << nFFTTicks
141 std::vector<std::complex<double>> noiseFrequency(nFFTTicks/2+1, 0.);
145 double rnd[2] = {0.};
150 for(
size_t i=0; i< nFFTTicks/2 + 1; ++i)
153 flat.fireArray(2,rnd,0,1);
157 phase = rnd[1] * 2. * M_PI;
159 std::complex<double> tc(pval*cos(phase),pval*sin(phase));
161 noiseFrequency.at(i) += tc;
165 fFFT->inverseFFT(noiseFrequency, noise);
167 noiseFrequency.clear();
Utilities related to art service access.
The data type to uniquely identify a Plane.
std::vector< SigProcPrecision > TimeVec
unsigned int NumberTimeSamples() const
This is the interface class for a tool to handle a GenNoise for the overall response.