8 #include "art/Framework/Core/EDProducer.h"
9 #include "art/Utilities/ToolMacros.h"
10 #include "art/Utilities/make_tool.h"
11 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include "cetlib_except/exception.h"
15 #include "art_root_io/TFileService.h"
20 #include "nurandom/RandomUtils/NuRandomService.h"
22 #include "icarus_signal_processing/WaveformTools.h"
25 #include "CLHEP/Random/RandFlat.h"
26 #include "CLHEP/Random/RandGeneral.h"
27 #include "CLHEP/Random/RandGaussQ.h"
34 #include <unsupported/Eigen/FFT>
48 void configure(
const fhicl::ParameterSet& pset)
override;
53 CLHEP::HepRandomEngine& ,
58 unsigned int)
override;
86 using WaveformTools = icarus_signal_processing::WaveformTools<icarusutil::SigProcPrecision>;
134 std::cout <<
" after making histos " << std::endl;
145 std::cout <<
" configuring tool " << std::endl;
147 fPlane = pset.get<
size_t >(
"Plane");
152 std::vector<float> noiseFracVec = pset.get< std::vector<float> >(
"IncoherentNoiseFraction", std::vector<float>());
161 for(
auto& noiseFrac : noiseFracVec) {
165 std::string fullFileName;
167 cet::search_path searchPath(
"FW_SEARCH_PATH");
169 searchPath.find_file(fInputNoiseHistFileName, fullFileName);
174 throw cet::exception(
"NoiseFromHist::configure") <<
"Unable to open input file: " << fInputNoiseHistFileName << std::endl;
176 std::cout <<
" end configuring tool " << std::endl;
191 noiseVec.resize(corrHistPtr->GetNbinsX(),0.);
192 for(
size_t histIdx = 0; histIdx < size_t(corrHistPtr->GetNbinsX()); histIdx++) noiseVec[histIdx] = corrHistPtr->GetBinContent(histIdx+1);
199 throw cet::exception(
"NoiseFromHist::configure") <<
"Unable to recover desired histogram: " <<
fUncorrelatedHistogramName << std::endl;
203 noiseVec.resize(uncorrHistPtr->GetNbinsX(),0.);
204 for(
size_t histIdx = 0; histIdx < size_t(uncorrHistPtr->GetNbinsX()); histIdx++) noiseVec[histIdx] = uncorrHistPtr->GetBinContent(histIdx+1);
210 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
211 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
214 art::ServiceHandle<art::TFileService>
tfs;
216 art::TFileDirectory* histDirectory = tfs.get();
219 art::TFileDirectory
dir = histDirectory->mkdir(Form(
"CorNoisePlane%1zu",
fPlane));
222 float readOutSize =
detProp.ReadOutWindowSize();
223 float maxFreq = 1.e6 / (2. * sampleRate);
224 float minFreq = 1.e6 / (2. * sampleRate * readOutSize);
225 int numSamples = readOutSize / 2;
227 fInputNoiseHist = dir.make<TProfile>(
"InNoise",
";freq(kHz)", numSamples, minFreq, maxFreq);
228 fMediaNoiseHist = dir.make<TH1D>(
"MedNoise",
";ADC", 100, -10., -10.);;
229 fPeakNoiseHist = dir.make<TProfile>(
"PeakNoise",
";freq(kHz)", numSamples, minFreq, maxFreq);;
244 CLHEP::HepRandomEngine& engine_corr,
255 art::ServiceHandle<geo::Geometry> geom;
276 std::transform(noise_unc.begin(),noise_unc.end(),noise_corr.begin(),noise.begin(),std::plus<float>());
301 CLHEP::RandFlat noiseGen(engine,0,1);
303 std::function<void (double[])> randGenFunc = [&noiseGen](
double randArray[]){noiseGen.fireArray(2,randArray);};
316 CLHEP::RandFlat noiseGen(engine,0,1);
318 std::function<void (double[])> randGenFunc = [&noiseGen](
double randArray[]){noiseGen.fireArray(2,randArray);};
327 double rnd_corr[2] = {0.,0.};
330 for(
size_t i=0; i< noise.size()/2; ++i)
337 float phase = rnd_corr[1] * 2. * M_PI;
340 std::complex<float> tc(pval*cos(phase),pval*sin(phase));
Utilities related to art service access.
The data type to uniquely identify a Plane.
std::vector< ComplexVal > FrequencyVec
std::vector< SigProcPrecision > TimeVec
std::string to_string(WindowPattern const &pattern)
This is the interface class for a tool to handle a GenNoise for the overall response.
art::ServiceHandle< art::TFileService > tfs
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
art framework interface to geometry description
BEGIN_PROLOG could also be cout