All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
icarus_tool::SBNDataNoise Class Reference
Inheritance diagram for icarus_tool::SBNDataNoise:
icarus_tool::IGenNoise

Public Member Functions

 SBNDataNoise (const fhicl::ParameterSet &pset)
 
 ~SBNDataNoise ()
 
void configure (const fhicl::ParameterSet &pset) override
 
void nextEvent () override
 
void generateNoise (CLHEP::HepRandomEngine &noise_engine, CLHEP::HepRandomEngine &cornoise_engine, icarusutil::TimeVec &noise, detinfo::DetectorPropertiesData const &, double noise_factor, const geo::PlaneID &, unsigned int board) override
 

Private Types

using CorrFactorsMap = std::map< unsigned int, std::vector< float >>
 
using WaveformTools = icarus_signal_processing::WaveformTools< icarusutil::SigProcPrecision >
 

Private Member Functions

void GenerateCorrelatedNoise (CLHEP::HepRandomEngine &, icarusutil::TimeVec &, double, unsigned int, unsigned int)
 
void GenerateUncorrelatedNoise (CLHEP::HepRandomEngine &, icarusutil::TimeVec &, double, unsigned int)
 
void GenNoise (std::function< void(double[])> &, const icarusutil::TimeVec &, icarusutil::TimeVec &, float)
 
void ComputeRMSs ()
 
void makeHistograms ()
 
void SampleCorrelatedRMSs ()
 
void ExtractUncorrelatedRMS (float &, int) const
 
- Private Member Functions inherited from icarus_tool::IGenNoise
virtual ~IGenNoise () noexcept=default
 

Private Attributes

size_t fPlane
 
int fMedianNumBins
 
float fNoiseRand
 
long fCorrelatedSeed
 
long fUncorrelatedSeed
 
std::vector< float > fIncoherentNoiseFrac
 
bool fStoreHistograms
 
std::vector< std::string > fInputNoiseHistFileName
 
std::string fHistogramName
 
std::string fCorrelatedHistogramName
 
std::string fUncorrelatedHistogramName
 
std::string fCorrelatedRMSHistoName
 
std::string fUncorrelatedRMSHistoName
 
std::string fTotalRMSHistoName
 
CorrFactorsMap fCorrFactorsMap
 
WaveformTools fWaveformTool
 
std::vector< icarusutil::TimeVecfCoherentNoiseVec
 
std::vector< icarusutil::TimeVecfIncoherentNoiseVec
 
Noise::ICoherentNoiseFactorfCoherentNoiseService
 
double fIncoherentNoiseRMS
 
double fCoherentNoiseRMS
 
icarusutil::FrequencyVec fNoiseFrequencyVec
 
bool fNeedFirstSeed =true
 
TProfile * fInputNoiseHist
 
TH1D * fMediaNoiseHist
 
TProfile * fPeakNoiseHist
 
std::vector< TH1D * > corrRMSHistPtr
 
std::vector< TH1D * > uncorrRMSHistPtr
 
std::vector< TH1D * > totalRMSHistPtr
 
std::vector< float > totalRMS
 
std::vector< float > rmsUnc
 
std::vector< float > rmsCorr
 
Eigen::FFT< double > fEigenFFT
 

Detailed Description

Definition at line 43 of file SBNDataNoise_tool.cc.

Member Typedef Documentation

using icarus_tool::SBNDataNoise::CorrFactorsMap = std::map<unsigned int, std::vector<float>>
private

Definition at line 87 of file SBNDataNoise_tool.cc.

using icarus_tool::SBNDataNoise::WaveformTools = icarus_signal_processing::WaveformTools<icarusutil::SigProcPrecision>
private

Definition at line 91 of file SBNDataNoise_tool.cc.

Constructor & Destructor Documentation

icarus_tool::SBNDataNoise::SBNDataNoise ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 130 of file SBNDataNoise_tool.cc.

131 {
132  // Recover the configuration of the tool from the input fhicl file and set up
133  configure(pset);
134  ComputeRMSs();
135 
136  // Output some histograms to catalogue what's been done
137  makeHistograms();
138 }
void configure(const fhicl::ParameterSet &pset) override
icarus_tool::SBNDataNoise::~SBNDataNoise ( )

Definition at line 140 of file SBNDataNoise_tool.cc.

141 {
142 }

Member Function Documentation

void icarus_tool::SBNDataNoise::ComputeRMSs ( )
private

Definition at line 439 of file SBNDataNoise_tool.cc.

440 {
441  // Let's get the rms we expect from the incoherent noise contribution to the waveform
442  // A couple of ways to do this, let's basically invert the frequency spectrum to
443  // produce a waveform and then get the rms from that
444  std::function<void (double[])> randGenFunc = [](double randArray[]){randArray[0]=0.5; randArray[1]=0.5;};
445 
446  icarusutil::TimeVec waveNoise(fIncoherentNoiseVec.back().size());
447  //float scaleFactor = 1.;
448 
449  // GenNoise(randGenFunc, fIncoherentNoiseVec, waveNoise, scaleFactor);
450 
451  // Now get the details...
452  double nSig(3.);
453  double mean,rmsTrunc;
454  int nTrunc;
455  int range;
456 
457  // Use the waveform tool to recover the full rms
458  fWaveformTool.getTruncatedMeanRMS(waveNoise, nSig, mean, fIncoherentNoiseRMS, rmsTrunc, nTrunc, range);
459 
460  // Do the same for the coherent term
461  // GenNoise(randGenFunc, fCoherentNoiseVec, waveNoise, scaleFactor);
462 
463  fWaveformTool.getTruncatedMeanRMS(waveNoise, nSig, mean, fCoherentNoiseRMS, rmsTrunc, nTrunc, range);
464 
465 for(unsigned int jh=0;jh<totalRMSHistPtr.size();jh++) {
466  totalRMS.push_back(totalRMSHistPtr[jh]->GetMean());
467  rmsUnc.push_back(uncorrRMSHistPtr[jh]->GetMean());
468 rmsCorr.push_back(corrRMSHistPtr[jh]->GetMean());
469 fIncoherentNoiseFrac.push_back(rmsUnc.back()/totalRMS.back());
470 //TEMPORARY!
471 //fIncoherentNoiseFrac[jh]=0;
472 std::cout << " index " <<jh << " totalRMS " << totalRMS.back() << std::endl;
473 std::cout << " index " <<jh <<" uncRMS " << rmsUnc.back() << std::endl;
474 std::cout << " index " <<jh <<" corrRMS " << rmsCorr.back() << std::endl;
475 }
476  return;
477 }
std::vector< TH1D * > corrRMSHistPtr
std::vector< float > rmsUnc
std::vector< float > rmsCorr
std::vector< float > fIncoherentNoiseFrac
std::vector< icarusutil::TimeVec > fIncoherentNoiseVec
std::vector< TH1D * > uncorrRMSHistPtr
std::vector< SigProcPrecision > TimeVec
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
std::vector< TH1D * > totalRMSHistPtr
std::vector< float > totalRMS
BEGIN_PROLOG could also be cout
void icarus_tool::SBNDataNoise::configure ( const fhicl::ParameterSet &  pset)
overridevirtual

Implements icarus_tool::IGenNoise.

Definition at line 144 of file SBNDataNoise_tool.cc.

145 {
146  // Recover the histogram used for noise generation
147  fPlane = pset.get< size_t >("Plane");
148  fMedianNumBins = pset.get< int >("MedianNumBins");
149  fNoiseRand = pset.get< float >("NoiseRand");
150  fCorrelatedSeed = pset.get< long >("CorrelatedSeed",1000);
151  fUncorrelatedSeed = pset.get< long >("UncorrelatedSeed",5000);
152  std::vector<float> noiseFracVec = pset.get< std::vector<float> >("IncoherentNoiseFraction", std::vector<float>());
153  for(auto& noiseFrac : noiseFracVec) {
154  fIncoherentNoiseFrac.push_back(float(noiseFrac));
155  }
156  // fIncoherentNoiseFrac = pset.get< float >("IncoherentNoiseFraction",0.5);
157  fStoreHistograms = pset.get< bool >("StoreHistograms");
158 
159  std::vector<std::string> noiseToolParamSetVec = pset.get< std::vector<std::string> >("NoiseHistFileName", std::vector<std::string>());
160  for(auto& noiseToolParams : noiseToolParamSetVec) {
161  fInputNoiseHistFileName.push_back(std::string(noiseToolParams));
162  }
163  // fInputNoiseHistFileName = pset.get< std::string >("NoiseHistFileName");
164  fCorrelatedHistogramName = pset.get< std::string >("CorrelatedHistogramName");
165  fUncorrelatedHistogramName = pset.get< std::string >("UncorrelatedHistogramName");
166  fCorrelatedRMSHistoName = pset.get< std::string >("CorrelatedRMSHistoName");
167  fUncorrelatedRMSHistoName = pset.get< std::string >("UncorrelatedRMSHistoName");
168  fTotalRMSHistoName = pset.get< std::string >("TotalRMSHistoName");
169  // Initialize the work vector
170  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
171  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
172  fNoiseFrequencyVec.resize(detProp.NumberTimeSamples(),std::complex<float>(0.,0.));
173 
174 for(auto& filename : fInputNoiseHistFileName) {
175  // Set up to input the histogram with the overall noise spectrum
176  std::string fullFileName;
177 
178  cet::search_path searchPath("FW_SEARCH_PATH");
179 
180  searchPath.find_file(filename, fullFileName);
181 std::cout << " inputfilename;" << filename << std::endl;
182  std::cout << " fullfilename;" << fullFileName << std::endl;
183  std::cout << "correlated histo name: " << fCorrelatedHistogramName << std::endl;
184 std::cout << "uncorrelated histo name: " << fUncorrelatedHistogramName << std::endl;
185  TFile inputFile(fullFileName.c_str(), "READ");
186 
187  if (!inputFile.IsOpen())
188  throw cet::exception("NoiseFromHist::configure") << "Unable to open input file: " << filename << std::endl;
189 
190  TH1D* corrHistPtr = (TH1D*)inputFile.Get(fCorrelatedHistogramName.c_str());
191  if (!corrHistPtr)
192  throw cet::exception("NoiseFromHist::configure") << "Unable to recover desired histogram: " << fCorrelatedHistogramName << std::endl;
193 
194  TH1D* uncorrHistPtr = (TH1D*)inputFile.Get(fUncorrelatedHistogramName.c_str());
195  if (!inputFile.Get(fUncorrelatedHistogramName.c_str()))
196  throw cet::exception("NoiseFromHist::configure") << "Unable to recover desired histogram: " << fUncorrelatedHistogramName << std::endl;
197 
198  corrRMSHistPtr.push_back((TH1D*)inputFile.Get(fCorrelatedRMSHistoName.c_str()));
199  if (!inputFile.Get(fCorrelatedRMSHistoName.c_str()))
200  throw cet::exception("NoiseFromHist::configure") << "Unable to recover desired histogram: " << fCorrelatedRMSHistoName << std::endl;
201 
202  uncorrRMSHistPtr.push_back((TH1D*)inputFile.Get(fUncorrelatedRMSHistoName.c_str()));
203  if (!inputFile.Get(fUncorrelatedRMSHistoName.c_str()))
204  throw cet::exception("NoiseFromHist::configure") << "Unable to recover desired histogram: " << fUncorrelatedRMSHistoName << std::endl;
205 
206  totalRMSHistPtr.push_back((TH1D*)inputFile.Get(fTotalRMSHistoName.c_str()));
207  if (!inputFile.Get(fTotalRMSHistoName.c_str()))
208  throw cet::exception("NoiseFromHist::configure") << "Unable to recover desired histogram: " << fTotalRMSHistoName << std::endl;
209 
210  // Close the input file
211  inputFile.Close();
212 
213 std::cout << " corr hist nbins " << corrHistPtr->GetNbinsX() << std::endl;
214 std::cout << " uncorr hist nbins " << uncorrHistPtr->GetNbinsX() << std::endl;
215 icarusutil::TimeVec corvec;
216  corvec.resize(corrHistPtr->GetNbinsX(), 0.);
217 
218  // Recover the bin contents into local vectors
219  for(size_t histIdx = 0; histIdx < size_t(corrHistPtr->GetNbinsX()); histIdx++)
220  corvec[histIdx] = corrHistPtr->GetBinContent(histIdx+1);
221 fCoherentNoiseVec.push_back(corvec);
222 icarusutil::TimeVec incvec;
223 incvec.resize(uncorrHistPtr->GetNbinsX(), 0.);
224 
225  // Recover the bin contents into local vectors
226  for(size_t histIdx = 0; histIdx < size_t(uncorrHistPtr->GetNbinsX()); histIdx++)
227  incvec[histIdx] = uncorrHistPtr->GetBinContent(histIdx+1);
228 fIncoherentNoiseVec.push_back(incvec);
229  // Should we store hists?
230 
231 }
232 std::cout << " after filling vectors " << std::endl;
233  if (fStoreHistograms)
234  {
235  // Define histograms
236  art::ServiceHandle<art::TFileService> tfs;
237 
238  art::TFileDirectory* histDirectory = tfs.get();
239 
240  // Make a directory for these histograms
241  art::TFileDirectory dir = histDirectory->mkdir(Form("CorNoisePlane%1zu",fPlane));
242 
243  float sampleRate = sampling_rate(clockData);
244  float readOutSize = detProp.ReadOutWindowSize();
245  float maxFreq = 1.e6 / (2. * sampleRate);
246  float minFreq = 1.e6 / (2. * sampleRate * readOutSize);
247  int numSamples = readOutSize / 2;
248 
249  fInputNoiseHist = dir.make<TProfile>("InNoise", ";freq(kHz)", numSamples, minFreq, maxFreq);
250  fMediaNoiseHist = dir.make<TH1D>("MedNoise", ";ADC", 100, -10., -10.);;
251  fPeakNoiseHist = dir.make<TProfile>("PeakNoise", ";freq(kHz)", numSamples, minFreq, maxFreq);;
252 
253  }
254 
255  // Set up the board->correlated factors map
256  const auto& channelMap = art::ServiceHandle<icarusDB::IICARUSChannelMap const>{}.get();
257 
258  const icarusDB::TPCReadoutBoardToChannelMap& readoutBoardToChannelMap = channelMap->getReadoutBoardToChannelMap();
259 
260  for(const auto& boardPair : readoutBoardToChannelMap)
261  {
262  fCorrFactorsMap.insert({boardPair.first,std::vector<float>(4,0.)});
263  }
264 
265  fCoherentNoiseService = art::ServiceHandle<Noise::ICoherentNoiseFactor>{}.get();
266 
268 
269  return;
270 }
std::vector< TH1D * > corrRMSHistPtr
icarusutil::FrequencyVec fNoiseFrequencyVec
BEGIN_PROLOG could also be dds filename
std::vector< float > fIncoherentNoiseFrac
std::vector< std::string > fInputNoiseHistFileName
std::vector< icarusutil::TimeVec > fIncoherentNoiseVec
std::vector< TH1D * > uncorrRMSHistPtr
std::vector< icarusutil::TimeVec > fCoherentNoiseVec
std::vector< SigProcPrecision > TimeVec
Noise::ICoherentNoiseFactor * fCoherentNoiseService
tuple dir
Definition: dropbox.py:28
std::vector< TH1D * > totalRMSHistPtr
std::map< unsigned int, SlotChannelVecPair > TPCReadoutBoardToChannelMap
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
auto const detProp
void icarus_tool::SBNDataNoise::ExtractUncorrelatedRMS ( float &  cf,
int  index 
) const
private

Definition at line 497 of file SBNDataNoise_tool.cc.

498 {
499 TH1D* histo=uncorrRMSHistPtr[index];
500 
501 
502 float rndRMS=histo->GetRandom();
503 float meanRMS=histo->GetMean();
504 cf=rndRMS/meanRMS;
505 //corrFactor=10;
506 //if(fPlane==1) std::cout << " rndRMS " << rndRMS << " meanRMS " << meanRMS << " corrFactor " << corrFactor << std::endl;
507 }
std::vector< TH1D * > uncorrRMSHistPtr
void icarus_tool::SBNDataNoise::GenerateCorrelatedNoise ( CLHEP::HepRandomEngine &  engine,
icarusutil::TimeVec noise,
double  noise_factor,
unsigned int  board,
unsigned int  index 
)
private

Definition at line 386 of file SBNDataNoise_tool.cc.

387 {
388 
389  // Set the engine seed to the board being considered
390  engine.setSeed(fCorrelatedSeed+board,0);
391 
392  CLHEP::RandFlat noiseGen(engine,0,1);
393 
394  std::function<void (double[])> randGenFunc = [&noiseGen](double randArray[]){noiseGen.fireArray(2,randArray);};
395 
396 
397  float scaleFactor = noise_factor;
398  // std::cout << " fraction " << fraction << " corr scale Factor " << scaleFactor << std::endl;
399  GenNoise(randGenFunc, fCoherentNoiseVec[index], noise, scaleFactor);
400 
401 
402  return;
403 }
void GenNoise(std::function< void(double[])> &, const icarusutil::TimeVec &, icarusutil::TimeVec &, float)
std::vector< icarusutil::TimeVec > fCoherentNoiseVec
void icarus_tool::SBNDataNoise::generateNoise ( CLHEP::HepRandomEngine &  noise_engine,
CLHEP::HepRandomEngine &  cornoise_engine,
icarusutil::TimeVec noise,
detinfo::DetectorPropertiesData const &  ,
double  noise_factor,
const geo::PlaneID planeID,
unsigned int  board 
)
overridevirtual

Implements icarus_tool::IGenNoise.

Definition at line 280 of file SBNDataNoise_tool.cc.

287 {
288 //std::cout << " generating noise channel " << channel << std::endl;
289  //GET THE GEOMETRY.
290 // art::ServiceHandle<geo::Geometry> geom;
291  // get the WireID for this hit
292 // std::vector<geo::WireID> wids = geom->ChannelToWire(channel);
293  // for now, just take the first option returned from ChannelToWire
294 // geo::WireID wid = wids[0];
295  // We need to know the plane to look up parameters
296 
297  size_t cryostat=planeID.Cryostat;
298  size_t tpc=planeID.TPC;
299 // size_t iWire=wid.Wire;
300 //std::cout << " generating noise cryostat " << cryostat << " tpc " << tpc << " wire " << iWire << std::endl;
301 int index=-1;
302 if(cryostat==0&&tpc<2) index=0;
303 if(cryostat==0&&tpc>1) index=1;
304 if(cryostat==1&&tpc<2) index=2;
305 if(cryostat==1&&tpc>1) index=3;
306 
307 //std::cout << " index " << index << std::endl;
308 //std::cout << " totalrms size " << totalRMS.size() << std::endl;
309 
310 // noise_factor=1; ****** not sure why this was done?
311 //noise_factor=totalRMS[index]/3.9;
312 
313 //std::cout << " index " << index << " generating noise totalRMS " << totalRMS[index] << std::endl;
314  // Define a couple of vectors to hold intermediate work
315  icarusutil::TimeVec noise_unc(noise.size(),0.);
316  icarusutil::TimeVec noise_corr(noise.size(),0.);
317 
318  // Make sure the work vector is size right with the output
319  if (fNoiseFrequencyVec.size() != noise.size()) fNoiseFrequencyVec.resize(noise.size(),std::complex<float>(0.,0.));
320  //std::cout << " generating uncorrelated noise " << std::endl;
321  // If applying incoherent noise call the generator
322  GenerateUncorrelatedNoise(engine_unc,noise_unc,noise_factor,index);
323 //int board=iWire/32;
324 
325 
326 //float cf=corrFactors[board][index];
327 
328 CorrFactorsMap::const_iterator corrFactorItr = fCorrFactorsMap.find(board);
329 
330 if (corrFactorItr == fCorrFactorsMap.end()) std::cout << "********************** board " << board << " not found in map!" << std::endl;
331 
332 //float cf = fCorrFactorsMap[board][index];
333 
334 float cf = fCoherentNoiseService->getCoherentNoiseFactor(board,index);
335 
336 
337  GenerateCorrelatedNoise(engine_corr, noise_corr, noise_factor*cf, board, index);
338 
339  // std::cout << " summing noise " << std::endl;
340  // Take the noise as the simple sum of the two contributions
341  std::transform(noise_unc.begin(),noise_unc.end(),noise_corr.begin(),noise.begin(),std::plus<float>());
342 
343  float mediaNoise=0;
344  for(unsigned int jn=0;jn<noise.size();jn++) {
345 //if(!cryostat&&!tpc&&!fPlane&&iWire<2)
346 //{
347 //std::cout << " jn " << jn << " noise sum " << noise.at(jn) << std::endl;
348 //std::cout << " jn " << jn << " noise unc " << noise_unc.at(jn) << std::endl;
349 //std::cout << " jn " << jn << " noise corr " << noise_corr.at(jn) << std::endl;
350 //}
351  mediaNoise+=noise.at(jn);
352 }
353 
354 mediaNoise/=(noise.size());
355 //std::cout << " media noise size " << noise.size() << std::endl;
356 fMediaNoiseHist->Fill(mediaNoise);
357 //std::cout << " media noise " << mediaNoise << std::endl;
358 
359  return;
360 }
icarusutil::FrequencyVec fNoiseFrequencyVec
static constexpr Sample_t transform(Sample_t sample)
virtual float getCoherentNoiseFactor(unsigned int, unsigned int) const =0
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
std::vector< SigProcPrecision > TimeVec
Noise::ICoherentNoiseFactor * fCoherentNoiseService
void GenerateUncorrelatedNoise(CLHEP::HepRandomEngine &, icarusutil::TimeVec &, double, unsigned int)
void GenerateCorrelatedNoise(CLHEP::HepRandomEngine &, icarusutil::TimeVec &, double, unsigned int, unsigned int)
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
BEGIN_PROLOG could also be cout
void icarus_tool::SBNDataNoise::GenerateUncorrelatedNoise ( CLHEP::HepRandomEngine &  engine,
icarusutil::TimeVec noise,
double  noise_factor,
unsigned int  index 
)
private

Definition at line 362 of file SBNDataNoise_tool.cc.

363 {
364  // Here we aim to produce a waveform consisting of incoherent noise
365  // Note that this is expected to be the dominate noise contribution
366  // Check for seed initialization
367  if (fNeedFirstSeed)
368  {
369  engine.setSeed(fUncorrelatedSeed,0);
370  fNeedFirstSeed = false;
371  }
372 
373  // Get the generator
374  CLHEP::RandFlat noiseGen(engine,0,1);
375 
376  std::function<void (double[])> randGenFunc = [&noiseGen](double randArray[]){noiseGen.fireArray(2,randArray);};
377 float cf;
378 ExtractUncorrelatedRMS(cf,index);
379  float scaleFactor = cf*noise_factor;
380  //std::cout << " fraction " << fraction <<" unc scale Factor " << scaleFactor << std::endl;
381  GenNoise(randGenFunc, fIncoherentNoiseVec[index], noise, scaleFactor);
382 
383  return;
384 }
void GenNoise(std::function< void(double[])> &, const icarusutil::TimeVec &, icarusutil::TimeVec &, float)
std::vector< icarusutil::TimeVec > fIncoherentNoiseVec
void ExtractUncorrelatedRMS(float &, int) const
void icarus_tool::SBNDataNoise::GenNoise ( std::function< void(double[])> &  gen,
const icarusutil::TimeVec freqDist,
icarusutil::TimeVec noise,
float  scaleFactor 
)
private

Definition at line 405 of file SBNDataNoise_tool.cc.

406 {
407  double rnd_corr[2] = {0.,0.};
408 
409  // Build out the frequency vector
410  for(size_t i=0; i< noise.size()/2; ++i)
411  {
412 //std::cout << " i " << i << " freqdist " << freqDist[i] << std::endl;
413  // exponential noise spectrum
414  gen(rnd_corr);
415  // if(i!=10) continue;
416  float pval = freqDist[i] * ((1-fNoiseRand) + 2 * fNoiseRand*rnd_corr[0]) * scaleFactor;
417  float phase = rnd_corr[1] * 2. * M_PI;
418  // float pval = freqDist[i]*scaleFactor ;
419  // float phase = 0;
420  std::complex<float> tc(pval*cos(phase),pval*sin(phase));
421 
422  fNoiseFrequencyVec[i] = tc;
423 //std::cout << " i " << i << " noise freqvec " << fNoiseFrequencyVec[i] << std::endl;
424  }
425 
426  // inverse FFT MCSignal
427  fEigenFFT.inv(noise, fNoiseFrequencyVec);
428 // for(unsigned int jn=0;jn<noise.size();jn++) std::cout << " jn " << jn << " noise sum " << noise.at(jn) << std::endl;
429 //exit(22);
430  return;
431 }
icarusutil::FrequencyVec fNoiseFrequencyVec
Eigen::FFT< double > fEigenFFT
void icarus_tool::SBNDataNoise::makeHistograms ( )
private

Definition at line 433 of file SBNDataNoise_tool.cc.

434 {
435 
436  return;
437 }
void icarus_tool::SBNDataNoise::nextEvent ( )
overridevirtual

Implements icarus_tool::IGenNoise.

Definition at line 272 of file SBNDataNoise_tool.cc.

273 {
274  // We update the correlated seed because we want to see different noise event-by-event
275  fCorrelatedSeed = (333 * fCorrelatedSeed) % 900000000;
277  return;
278 }
void icarus_tool::SBNDataNoise::SampleCorrelatedRMSs ( )
private

Definition at line 478 of file SBNDataNoise_tool.cc.

479 {
480  for(size_t index = 0; index < 4; index++)
481  {
482  TH1D* noiseHist = corrRMSHistPtr[index];
483 
484  float meanVal = noiseHist->GetMean();
485 
486  for(auto& correction : fCorrFactorsMap)
487  {
488  float corVal = noiseHist->GetRandom() / meanVal;
489 
490  correction.second[index] = corVal;
491  }
492 
494  }
495 }
std::vector< TH1D * > corrRMSHistPtr
virtual void resetCoherentNoiseFactors(const TH1D *)=0
Noise::ICoherentNoiseFactor * fCoherentNoiseService

Member Data Documentation

std::vector<TH1D*> icarus_tool::SBNDataNoise::corrRMSHistPtr
private

Definition at line 115 of file SBNDataNoise_tool.cc.

double icarus_tool::SBNDataNoise::fCoherentNoiseRMS
private

Definition at line 102 of file SBNDataNoise_tool.cc.

Noise::ICoherentNoiseFactor* icarus_tool::SBNDataNoise::fCoherentNoiseService
private

Definition at line 99 of file SBNDataNoise_tool.cc.

std::vector<icarusutil::TimeVec> icarus_tool::SBNDataNoise::fCoherentNoiseVec
private

Definition at line 97 of file SBNDataNoise_tool.cc.

std::string icarus_tool::SBNDataNoise::fCorrelatedHistogramName
private

Definition at line 81 of file SBNDataNoise_tool.cc.

std::string icarus_tool::SBNDataNoise::fCorrelatedRMSHistoName
private

Definition at line 83 of file SBNDataNoise_tool.cc.

long icarus_tool::SBNDataNoise::fCorrelatedSeed
private

Definition at line 75 of file SBNDataNoise_tool.cc.

CorrFactorsMap icarus_tool::SBNDataNoise::fCorrFactorsMap
private

Definition at line 89 of file SBNDataNoise_tool.cc.

Eigen::FFT<double> icarus_tool::SBNDataNoise::fEigenFFT
private

Definition at line 124 of file SBNDataNoise_tool.cc.

std::string icarus_tool::SBNDataNoise::fHistogramName
private

Definition at line 80 of file SBNDataNoise_tool.cc.

std::vector<float> icarus_tool::SBNDataNoise::fIncoherentNoiseFrac
private

Definition at line 77 of file SBNDataNoise_tool.cc.

double icarus_tool::SBNDataNoise::fIncoherentNoiseRMS
private

Definition at line 101 of file SBNDataNoise_tool.cc.

std::vector<icarusutil::TimeVec> icarus_tool::SBNDataNoise::fIncoherentNoiseVec
private

Definition at line 98 of file SBNDataNoise_tool.cc.

TProfile* icarus_tool::SBNDataNoise::fInputNoiseHist
private

Definition at line 111 of file SBNDataNoise_tool.cc.

std::vector<std::string> icarus_tool::SBNDataNoise::fInputNoiseHistFileName
private

Definition at line 79 of file SBNDataNoise_tool.cc.

int icarus_tool::SBNDataNoise::fMedianNumBins
private

Definition at line 73 of file SBNDataNoise_tool.cc.

TH1D* icarus_tool::SBNDataNoise::fMediaNoiseHist
private

Definition at line 112 of file SBNDataNoise_tool.cc.

bool icarus_tool::SBNDataNoise::fNeedFirstSeed =true
private

Definition at line 108 of file SBNDataNoise_tool.cc.

icarusutil::FrequencyVec icarus_tool::SBNDataNoise::fNoiseFrequencyVec
private

Definition at line 105 of file SBNDataNoise_tool.cc.

float icarus_tool::SBNDataNoise::fNoiseRand
private

Definition at line 74 of file SBNDataNoise_tool.cc.

TProfile* icarus_tool::SBNDataNoise::fPeakNoiseHist
private

Definition at line 113 of file SBNDataNoise_tool.cc.

size_t icarus_tool::SBNDataNoise::fPlane
private

Definition at line 72 of file SBNDataNoise_tool.cc.

bool icarus_tool::SBNDataNoise::fStoreHistograms
private

Definition at line 78 of file SBNDataNoise_tool.cc.

std::string icarus_tool::SBNDataNoise::fTotalRMSHistoName
private

Definition at line 85 of file SBNDataNoise_tool.cc.

std::string icarus_tool::SBNDataNoise::fUncorrelatedHistogramName
private

Definition at line 82 of file SBNDataNoise_tool.cc.

std::string icarus_tool::SBNDataNoise::fUncorrelatedRMSHistoName
private

Definition at line 84 of file SBNDataNoise_tool.cc.

long icarus_tool::SBNDataNoise::fUncorrelatedSeed
private

Definition at line 76 of file SBNDataNoise_tool.cc.

WaveformTools icarus_tool::SBNDataNoise::fWaveformTool
private

Definition at line 93 of file SBNDataNoise_tool.cc.

std::vector<float> icarus_tool::SBNDataNoise::rmsCorr
private

Definition at line 121 of file SBNDataNoise_tool.cc.

std::vector<float> icarus_tool::SBNDataNoise::rmsUnc
private

Definition at line 120 of file SBNDataNoise_tool.cc.

std::vector<float> icarus_tool::SBNDataNoise::totalRMS
private

Definition at line 119 of file SBNDataNoise_tool.cc.

std::vector<TH1D*> icarus_tool::SBNDataNoise::totalRMSHistPtr
private

Definition at line 117 of file SBNDataNoise_tool.cc.

std::vector<TH1D*> icarus_tool::SBNDataNoise::uncorrRMSHistPtr
private

Definition at line 116 of file SBNDataNoise_tool.cc.


The documentation for this class was generated from the following file: