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

Public Member Functions

 RawDigitFilterICARUS (fhicl::ParameterSet const &pset, art::ProcessingFrame const &frame)
 
virtual ~RawDigitFilterICARUS ()
 Destructor. More...
 
virtual void configure (fhicl::ParameterSet const &pset)
 
virtual void produce (art::Event &e, art::ProcessingFrame const &frame)
 
virtual void beginJob (art::ProcessingFrame const &frame)
 Begin job method. More...
 
virtual void endJob (art::ProcessingFrame const &frame)
 End job method. More...
 
void WaveformChar (unsigned int i, unsigned int &fDataSize, unsigned int &fftsize, void *fplan, void *rplan, vector< GroupWireDigIndx > &igwvec, std::vector< const raw::RawDigit * > &rawDigitVec, vector< vector< caldata::RawDigitVector >> &rawadcgvec, vector< vector< WireChar >> &wgcvec, vector< vector< vector< int >>> &wgqvec, std::unique_ptr< std::vector< raw::RawDigit > > &filteredRawDigit) const
 
void RemoveCorrelatedNoise (unsigned int igrp, unsigned int &fftSize, unsigned int &halfFFTSize, void *fplan, void *rplan, vector< vector< caldata::RawDigitVector >> &rawadcgvec, vector< vector< WireChar >> &wgcvec, vector< vector< vector< int >>> &wgqvec, std::unique_ptr< std::vector< raw::RawDigit > > &filteredRawDigit) const
 
 RawDigitFilterICARUS (fhicl::ParameterSet const &pset, art::ProcessingFrame const &frame)
 
virtual ~RawDigitFilterICARUS ()
 
virtual void configure (fhicl::ParameterSet const &pset)
 
virtual void produce (art::Event &e, art::ProcessingFrame const &frame)
 
virtual void beginJob (art::ProcessingFrame const &frame)
 
virtual void endJob (art::ProcessingFrame const &frame)
 

Private Member Functions

template<typename T >
void findPeaks (typename std::vector< T >::iterator startItr, typename std::vector< T >::iterator stopItr, std::vector< std::tuple< size_t, size_t, size_t >> &peakTupleVec, T threshold, size_t firstTick) const
 
void saveRawDigits (std::unique_ptr< std::vector< raw::RawDigit > > &, raw::ChannelID_t &, caldata::RawDigitVector &, float, float)
 
void saveRawDigits (std::unique_ptr< std::vector< raw::RawDigit > > &, raw::ChannelID_t &, caldata::RawDigitVector &, float, float)
 

Private Attributes

std::string fDigitModuleLabel
 The full collection of hits. More...
 
bool fTruncateTicks
 If true then drop ticks off ends of wires. More...
 
bool fTruncateChannels
 If true then we drop channels with "no signal". More...
 
bool fDoFFTCorrection
 Run the FFT noise correction. More...
 
bool fSmoothCorrelatedNoise
 Should we smooth the noise? More...
 
bool fDoCorrelatedNoise
 Process the noise. More...
 
bool fApplyCorSmoothing
 Attempt to smooth the correlated noise correction? More...
 
bool fApplyFFTCorrection
 Use an FFT to get the correlated noise correction. More...
 
bool fApplyTopHatFilter
 Apply the top hat filter. More...
 
unsigned int fWindowSize
 

ticks to keep in window

More...
 
unsigned int fNumTicksToDropFront
 

ticks to drop from front of waveform

More...
 
float fTruncMeanFraction
 Fraction for truncated mean. More...
 
std::vector< size_t > fNumWiresToGroup
 If smoothing, the number of wires to look at. More...
 
std::vector< short > fMinMaxSelectionCut
 Plane by plane cuts for spread cut. More...
 
std::vector< float > fNRmsChannelReject
 

rms to reject channel as no signal

More...
 
std::vector< float > fRmsRejectionCutHi
 Maximum rms for input channels, reject if larger. More...
 
std::vector< float > fRmsRejectionCutLow
 Minimum rms to consider channel "alive". More...
 
std::vector< float > fNumRmsToSmoothVec
 

"sigma" to smooth correlated correction vec

More...
 
std::vector< double > fFFTMinPowerThreshold
 Threshold for trimming FFT power spectrum. More...
 
int fNumEvent
 Number of events seen. More...
 
caldata::RawDigitBinAverageAlg fBinAverageAlg
 
caldata::RawDigitCharacterizationAlg fCharacterizationAlg
 
caldata::RawDigitCorrelatedCorrectionAlg fCorCorrectAlg
 
std::unique_ptr
< caldata::IRawDigitFilter
fRawDigitFilterTool
 
std::map< size_t, std::vector
< std::complex< double > > > 
fFilterVec
 
std::map< size_t,
std::unique_ptr
< icarus_tool::IFilter > > 
fFilterToolMap
 
geo::GeometryCore const * fGeometry
 pointer to Geometry service More...
 
const lariov::DetPedestalProviderfPedestalRetrievalAlg
 Keep track of an instance to the pedestal retrieval alg. More...
 
caldata::ChannelGroups fChannelGroups
 
bool fApplyBinAverage
 Do bin averaging to get rid of high frequency noise. More...
 
std::map< size_t,
icarusutil::FrequencyVec
fFilterVec
 

Detailed Description

Definition at line 70 of file mtRawDigitFilterICARUS_module.cc.

Constructor & Destructor Documentation

RawDigitFilterICARUS::RawDigitFilterICARUS ( fhicl::ParameterSet const &  pset,
art::ProcessingFrame const &  frame 
)
explicit

Constructor.

Arguments:

pset - Fcl parameters.

Definition at line 230 of file mtRawDigitFilterICARUS_module.cc.

230  :
231  art::ReplicatedProducer(pset, frame),
232  fNumEvent(0),
233  fBinAverageAlg(pset),
234  fCharacterizationAlg(pset.get<fhicl::ParameterSet>("CharacterizationAlg")),
235  fCorCorrectAlg(pset.get<fhicl::ParameterSet>("CorrelatedCorrectionAlg")),
236  fPedestalRetrievalAlg(*lar::providerFrom<lariov::DetPedestalService>()),
237  fChannelGroups(pset)
238 {
239 
240  fGeometry = lar::providerFrom<geo::Geometry>();
241 
242  configure(pset);
243  produces<std::vector<raw::RawDigit> >();
244 
245  // Report.
246  mf::LogInfo("RawDigitFilterICARUS") << "RawDigitFilterICARUS configured\n";
247 }
caldata::RawDigitCorrelatedCorrectionAlg fCorCorrectAlg
const lariov::DetPedestalProvider & fPedestalRetrievalAlg
Keep track of an instance to the pedestal retrieval alg.
caldata::RawDigitCharacterizationAlg fCharacterizationAlg
int fNumEvent
Number of events seen.
caldata::ChannelGroups fChannelGroups
virtual void configure(fhicl::ParameterSet const &pset)
caldata::RawDigitBinAverageAlg fBinAverageAlg
geo::GeometryCore const * fGeometry
pointer to Geometry service
RawDigitFilterICARUS::~RawDigitFilterICARUS ( )
virtual

Destructor.

Definition at line 250 of file mtRawDigitFilterICARUS_module.cc.

251 {}
RawDigitFilterICARUS::RawDigitFilterICARUS ( fhicl::ParameterSet const &  pset,
art::ProcessingFrame const &  frame 
)
explicit
virtual RawDigitFilterICARUS::~RawDigitFilterICARUS ( )
virtual

Member Function Documentation

void RawDigitFilterICARUS::beginJob ( art::ProcessingFrame const &  frame)
virtual

Begin job method.

Definition at line 293 of file mtRawDigitFilterICARUS_module.cc.

294 {
295  // Access ART's TFileService, which will handle creating and writing
296  // histograms and n-tuples for us.
297  art::ServiceHandle<art::TFileService> tfs;
298 
301 
302  art::TFileDirectory dir = tfs->mkdir(Form("RawDigitFilter"));
303 
304  fRawDigitFilterTool->initializeHistograms(dir);
305 
306  return;
307 }
caldata::RawDigitCorrelatedCorrectionAlg fCorCorrectAlg
caldata::RawDigitCharacterizationAlg fCharacterizationAlg
void initializeHists(art::ServiceHandle< art::TFileService > &)
Begin job method.
tuple dir
Definition: dropbox.py:28
std::unique_ptr< caldata::IRawDigitFilter > fRawDigitFilterTool
art::ServiceHandle< art::TFileService > tfs
void initializeHists(art::ServiceHandle< art::TFileService > &)
Begin job method.
virtual void RawDigitFilterICARUS::beginJob ( art::ProcessingFrame const &  frame)
virtual
void RawDigitFilterICARUS::configure ( fhicl::ParameterSet const &  pset)
virtual

Reconfigure method.

Arguments:

pset - Fcl parameter set.

Definition at line 254 of file mtRawDigitFilterICARUS_module.cc.

255 {
256  fDigitModuleLabel = pset.get<std::string> ("DigitModuleLabel", "daq");
257  fWindowSize = pset.get<size_t> ("WindowSize", 6400);
258  fTruncateTicks = pset.get<bool> ("TruncateTicks", false);
259  fNumTicksToDropFront = pset.get<size_t> ("NumTicksToDropFront", 2400);
260  fTruncateChannels = pset.get<bool> ("TruncateChannels", false);
261  fDoFFTCorrection = pset.get<bool> ("FFTNoise", true);
262  fNRmsChannelReject = pset.get<std::vector<float>> ("NRMSChannelReject", std::vector<float>() = {3., 3., 3. });
263  fSmoothCorrelatedNoise = pset.get<bool> ("SmoothCorrelatedNoise", true);
264  // .. waveform characterization
265  fRmsRejectionCutHi = pset.get<std::vector<float>> ("RMSRejectionCutHi", std::vector<float>() = {25.0,25.0,25.0});
266  fRmsRejectionCutLow = pset.get<std::vector<float>> ("RMSRejectionCutLow", std::vector<float>() = {0.70,0.70,0.70});
267  fMinMaxSelectionCut = pset.get<std::vector<short>> ("MinMaxSelectionCut", std::vector<short>() = {13, 13, 11});
268  // .. correlated noise correction
269  fNumWiresToGroup = pset.get<std::vector<size_t>>("NumWiresToGroup", std::vector<size_t>() = {48, 48, 96});
270  fDoCorrelatedNoise = pset.get<bool> ("ProcessNoise", true);
271  fApplyCorSmoothing = pset.get<bool> ("ApplyCorSmoothing", true);
272  fTruncMeanFraction = pset.get<float> ("TruncMeanFraction", 0.15);
273  fNumRmsToSmoothVec = pset.get<std::vector<float>> ("NumRmsToSmooth", std::vector<float>() = {3.6, 3.6, 4.});
274  fApplyFFTCorrection = pset.get<bool> ("ApplyFFTCorrection", true);
275  fFFTMinPowerThreshold = pset.get<std::vector<double>>("FFTPowerThreshold", std::vector<double>() = {100.,75.,500.});
276  fApplyTopHatFilter = pset.get<bool> ("ApplyTopHatFilter", true);
277 
278  fRawDigitFilterTool = art::make_tool<caldata::IRawDigitFilter>(pset.get<fhicl::ParameterSet>("RawDigitFilterTool"));
279 
280  // Implement the tools for handling the responses
281  const fhicl::ParameterSet& filterTools = pset.get<fhicl::ParameterSet>("FilterTools");
282 
283  for(const std::string& filterTool : filterTools.get_pset_names())
284  {
285  const fhicl::ParameterSet& filterToolParamSet = filterTools.get<fhicl::ParameterSet>(filterTool);
286  size_t planeIdx = filterToolParamSet.get<size_t>("Plane");
287 
288  fFilterToolMap.insert(std::pair<size_t,std::unique_ptr<icarus_tool::IFilter>>(planeIdx,art::make_tool<icarus_tool::IFilter>(filterToolParamSet)));
289  }
290 }
bool fTruncateChannels
If true then we drop channels with &quot;no signal&quot;.
bool fApplyFFTCorrection
Use an FFT to get the correlated noise correction.
std::vector< short > fMinMaxSelectionCut
Plane by plane cuts for spread cut.
float fTruncMeanFraction
Fraction for truncated mean.
bool fTruncateTicks
If true then drop ticks off ends of wires.
std::string fDigitModuleLabel
The full collection of hits.
unsigned int fWindowSize
ticks to keep in window
bool fDoFFTCorrection
Run the FFT noise correction.
bool fDoCorrelatedNoise
Process the noise.
std::vector< float > fRmsRejectionCutHi
Maximum rms for input channels, reject if larger.
bool fApplyCorSmoothing
Attempt to smooth the correlated noise correction?
bool fSmoothCorrelatedNoise
Should we smooth the noise?
bool fApplyTopHatFilter
Apply the top hat filter.
unsigned int fNumTicksToDropFront
ticks to drop from front of waveform
std::vector< double > fFFTMinPowerThreshold
Threshold for trimming FFT power spectrum.
std::vector< float > fRmsRejectionCutLow
Minimum rms to consider channel &quot;alive&quot;.
std::unique_ptr< caldata::IRawDigitFilter > fRawDigitFilterTool
std::vector< float > fNumRmsToSmoothVec
&quot;sigma&quot; to smooth correlated correction vec
std::map< size_t, std::unique_ptr< icarus_tool::IFilter > > fFilterToolMap
std::vector< size_t > fNumWiresToGroup
If smoothing, the number of wires to look at.
std::vector< float > fNRmsChannelReject
rms to reject channel as no signal
virtual void RawDigitFilterICARUS::configure ( fhicl::ParameterSet const &  pset)
virtual
void RawDigitFilterICARUS::endJob ( art::ProcessingFrame const &  frame)
virtual

End job method.

Definition at line 934 of file mtRawDigitFilterICARUS_module.cc.

935 {
936  mf::LogInfo("RawDigitFilterICARUS") << "Looked at " << fNumEvent << " events" << std::endl;
937 }
int fNumEvent
Number of events seen.
virtual void RawDigitFilterICARUS::endJob ( art::ProcessingFrame const &  frame)
virtual
template<typename T >
void RawDigitFilterICARUS::findPeaks ( typename std::vector< T >::iterator  startItr,
typename std::vector< T >::iterator  stopItr,
std::vector< std::tuple< size_t, size_t, size_t >> &  peakTupleVec,
threshold,
size_t  firstTick 
) const
private

Definition at line 838 of file mtRawDigitFilterICARUS_module.cc.

843 {
844  // Need a minimum distance or else nothing to do
845  if (std::distance(startItr,stopItr) > 4)
846  {
847  // This is a divide and conquer algorithm, start by finding the maximum element.
848  typename std::vector<T>::iterator firstItr = std::max_element(startItr,stopItr,[](float left, float right){return std::fabs(left) < std::fabs(right);});
849 
850  // Are we over threshold?
851  if (std::fabs(*firstItr) > threshold)
852  {
853  // What am I thinking?
854  // First task is to find the "other" lobe max point
855  // Set one to the "first", the other to the "second"
856  // Search backward from first to find start point, forward from second to find end point
857  // Set mid point between first and second as "peak"?
858  typename std::vector<T>::iterator secondItr = firstItr;
859 
860  // Assume if max bin is positive then second lobe is later
861  if (*firstItr > 0)
862  {
863  typename std::vector<T>::iterator tempItr = secondItr;
864 
865  while(tempItr != stopItr)
866  {
867  if (*++tempItr < -threshold)
868  {
869  if (*tempItr < *secondItr) secondItr = tempItr;
870  }
871  else if (secondItr != firstItr) break;
872  }
873  }
874  // Otherwise it goes the other way
875  else
876  {
877  typename std::vector<T>::iterator tempItr = secondItr;
878 
879  while(tempItr != startItr)
880  {
881  if (*--tempItr > threshold)
882  {
883  if (*tempItr > *secondItr) secondItr = tempItr;
884  }
885  else if (secondItr != firstItr) break;
886  }
887 
888  std::swap(firstItr,secondItr);
889  }
890 
891  // It might that no real pulse was found
892  if (firstItr != secondItr)
893  {
894  // Get the "peak" position
895  size_t peakBin = std::distance(startItr,firstItr) + std::distance(firstItr,secondItr) / 2;
896 
897  // Advance (forward or backward) the first and second iterators to get back to zero crossing
898  while(firstItr != startItr) if (*--firstItr < 0.) break;
899  while(secondItr != stopItr) if (*++secondItr > 0.) break;
900 
901  size_t firstBin = std::distance(startItr,firstItr);
902  size_t lastBin = std::distance(startItr,secondItr);
903 
904  // Find leading peaks
905  findPeaks(startItr, firstItr, peakTupleVec, threshold, firstTick);
906 
907  // Save this peak
908  peakTupleVec.push_back(std::tuple<size_t,size_t,size_t>(firstBin+firstTick,peakBin+firstTick,lastBin+firstTick));
909 
910  // Find downstream peaks
911  findPeaks(secondItr, stopItr, peakTupleVec, threshold, firstTick + std::distance(startItr,secondItr));
912  }
913  }
914  }
915 
916  return;
917 }
walls no right
Definition: selectors.fcl:105
void findPeaks(typename std::vector< T >::iterator startItr, typename std::vector< T >::iterator stopItr, std::vector< std::tuple< size_t, size_t, size_t >> &peakTupleVec, T threshold, size_t firstTick) const
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
walls no left
Definition: selectors.fcl:105
void RawDigitFilterICARUS::produce ( art::Event &  event,
art::ProcessingFrame const &  frame 
)
virtual

Produce method.

Arguments:

evt - Art event.

This is the primary method.

Definition at line 310 of file mtRawDigitFilterICARUS_module.cc.

311 {
312  ++fNumEvent;
313 
314  // Read in the digit List object(s).
315  art::Handle< std::vector<raw::RawDigit> > digitVecHandle;
316  event.getByLabel(fDigitModuleLabel, digitVecHandle);
317 
318  // Agreed convention is to ALWAYS output to the event store so get a pointer to our collection
319  std::unique_ptr<std::vector<raw::RawDigit> > filteredRawDigit(new std::vector<raw::RawDigit>);
320  filteredRawDigit->resize(digitVecHandle->size());
321  //std::cout << " ~~~~~ Initial size of filteredRawDigit: " << filteredRawDigit->size() << std::endl;
322 
323  // ... Require a valid handle
324  if (digitVecHandle.isValid() && digitVecHandle->size()>0 ){
325  unsigned int maxChannels = fGeometry->Nchannels();
326 
327  // .. Let's first sort the rawDigitVec
328  std::vector<const raw::RawDigit*> rawDigitVec;
329  for(size_t idx = 0; idx < digitVecHandle->size(); idx++) rawDigitVec.push_back(&digitVecHandle->at(idx));
330  std::sort(rawDigitVec.begin(),rawDigitVec.end(),
331  [](const raw::RawDigit* left, const raw::RawDigit* right) {return left->Channel() < right->Channel();});
332 
333  // .. Use the handle to get a particular (0th) element of collection.
334  art::Ptr<raw::RawDigit> digitVec0(digitVecHandle, 0);
335  unsigned int fDataSize = digitVec0->Samples(); //size of raw data vectors
336  unsigned int fftSize;
337  if (fTruncateTicks) {
338  fftSize = fWindowSize;
339  } else {
340  fftSize = fDataSize;
341  }
342  vector<short> rawadc;
343  rawadc.resize(fftSize);
344 
345  vector<vector<caldata::RawDigitVector>> rawadcgvec;
346  vector<vector<WireChar>> wgcvec;
347  vector<vector<vector <int>>> wgqvec;
348  vector<GroupWireDigIndx>igwvec;
349 
350  vector<caldata::RawDigitVector> rawadcvec;
351  vector<WireChar> wcvec;
352  vector<vector<int>>wqvec;
353  wqvec.push_back({});
354  wqvec.push_back({});
355  int irawdig=-1;
356 
357  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358  // ... Do a first loop over all the rawDigits to set up the grouped vectors
359  // for:
360  // wgcvec: wire charactestics
361  // wgqvec: wire quality
362  // rawdcgvec: uncompressed raw adcs
363  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
364  for(const auto& rawDigit : rawDigitVec){
365 
366  irawdig++;
367 
368  raw::ChannelID_t channel = rawDigit->Channel();
369  bool goodChan(true);
370  std::vector<geo::WireID> wids;
371  try {
372  wids = fGeometry->ChannelToWire(channel);
373  }
374  catch(...){
375  goodChan = false;
376  }
377  if (channel >= maxChannels || !goodChan) continue;
378 
379  unsigned int plane = wids[0].Plane;
380  unsigned int wire = wids[0].Wire;
381 
382  // .. Verify that dataSize looks fine
383  unsigned int dataSize = rawDigit->Samples();
384  if (dataSize < 1){
385  std::cout << "****>> Found zero length raw digit buffer, channel: "
386  << channel << ", plane: " << plane << ", wire: " << wire << std::endl;
387  continue;
388  }else if (dataSize!=fDataSize) {
389  std::cout << "****>> DataSize has changed from " << fDataSize << " to " << dataSize
390  << " for channel: " << channel << ", plane: " << plane << ", wire: " << wire << std::endl;
391  continue;
392  }
393  rawadcvec.push_back(rawadc);
394 
395  unsigned int wireIdx = wire % fNumWiresToGroup[plane];
396  //std::cout << "Channel = " << channel << " wire = " << wire
397  // << " plane = " << plane << " wireIdx = " << wireIdx << std::endl;
398 
399  WireChar wc;
400  wc.wire = wire;
401  wc.plane = plane;
402  wc.channel = channel;
403  wc.wireIdx = wireIdx;
404  wc.irawdig = irawdig;
405  wcvec.push_back(wc);
406 
407  GroupWireDigIndx igw;
408  igw.windx=int(wcvec.size()-1);
409  igw.irawdig=irawdig;
410  igw.group=int(wgcvec.size());
411 
412  igw.qgroup=-1;
413  size_t group = fChannelGroups.channelGroup(plane,wire);
414  if (group==0) {
415  wqvec[0].push_back(wcvec.size()-1);
416  igw.qgroup=0;
417  igw.qgindx=wqvec[0].size()-1;
418  } else if (group==1){
419  wqvec[1].push_back(wcvec.size()-1);
420  igw.qgroup=1;
421  igw.qgindx=wqvec[1].size()-1;
422  }
423 
424  igwvec.push_back(igw);
425 
426  // Are we at the correct boundary for dealing with the noise?
427  if (!((wireIdx + 1) % fNumWiresToGroup[plane])){
428  //std::cout << "!!!! Reached boundary to group wires" << std::endl;
429  rawadcgvec.push_back(rawadcvec);
430  wgcvec.push_back(wcvec);
431  wgqvec.push_back(wqvec);
432  rawadcvec.clear();
433  wcvec.clear();
434  wqvec[0].clear();
435  wqvec[1].clear();
436  }
437  }
438 
439  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
440  // ... Now that we have set up the data structures above, we can peform
441  // the FFT correction and determine the waveform parameters for each
442  // individual wire.
443  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
444 
445  // .. First set up the filters
446  unsigned int halfFFTSize(fftSize/2 + 1);
447  for(unsigned int plne = 0; plne < 3; plne++)
448  {
449  fFilterToolMap.at(plne)->setResponse(fftSize,1.,1.);
450  fFilterVec[plne] = fFilterToolMap.at(plne)->getResponseVec();
451  }
452 
453  // .. Now set up the fftw plan
454  util::LArFFTWPlan lfftwp(fftSize,"ES");
455 
456  //int nwavedump = 0;
457 
458  //for (std::size_t i=0; i<igwvec.size(); i++){
459  // WaveformChar(i, fDataSize, igwvec, rawDigitVec, rawadcgvec, wgcvec, filteredRawDigit);
460  //}
461  // ... Launch multiple threads with TBB to do the waveform characterization and fft correction in parallel
462  auto func = lartbb_WaveformChar(*this, fDataSize, fftSize, lfftwp.fPlan, lfftwp.rPlan, igwvec, rawDigitVec,
463  rawadcgvec, wgcvec, wgqvec, filteredRawDigit);
464  tbb::parallel_for(tbb::blocked_range<size_t>(0, igwvec.size()), func);
465 
466  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
467  // ... Next, we can do the correlated noise correction for each wire group
468  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
469 
471 
472  // .. Loop over each group of wires
473  //for (size_t igrp = 0; igrp < wgcvec.size(); igrp++) {
474  // RemoveCorrelatedNoise(igrp, fftSize, halfFFTSize, lfftwp.fPlan, lfftwp.rPlan, rawadcgvec, wgcvec, wgqvec, filteredRawDigit);
475  //} // loop over igrp
476  auto func = lartbb_RemoveCorrelatedNoise(*this, fftSize, halfFFTSize, lfftwp.fPlan, lfftwp.rPlan,
477  rawadcgvec, wgcvec, wgqvec, filteredRawDigit);
478  tbb::parallel_for(tbb::blocked_range<size_t>(0, wgcvec.size()), func);
479  } // if do and smooth correlated noise
480 
481  filteredRawDigit->erase(std::remove_if(filteredRawDigit->begin(),filteredRawDigit->end(),
482  [](const raw::RawDigit & frd){return frd.ADCs().size()==0;}),
483  filteredRawDigit->end());
484 
485  rawadcgvec.clear();
486  wgcvec.clear();
487  wgqvec.clear();
488  igwvec.clear();
489 
490  }
491 
492  //std::cout << " ~~~~~ Final size of filteredRawDigit: " << filteredRawDigit->size() << std::endl;
493 
494  // Add tracks and associations to event.
495  event.put(std::move(filteredRawDigit));
496 }
raw::ChannelID_t channel
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
bool fTruncateTicks
If true then drop ticks off ends of wires.
walls no right
Definition: selectors.fcl:105
ChannelID_t Channel() const
DAQ channel this raw data was read from.
Definition: RawDigit.h:212
std::string fDigitModuleLabel
The full collection of hits.
unsigned int fWindowSize
ticks to keep in window
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
bool fDoCorrelatedNoise
Process the noise.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
int fNumEvent
Number of events seen.
size_t channelGroup(size_t view, size_t wire) const
bool fSmoothCorrelatedNoise
Should we smooth the noise?
walls no left
Definition: selectors.fcl:105
std::map< size_t, std::vector< std::complex< double > > > fFilterVec
caldata::ChannelGroups fChannelGroups
geo::GeometryCore const * fGeometry
pointer to Geometry service
std::map< size_t, std::unique_ptr< icarus_tool::IFilter > > fFilterToolMap
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
std::vector< size_t > fNumWiresToGroup
If smoothing, the number of wires to look at.
BEGIN_PROLOG could also be cout
virtual void RawDigitFilterICARUS::produce ( art::Event &  e,
art::ProcessingFrame const &  frame 
)
virtual
void RawDigitFilterICARUS::RemoveCorrelatedNoise ( unsigned int  igrp,
unsigned int &  fftSize,
unsigned int &  halfFFTSize,
void *  fplan,
void *  rplan,
vector< vector< caldata::RawDigitVector >> &  rawadcgvec,
vector< vector< WireChar >> &  wgcvec,
vector< vector< vector< int >>> &  wgqvec,
std::unique_ptr< std::vector< raw::RawDigit > > &  filteredRawDigit 
) const

Definition at line 499 of file mtRawDigitFilterICARUS_module.cc.

503  {
504 
505  for (size_t iq = 0; iq < 2; iq++) {
506 
507  if (wgqvec[igrp][iq].size() == 0) continue;
508 
509  // .. Remove the unclassified wires whose indices have been set to negative
510  wgqvec[igrp][iq].erase(std::remove_if(wgqvec[igrp][iq].begin(),wgqvec[igrp][iq].end(),[](const int& i){return i<0;}),wgqvec[igrp][iq].end());
511 
512  // .. Don't try to do correction if too few wires unless they have gaps
513  size_t nwq = wgqvec[igrp][iq].size();
514  if (nwq <= 2) continue;
515 
516  std::vector<float> corValVec;
517  corValVec.resize(fftSize, 0.);
518 
519  // ----------------------------------------------------
520  // .. Build the vector of corrections for each time bin
521  // ----------------------------------------------------
522  for(size_t itck = 0; itck < fftSize; itck++){
523  std::vector<float> adcValuesVec;
524  // .. Loop over each entry in wgqvec[igrp][iq]
525  for (size_t i = 0; i < nwq; i++) {
526  // .. get index into the wgvec[igrp] array
527  size_t iwdx = wgqvec[igrp][iq][i];
528  // .. Check that we should be doing something in this range
529  // Note that if the wire is not to be considered then the "start" bin will be after the last bin
530  if (itck < wgcvec[igrp][iwdx].tcka || itck >= wgcvec[igrp][iwdx].tckb) continue;
531  // .. Accumulate
532  adcValuesVec.push_back(float(rawadcgvec[igrp][iwdx][itck]) - wgcvec[igrp][iwdx].truncMean);
533  }
534  // ... Get the median for this time tick across all wires in the group
535  float medval(-10000);
536  if (!adcValuesVec.empty()) {
537  std::sort(adcValuesVec.begin(),adcValuesVec.end());
538  size_t medidx = adcValuesVec.size() / 2;
539  medval = adcValuesVec[medidx];
540  if (adcValuesVec.size() > 1 && medidx % 2) medval = (medval + adcValuesVec[medidx+1]) / 2;
541  }
542  corValVec[itck] = std::max(medval,float(-10000.));
543  } // loop over itck
544 
545  // .. get the plane number for first wire in this set, for use below
546  size_t iwdx0 = wgqvec[igrp][iq][0];
547  unsigned int plane = wgcvec[igrp][iwdx0].plane;
548 
549  // --------------------------------------
550  // ... Try to eliminate any real outliers
551  // --------------------------------------
552  if (fApplyCorSmoothing) {
553  std::vector<float> localCorValVec = corValVec;
554  std::sort(localCorValVec.begin(),localCorValVec.end());
555 
556  int nTruncVal = (1. - fTruncMeanFraction) * localCorValVec.size();
557  float corValSum = std::accumulate(localCorValVec.begin(),localCorValVec.begin() + nTruncVal,0.);
558  float meanCorVal = corValSum / float(nTruncVal);
559 
560  std::vector<float> diffVec(nTruncVal);
561  std::transform(localCorValVec.begin(),localCorValVec.begin() + nTruncVal, diffVec.begin(),
562  std::bind(std::minus<float>(),std::placeholders::_1,meanCorVal));
563 
564  float rmsValSq = std::inner_product(diffVec.begin(),diffVec.end(),diffVec.begin(),0.);
565  float rmsVal = std::sqrt(rmsValSq / float(nTruncVal));
566 
567  // .. Now set up to run through and do a "simple" interpolation over outliers
568  std::vector<float>::iterator lastGoodItr = corValVec.begin();
569  bool wasOutlier(false);
570  for(std::vector<float>::iterator corValItr = lastGoodItr+1; corValItr != corValVec.end(); corValItr++){
571  if (fabs(*corValItr - meanCorVal) < fNumRmsToSmoothVec.at(plane)*rmsVal){
572  if (wasOutlier){
573  float lastVal = *lastGoodItr;
574  float curVal = *corValItr;
575  float numTicks = std::distance(lastGoodItr,corValItr);
576  float slope = (curVal - lastVal) / numTicks;
577  while(lastGoodItr != corValItr){
578  *lastGoodItr++ = (numTicks - std::distance(lastGoodItr,corValItr)) * slope + lastVal;
579  }
580  }
581  wasOutlier = false;
582  lastGoodItr = corValItr;
583  } else {
584  wasOutlier = true;
585  }
586  }
587  } // fApplyCorSmoothing
588 
589  // ... Get the FFT correction
590  if (fApplyFFTCorrection) {
591  std::vector<std::complex<double>> fftOutputVec(halfFFTSize);
592  util::LArFFTW lfftw(fftSize, fplan, rplan, 0);
593  lfftw.DoFFT(corValVec, fftOutputVec);
594 
595  std::vector<double> powerVec(halfFFTSize);
596  std::transform(fftOutputVec.begin(), fftOutputVec.begin() + halfFFTSize, powerVec.begin(), [](const auto& val){return std::abs(val);});
597 
598  // Want the first derivative
599  std::vector<double> firstDerivVec(powerVec.size(), 0.);
600 
601  //fWaveformTool->firstDerivative(powerVec, firstDerivVec);
602  for(size_t idx = 1; idx < firstDerivVec.size() - 1; idx++)
603  firstDerivVec.at(idx) = 0.5 * (powerVec.at(idx + 1) - powerVec.at(idx - 1));
604 
605  // Find the peaks
606  std::vector<std::tuple<size_t,size_t,size_t>> peakTupleVec;
607 
608  findPeaks(firstDerivVec.begin(),firstDerivVec.end(),peakTupleVec,fFFTMinPowerThreshold[plane],0);
609 
610  if (!peakTupleVec.empty())
611  {
612  for(const auto& peakTuple : peakTupleVec)
613  {
614  size_t startTick = std::get<0>(peakTuple);
615  size_t stopTick = std::get<2>(peakTuple);
616 
617  if (stopTick > startTick)
618  {
619  std::complex<double> slope = (fftOutputVec[stopTick] - fftOutputVec[startTick]) / double(stopTick - startTick);
620 
621  for(size_t tick = startTick; tick < stopTick; tick++)
622  {
623  std::complex<double> interpVal = fftOutputVec[startTick] + double(tick - startTick) * slope;
624 
625  fftOutputVec[tick] = interpVal;
626  //fftOutputVec[fftDataSize - tick - 1] = interpVal;
627  }
628  }
629  }
630 
631  std::vector<double> tmpVec(corValVec.size());
632 
633  lfftw.DoInvFFT(fftOutputVec, tmpVec);
634 
635  std::transform(corValVec.begin(),corValVec.end(),tmpVec.begin(),corValVec.begin(),std::minus<double>());
636  }
637  } // fApplyFFTCorrection
638 
639  // -------------------------------------------
640  // ... Now go through and apply the correction
641  // -------------------------------------------
642  for(size_t itck = 0; itck < fftSize; itck++){
643  for (size_t i = 0; i < nwq; i++) {
644  float corVal;
645  size_t iwdx = wgqvec[igrp][iq][i];
646  // .. If the "start" bin is after the "stop" bin then we are meant to skip this wire in the averaging process
647  // Or if the sample index is in a chirping section then no correction is applied.
648  // Both cases are handled by looking at the sampleIdx
649  if (itck < wgcvec[igrp][iwdx].tcka || itck >= wgcvec[igrp][iwdx].tckb) {
650  corVal=0.;
651  } else {
652  corVal = corValVec[itck];
653  }
654  // .. Probably doesn't matter, but try to get slightly more accuracy by doing float math and rounding
655  float newAdcValueFloat = float(rawadcgvec[igrp][iwdx][itck]) - corVal - wgcvec[igrp][iwdx].pedCor;
656  rawadcgvec[igrp][iwdx][itck] = std::round(newAdcValueFloat);
657  }
658  }
659  } // loop over iq
660 
661  // ----------------------------------------------------
662  // ... One more pass through to store the good channels
663  // ----------------------------------------------------
664  for (size_t iwdx = 0; iwdx < wgcvec[igrp].size(); iwdx++) {
665 
666  unsigned int plane = wgcvec[igrp][iwdx].plane;
667 
668  // Try baseline correction?
669  if (fApplyTopHatFilter && plane != 2 && wgcvec[igrp][iwdx].skewness > 0.) {
670  fRawDigitFilterTool->FilterWaveform(rawadcgvec[igrp][iwdx], iwdx, plane);
671  }
672 
673  // recalculate rms for the output
674  float rmsVal = 0.;
675  float pedestal = wgcvec[igrp][iwdx].truncMean;
676  float pedCor = wgcvec[igrp][iwdx].pedCor;
677  float deltaPed = pedestal - pedCor;
678 
679  caldata::RawDigitVector& rawDataVec = rawadcgvec[igrp][iwdx];
680  fCharacterizationAlg.getTruncatedRMS(rawDataVec, deltaPed, rmsVal);
681 
682  // The ultra high noise channels are simply zapped
683  raw::ChannelID_t channel = wgcvec[igrp][iwdx].channel;
684  if (rmsVal < fRmsRejectionCutHi[plane]) { // && ImAGoodWire(plane,baseWireIdx + locWireIdx))
685  int irdg = wgcvec[igrp][iwdx].irawdig;
686  //saveRawDigits(filteredRawDigit, channelWireVec[locWireIdx], rawDataVec, pedestal, rmsVal);
687  filteredRawDigit->at(irdg) = raw::RawDigit(channel, rawDataVec.size(), rawDataVec, raw::kNone);
688  filteredRawDigit->at(irdg).SetPedestal(pedestal, rmsVal);
689  } else {
690  mf::LogInfo("RawDigitFilterICARUS") << "--> Rejecting channel for large rms, channel: "
691  << channel << ", rmsVal: " << rmsVal << ", truncMean: " << pedestal
692  << ", pedestal: " << pedCor << std::endl;
693  }
694  } // loop over igrp
695 
696 }
bool fApplyFFTCorrection
Use an FFT to get the correlated noise correction.
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
static constexpr Sample_t transform(Sample_t sample)
float fTruncMeanFraction
Fraction for truncated mean.
raw::RawDigit::ADCvector_t RawDigitVector
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
std::vector< float > fRmsRejectionCutHi
Maximum rms for input channels, reject if larger.
caldata::RawDigitCharacterizationAlg fCharacterizationAlg
no compression
Definition: RawTypes.h:9
void findPeaks(typename std::vector< T >::iterator startItr, typename std::vector< T >::iterator stopItr, std::vector< std::tuple< size_t, size_t, size_t >> &peakTupleVec, T threshold, size_t firstTick) const
T abs(T value)
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
bool fApplyCorSmoothing
Attempt to smooth the correlated noise correction?
bool fApplyTopHatFilter
Apply the top hat filter.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
std::vector< double > fFFTMinPowerThreshold
Threshold for trimming FFT power spectrum.
void getTruncatedRMS(const RawDigitVector &rawWaveform, float &pedestal, float &truncRms) const
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
std::unique_ptr< caldata::IRawDigitFilter > fRawDigitFilterTool
std::vector< float > fNumRmsToSmoothVec
&quot;sigma&quot; to smooth correlated correction vec
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void RawDigitFilterICARUS::saveRawDigits ( std::unique_ptr< std::vector< raw::RawDigit > > &  ,
raw::ChannelID_t ,
caldata::RawDigitVector ,
float  ,
float   
)
private
void RawDigitFilterICARUS::saveRawDigits ( std::unique_ptr< std::vector< raw::RawDigit > > &  filteredRawDigit,
raw::ChannelID_t channel,
caldata::RawDigitVector rawDigitVec,
float  pedestal,
float  rms 
)
private

Definition at line 920 of file mtRawDigitFilterICARUS_module.cc.

925 {
926  //filteredRawDigit->emplace_back(raw::RawDigit(channel, rawDigitVec.size(), rawDigitVec, raw::kNone));
927  filteredRawDigit->emplace_back(channel, rawDigitVec.size(), rawDigitVec, raw::kNone);
928  filteredRawDigit->back().SetPedestal(pedestal,rms);
929 
930  return;
931 }
no compression
Definition: RawTypes.h:9
void RawDigitFilterICARUS::WaveformChar ( unsigned int  i,
unsigned int &  fDataSize,
unsigned int &  fftsize,
void *  fplan,
void *  rplan,
vector< GroupWireDigIndx > &  igwvec,
std::vector< const raw::RawDigit * > &  rawDigitVec,
vector< vector< caldata::RawDigitVector >> &  rawadcgvec,
vector< vector< WireChar >> &  wgcvec,
vector< vector< vector< int >>> &  wgqvec,
std::unique_ptr< std::vector< raw::RawDigit > > &  filteredRawDigit 
) const

Definition at line 699 of file mtRawDigitFilterICARUS_module.cc.

705  {
706  int igrp = igwvec[i].group;
707  int iwdx = igwvec[i].windx;
708  int irdg = igwvec[i].irawdig;
709  const raw::RawDigit* rawDigit = rawDigitVec.at(irdg);
710 
711  // .. Uncompress the RawDigit
712  caldata::RawDigitVector& rawADC = rawadcgvec[igrp][iwdx];
713  caldata::RawDigitVector tempVec(fDataSize);
714  if (fTruncateTicks){
715  raw::Uncompress(rawDigit->ADCs(), tempVec, rawDigit->Compression());
716  std::copy(tempVec.begin() + fNumTicksToDropFront, tempVec.begin() + fNumTicksToDropFront + fWindowSize, rawADC.begin());
717  } else {
718  raw::Uncompress(rawDigit->ADCs(), rawADC, rawDigit->Compression());
719  }
720 
721  // .. Do the FFT correction
722 
723  raw::ChannelID_t channel = rawDigit->Channel();
724  unsigned int plane = wgcvec[igrp][iwdx].plane;
725 
726  if (fDoFFTCorrection){
727  // .. Subtract the pedestal
728  float pedestal = fPedestalRetrievalAlg.PedMean(channel);
729  std::vector<float> holder(fftSize);
730  std::transform(rawADC.begin(),rawADC.end(),holder.begin(),[pedestal](const auto& val){return float(float(val) - pedestal);});
731 
732  const icarusutil::FrequencyVec& filterVecPlane = fFilterVec.at(plane);
733 
734  std::vector<std::complex<double>> filterVec(filterVecPlane.size());
735 
736  for(size_t idx = 0; idx < filterVecPlane.size(); idx++)
737  filterVec[idx] = filterVecPlane[idx];
738 
739  // .. Do the correction
740  util::LArFFTW lfftw(fftSize, fplan, rplan, 0);
741  lfftw.Convolute(holder, filterVec);
742 
743  // .. Restore the pedestal
744  std::transform(holder.begin(), holder.end(), rawADC.begin(), [pedestal](const float& adc){return std::round(adc + pedestal);});
745  }
746 
748  channel,
749  plane,
750  wgcvec[igrp][iwdx].wire,
751  wgcvec[igrp][iwdx].truncMean,
752  wgcvec[igrp][iwdx].truncRms,
753  wgcvec[igrp][iwdx].mean,
754  wgcvec[igrp][iwdx].median,
755  wgcvec[igrp][iwdx].mode,
756  wgcvec[igrp][iwdx].skewness,
757  wgcvec[igrp][iwdx].fullRms,
758  wgcvec[igrp][iwdx].minMax,
759  wgcvec[igrp][iwdx].neighborRatio,
760  wgcvec[igrp][iwdx].pedCor);
761 
762  // This allows the module to be used simply to truncate waveforms with no noise processing
763  if (!fDoCorrelatedNoise)
764  {
765  // Is this channel "quiet" and should be rejected?
766  // Note that the "max - min" range is to be compared to twice the rms cut
767  if (fTruncateChannels && wgcvec[igrp][iwdx].minMax < 2. * fNRmsChannelReject[plane] * wgcvec[igrp][iwdx].truncRms) return;
768 
769  caldata::RawDigitVector pedCorrectedVec;
770  pedCorrectedVec.resize(rawADC.size(),0);
771  std::transform(rawADC.begin(),rawADC.end(),pedCorrectedVec.begin(),std::bind(std::minus<short>(),std::placeholders::_1,wgcvec[igrp][iwdx].pedCor));
772 
773  //saveRawDigits(filteredRawDigit, channel, pedCorrectedVec, truncMeanWireVec[wireIdx], truncRmsWireVec[wireIdx]);
774  filteredRawDigit->at(irdg) = raw::RawDigit(channel, pedCorrectedVec.size(), pedCorrectedVec, raw::kNone);
775  filteredRawDigit->at(irdg).SetPedestal(wgcvec[igrp][iwdx].truncMean,wgcvec[igrp][iwdx].truncRms);
776  return;
777  }
778 
779  // If we are not performing noise corrections then we are done with this wire
780  // Store it and move on
782  {
783  // Filter out the very high noise wires
784  if (wgcvec[igrp][iwdx].truncRms < fRmsRejectionCutHi[plane]) {
785  //saveRawDigits(filteredRawDigit, channel, rawadc, truncMeanWireVec[wireIdx], truncRmsWireVec[wireIdx]);
786  filteredRawDigit->at(irdg) = raw::RawDigit(channel, rawADC.size(), rawADC, raw::kNone);
787  filteredRawDigit->at(irdg).SetPedestal(wgcvec[igrp][iwdx].truncMean,wgcvec[igrp][iwdx].truncRms);
788  } else {
789  // Eventually we'll interface to some sort of channel status communication mechanism.
790  // For now use the log file
791  mf::LogInfo("RawDigitFilterICARUS") << "--> Rejecting channel for large rms, channel: " << channel
792  << ", rmsVal: " << wgcvec[igrp][iwdx].truncRms << ", truncMean: " << wgcvec[igrp][iwdx].truncMean
793  << ", pedestal: " << wgcvec[igrp][iwdx].pedCor << std::endl;
794  }
795 
796  return;
797  }
798 
799  // .. Classify the waveform
800  if (wgcvec[igrp][iwdx].minMax > fMinMaxSelectionCut[plane] && wgcvec[igrp][iwdx].truncRms < fRmsRejectionCutHi[plane]){
801  wgcvec[igrp][iwdx].tcka = 0;
802  wgcvec[igrp][iwdx].tckb = rawADC.size();
803  // .. Look for chirping wire sections. Confine this to only the V plane
804  if (plane == 1){
805  // .. Do wire shape corrections to look for chirping wires & other oddities to avoid. Recover our objects...
806  short threshold(6);
807  short mean = wgcvec[igrp][iwdx].mean;
808 
809  // .. If going from quiescent to on again, then the min/max will be large
810  if (wgcvec[igrp][iwdx].skewness > 0. && wgcvec[igrp][iwdx].neighborRatio < 0.7 && wgcvec[igrp][iwdx].minMax > 50){
811  raw::RawDigit::ADCvector_t::iterator stopChirpItr = std::find_if(rawADC.begin(),rawADC.end(),
812  [mean,threshold](const short& elem){return abs(elem - mean) > threshold;});
813  size_t threshIndex = std::distance(rawADC.begin(),stopChirpItr);
814  if (threshIndex > 60) wgcvec[igrp][iwdx].tcka = threshIndex;
815  } else if (wgcvec[igrp][iwdx].minMax > 20 && wgcvec[igrp][iwdx].neighborRatio < 0.7){ // .. Check in the reverse direction?
816  threshold = 3;
817  raw::RawDigit::ADCvector_t::reverse_iterator startChirpItr = std::find_if(rawADC.rbegin(),rawADC.rend(),
818  [mean,threshold](const short& elem){return abs(elem - mean) > threshold;});
819  size_t threshIndex = std::distance(rawADC.rbegin(),startChirpItr);
820  if (threshIndex > 60) wgcvec[igrp][iwdx].tckb = rawADC.size() - threshIndex;
821  }
822  }
823  } else {
824  // .. If unable to classify, then set the wire index in wgqvec to negative to skip coherent noise correction
825  int iqgrp = igwvec[i].qgroup;
826  unsigned int iqdx = igwvec[i].qgindx;
827  if ( iqgrp == 0 || iqgrp == 1 ) {
828  wgqvec[igrp][iqgrp][iqdx]=-1;
829  }
830  // .. and apply the pedestal correction
831  std::transform(rawADC.begin(),rawADC.end(),rawADC.begin(),std::bind(std::minus<short>(),std::placeholders::_1,wgcvec[igrp][iwdx].pedCor));
832  }
833 
834  return;
835 }
bool fTruncateChannels
If true then we drop channels with &quot;no signal&quot;.
std::vector< short > fMinMaxSelectionCut
Plane by plane cuts for spread cut.
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
Definition: RawDigit.h:210
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
static constexpr Sample_t transform(Sample_t sample)
bool fTruncateTicks
If true then drop ticks off ends of wires.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
Definition: RawDigit.h:212
unsigned int fWindowSize
ticks to keep in window
raw::RawDigit::ADCvector_t RawDigitVector
bool fDoFFTCorrection
Run the FFT noise correction.
bool fDoCorrelatedNoise
Process the noise.
const lariov::DetPedestalProvider & fPedestalRetrievalAlg
Keep track of an instance to the pedestal retrieval alg.
std::vector< ComplexVal > FrequencyVec
std::vector< float > fRmsRejectionCutHi
Maximum rms for input channels, reject if larger.
caldata::RawDigitCharacterizationAlg fCharacterizationAlg
no compression
Definition: RawTypes.h:9
T abs(T value)
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
bool fSmoothCorrelatedNoise
Should we smooth the noise?
const char mode
Definition: noise_ana.cxx:20
unsigned int fNumTicksToDropFront
ticks to drop from front of waveform
std::map< size_t, std::vector< std::complex< double > > > fFilterVec
virtual float PedMean(raw::ChannelID_t ch) const =0
Retrieve pedestal information.
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
Definition: RawDigit.h:216
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
T copy(T const &v)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
void getWaveformParams(const RawDigitVector &rawWaveform, unsigned int channel, unsigned int view, unsigned int wire, float &truncMean, float &truncRms, short &mean, short &median, short &mode, float &skewness, float &rms, short &minMax, float &neighborRatio, float &pedCorVal) const
std::vector< float > fNRmsChannelReject
rms to reject channel as no signal

Member Data Documentation

bool RawDigitFilterICARUS::fApplyBinAverage
private

Do bin averaging to get rid of high frequency noise.

Definition at line 95 of file RawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fApplyCorSmoothing
private

Attempt to smooth the correlated noise correction?

Definition at line 113 of file mtRawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fApplyFFTCorrection
private

Use an FFT to get the correlated noise correction.

Definition at line 114 of file mtRawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fApplyTopHatFilter
private

Apply the top hat filter.

Definition at line 115 of file mtRawDigitFilterICARUS_module.cc.

caldata::RawDigitBinAverageAlg RawDigitFilterICARUS::fBinAverageAlg
private

Definition at line 131 of file mtRawDigitFilterICARUS_module.cc.

caldata::ChannelGroups RawDigitFilterICARUS::fChannelGroups
private

Definition at line 145 of file mtRawDigitFilterICARUS_module.cc.

caldata::RawDigitCharacterizationAlg RawDigitFilterICARUS::fCharacterizationAlg
private

Definition at line 132 of file mtRawDigitFilterICARUS_module.cc.

caldata::RawDigitCorrelatedCorrectionAlg RawDigitFilterICARUS::fCorCorrectAlg
private

Definition at line 133 of file mtRawDigitFilterICARUS_module.cc.

std::string RawDigitFilterICARUS::fDigitModuleLabel
private

The full collection of hits.

Definition at line 107 of file mtRawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fDoCorrelatedNoise
private

Process the noise.

Definition at line 112 of file mtRawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fDoFFTCorrection
private

Run the FFT noise correction.

Definition at line 110 of file mtRawDigitFilterICARUS_module.cc.

std::vector<double> RawDigitFilterICARUS::fFFTMinPowerThreshold
private

Threshold for trimming FFT power spectrum.

Definition at line 125 of file mtRawDigitFilterICARUS_module.cc.

std::map< size_t, std::unique_ptr< icarus_tool::IFilter > > RawDigitFilterICARUS::fFilterToolMap
private

Definition at line 138 of file mtRawDigitFilterICARUS_module.cc.

std::map<size_t,icarusutil::FrequencyVec> RawDigitFilterICARUS::fFilterVec
private

Definition at line 116 of file RawDigitFilterICARUS_module.cc.

std::map<size_t,std::vector<std::complex<double> > > RawDigitFilterICARUS::fFilterVec
private

Definition at line 137 of file mtRawDigitFilterICARUS_module.cc.

geo::GeometryCore const * RawDigitFilterICARUS::fGeometry
private

pointer to Geometry service

Definition at line 141 of file mtRawDigitFilterICARUS_module.cc.

std::vector<short> RawDigitFilterICARUS::fMinMaxSelectionCut
private

Plane by plane cuts for spread cut.

Definition at line 120 of file mtRawDigitFilterICARUS_module.cc.

std::vector< float > RawDigitFilterICARUS::fNRmsChannelReject
private

rms to reject channel as no signal

Definition at line 121 of file mtRawDigitFilterICARUS_module.cc.

int RawDigitFilterICARUS::fNumEvent
private

Number of events seen.

Definition at line 128 of file mtRawDigitFilterICARUS_module.cc.

std::vector<float> RawDigitFilterICARUS::fNumRmsToSmoothVec
private

"sigma" to smooth correlated correction vec

Definition at line 124 of file mtRawDigitFilterICARUS_module.cc.

unsigned int RawDigitFilterICARUS::fNumTicksToDropFront
private

ticks to drop from front of waveform

Definition at line 117 of file mtRawDigitFilterICARUS_module.cc.

std::vector< size_t > RawDigitFilterICARUS::fNumWiresToGroup
private

If smoothing, the number of wires to look at.

Definition at line 119 of file mtRawDigitFilterICARUS_module.cc.

const lariov::DetPedestalProvider & RawDigitFilterICARUS::fPedestalRetrievalAlg
private

Keep track of an instance to the pedestal retrieval alg.

Definition at line 142 of file mtRawDigitFilterICARUS_module.cc.

std::unique_ptr< caldata::IRawDigitFilter > RawDigitFilterICARUS::fRawDigitFilterTool
private

Definition at line 135 of file mtRawDigitFilterICARUS_module.cc.

std::vector< float > RawDigitFilterICARUS::fRmsRejectionCutHi
private

Maximum rms for input channels, reject if larger.

Definition at line 122 of file mtRawDigitFilterICARUS_module.cc.

std::vector< float > RawDigitFilterICARUS::fRmsRejectionCutLow
private

Minimum rms to consider channel "alive".

Definition at line 123 of file mtRawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fSmoothCorrelatedNoise
private

Should we smooth the noise?

Definition at line 111 of file mtRawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fTruncateChannels
private

If true then we drop channels with "no signal".

Definition at line 109 of file mtRawDigitFilterICARUS_module.cc.

bool RawDigitFilterICARUS::fTruncateTicks
private

If true then drop ticks off ends of wires.

Definition at line 108 of file mtRawDigitFilterICARUS_module.cc.

float RawDigitFilterICARUS::fTruncMeanFraction
private

Fraction for truncated mean.

Definition at line 118 of file mtRawDigitFilterICARUS_module.cc.

unsigned int RawDigitFilterICARUS::fWindowSize
private

ticks to keep in window

Definition at line 116 of file mtRawDigitFilterICARUS_module.cc.


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