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" 
   18 #include "nurandom/RandomUtils/NuRandomService.h" 
   20 #include "icarus_signal_processing/WaveformTools.h" 
   23 #include "CLHEP/Random/RandFlat.h" 
   24 #include "CLHEP/Random/RandGeneral.h" 
   25 #include "CLHEP/Random/RandGaussQ.h" 
   33 #include <unsupported/Eigen/FFT> 
   43     explicit SBNNoise(
const fhicl::ParameterSet& pset);
 
   47     void configure(
const fhicl::ParameterSet& pset) 
override;
 
   52                        CLHEP::HepRandomEngine& cornoise_engine,
 
   57                        unsigned int board) 
override;
 
   82     using WaveformTools = icarus_signal_processing::WaveformTools<icarusutil::SigProcPrecision>;
 
  138     fPlane                     = pset.get< 
size_t      >(
"Plane");
 
  152     auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
 
  153     auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
 
  157     std::string fullFileName;
 
  158     std::string corrAmpFileName;
 
  160     cet::search_path searchPath(
"FW_SEARCH_PATH");
 
  161     searchPath.find_file(fInputNoiseHistFileName, fullFileName);
 
  163     TFile inputFile(fullFileName.c_str(), 
"READ");
 
  165     if (!inputFile.IsOpen())
 
  166         throw cet::exception(
"NoiseFromHist::configure") << 
"Unable to open input file: " << fInputNoiseHistFileName << std::endl;
 
  168     TH1D* corrHistPtr = (TH1D*)inputFile.Get(fCorrelatedHistogramName.c_str());    
 
  170         throw cet::exception(
"NoiseFromHist::configure") << 
"Unable to recover desired histogram: " << fCorrelatedHistogramName << std::endl;
 
  172   TH1D* uncorrHistPtr = (TH1D*)inputFile.Get(fUncorrelatedHistogramName.c_str());    
 
  174         throw cet::exception(
"NoiseFromHist::configure") << 
"Unable to recover desired histogram: " << fUncorrelatedHistogramName << std::endl;
 
  176     corrRMSHistPtr = (TH1D*)inputFile.Get(fCorrelatedRMSHistoName.c_str());  
 
  178         throw cet::exception(
"NoiseFromHist::configure") << 
"Unable to recover desired histogram: " << fCorrelatedRMSHistoName << std::endl;
 
  182         throw cet::exception(
"NoiseFromHist::configure") << 
"Unable to recover desired histogram: " << fUncorrelatedRMSHistoName << std::endl;
 
  186         throw cet::exception(
"NoiseFromHist::configure") << 
"Unable to recover desired histogram: " << fTotalRMSHistoName << std::endl;
 
  190 std::cout << 
" corr nbins " << corrHistPtr->GetNbinsX() << std::endl;
 
  191 std::cout << 
" uncorr nbins " << uncorrHistPtr->GetNbinsX() << std::endl;
 
  195     for(
size_t histIdx = 0; histIdx < size_t(corrHistPtr->GetNbinsX()); histIdx++)
 
  200     for(
size_t histIdx = 0; histIdx < size_t(uncorrHistPtr->GetNbinsX()); histIdx++)
 
  204 std::cout << 
" after filling vectors " << std::endl;
 
  208         art::ServiceHandle<art::TFileService> 
tfs;
 
  210         art::TFileDirectory* histDirectory = tfs.get();
 
  213         art::TFileDirectory 
dir = histDirectory->mkdir(Form(
"CorNoisePlane%1zu",
fPlane));
 
  216         float readOutSize = 
detProp.ReadOutWindowSize();
 
  217         float maxFreq     = 1.e6 / (2. * sampleRate);
 
  218         float minFreq     = 1.e6 / (2. * sampleRate * readOutSize);
 
  219         int   numSamples  = readOutSize / 2;
 
  221         fInputNoiseHist   = dir.make<TProfile>(
"InNoise",   
";freq(kHz)", numSamples, minFreq, maxFreq);
 
  222         fMedianNoiseHist  = dir.make<TProfile>(
"MedNoise",  
";freq(kHz)", numSamples, minFreq, maxFreq);;
 
  223         fPeakNoiseHist    = dir.make<TProfile>(
"PeakNoise", 
";freq(kHz)", numSamples, minFreq, maxFreq);;
 
  240                                     CLHEP::HepRandomEngine& engine_corr,
 
  265     std::transform(noise_unc.begin(),noise_unc.end(),noise_corr.begin(),noise.begin(),std::plus<float>());
 
  282     CLHEP::RandFlat noiseGen(engine,0,1);
 
  284     std::function<void (double[])> randGenFunc = [&noiseGen](
double randArray[]){noiseGen.fireArray(2,randArray);};
 
  299         CLHEP::RandFlat noiseGen(engine,0,1);
 
  301         std::function<void (double[])> randGenFunc = [&noiseGen](
double randArray[]){noiseGen.fireArray(2,randArray);};
 
  314     double rnd_corr[2] = {0.,0.};
 
  317     for(
size_t i=0; i< noise.size()/2; ++i)
 
  323         float phase = rnd_corr[1] * 2. * M_PI;
 
  325         std::complex<float> tc(pval*cos(phase),pval*sin(phase));
 
  347     std::function<void (double[])> randGenFunc = [](
double randArray[]){randArray[0]=0.5; randArray[1]=0.5;};
 
  350     float              scaleFactor = 1.;
 
  356     double mean,rmsTrunc;
 
Utilities related to art service access. 
 
The data type to uniquely identify a Plane. 
 
std::vector< ComplexVal > FrequencyVec
 
std::vector< SigProcPrecision > TimeVec
 
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
 
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. 
 
BEGIN_PROLOG could also be cout