All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawDigitFilterICARUS_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Class: RawDigitFilterICARUS
4 // Module Type: producer
5 // File: RawDigitFilterICARUS_module.cc
6 //
7 // The intent of this module is to filter out "bad" channels
8 // in an input RawDigit data stream. In the current implementation,
9 // "bad" is defined as the truncated rms for a channel crossing
10 // a user controlled threshold
11 //
12 // Configuration parameters:
13 //
14 // DigitModuleLabel - the source of the RawDigit collection
15 // TruncMeanFraction - the fraction of waveform bins to discard when
16 // computing the means and rms
17 // RMSRejectionCutHi - vector of maximum allowed rms values to keep channel
18 // RMSRejectionCutLow - vector of lowest allowed rms values to keep channel
19 // RMSSelectionCut - vector of rms values below which to not correct
20 // TheChoseWire - Wire chosen for "example" hists
21 // MaxPedestalDiff - Baseline difference to pedestal to flag
22 // SmoothCorrelatedNoise - Turns on the correlated noise suppression
23 // NumWiresToGroup - When removing correlated noise, # wires to group
24 // FillHistograms - Turn on histogram filling for diagnostics
25 // RunFFTInputWires - FFT analyze the input RawDigits if true - diagnostics
26 // RunFFTCorrectedWires - FFT analyze the output RawDigits if true - diagnostics
27 // TruncateTicks: - Provide mechanism to truncate a readout window to a smaller size
28 // WindowSize: - The desired size of the output window
29 // NumTicksToDropFront: - The number ticks dropped off the front of the original window
30 //
31 //
32 // Created by Tracy Usher (usher@slac.stanford.edu) on April 17, 2017
33 //
34 ////////////////////////////////////////////////////////////////////////
35 
36 #include <cmath>
37 #include <algorithm>
38 #include <vector>
39 
40 #include "TComplex.h"
41 
42 #include "art/Framework/Core/ReplicatedProducer.h"
43 #include "art/Framework/Principal/Event.h"
44 #include "art/Framework/Services/Registry/ServiceHandle.h"
45 #include "art_root_io/TFileService.h"
46 #include "art/Framework/Core/ModuleMacros.h"
47 #include "art/Utilities/make_tool.h"
48 #include "canvas/Persistency/Common/Ptr.h"
49 #include "messagefacility/MessageLogger/MessageLogger.h"
50 
58 
65 
67 #include "lardataobj/RawData/raw.h"
68 
69 #include <Eigen/Core>
70 #include <unsupported/Eigen/FFT>
71 
72 
73 class RawDigitFilterICARUS : public art::ReplicatedProducer
74 {
75 public:
76 
77  // Copnstructors, destructor.
78  explicit RawDigitFilterICARUS(fhicl::ParameterSet const & pset, art::ProcessingFrame const& frame);
79  virtual ~RawDigitFilterICARUS();
80 
81  // Overrides.
82  virtual void configure(fhicl::ParameterSet const & pset);
83  virtual void produce(art::Event & e, art::ProcessingFrame const& frame);
84  virtual void beginJob(art::ProcessingFrame const& frame);
85  virtual void endJob(art::ProcessingFrame const& frame);
86 
87 private:
88 
89  void saveRawDigits(std::unique_ptr<std::vector<raw::RawDigit> >&, raw::ChannelID_t&, caldata::RawDigitVector&, float, float);
90 
91  // Fcl parameters.
92  std::string fDigitModuleLabel; ///< The full collection of hits
93  bool fDoCorrelatedNoise; ///< Process the noise
94  bool fDoFFTCorrection; ///< Run the FFT noise correction
95  bool fApplyBinAverage; ///< Do bin averaging to get rid of high frequency noise
96  bool fApplyTopHatFilter; ///< Apply the top hat filter
97  bool fSmoothCorrelatedNoise; ///< Should we smooth the noise?
98  std::vector<size_t> fNumWiresToGroup; ///< If smoothing, the number of wires to look at
99  bool fTruncateTicks; ///< If true then drop ticks off ends of wires
100  bool fTruncateChannels; ///< If true then we drop channels with "no signal"
101  unsigned int fWindowSize; ///< # ticks to keep in window
102  unsigned int fNumTicksToDropFront; ///< # ticks to drop from front of waveform
103  std::vector<float> fRmsRejectionCutHi; ///< Maximum rms for input channels, reject if larger
104  std::vector<float> fRmsRejectionCutLow; ///< Minimum rms to consider channel "alive"
105  std::vector<float> fNRmsChannelReject; ///< # rms to reject channel as no signal
106 
107  // Statistics.
108  int fNumEvent; ///< Number of events seen.
109 
110  // Correction algorithms
114 
115  std::unique_ptr<caldata::IRawDigitFilter> fRawDigitFilterTool;
116  std::map<size_t,icarusutil::FrequencyVec> fFilterVec;
117  std::map<size_t,std::unique_ptr<icarus_tool::IFilter>> fFilterToolMap;
118 
119  // Useful services, keep copies for now (we can update during begin run periods)
120  geo::GeometryCore const* fGeometry; ///< pointer to Geometry service
121  const lariov::DetPedestalProvider& fPedestalRetrievalAlg; ///< Keep track of an instance to the pedestal retrieval alg
122 
123 };
124 
125 DEFINE_ART_MODULE(RawDigitFilterICARUS)
126 
127 //----------------------------------------------------------------------------
128 /// Constructor.
129 ///
130 /// Arguments:
131 ///
132 /// pset - Fcl parameters.
133 ///
134 RawDigitFilterICARUS::RawDigitFilterICARUS(fhicl::ParameterSet const & pset, art::ProcessingFrame const& frame) :
135  art::ReplicatedProducer(pset, frame),
136  fNumEvent(0),
137  fBinAverageAlg(pset),
138  fCharacterizationAlg(pset.get<fhicl::ParameterSet>("CharacterizationAlg")),
139  fCorCorrectAlg(pset.get<fhicl::ParameterSet>("CorrelatedCorrectionAlg")),
140  fPedestalRetrievalAlg(*lar::providerFrom<lariov::DetPedestalService>())
141 {
142 
143  fGeometry = lar::providerFrom<geo::Geometry>();
144 
145  configure(pset);
146  produces<std::vector<raw::RawDigit> >();
147 
148  // Report.
149  mf::LogInfo("RawDigitFilterICARUS") << "RawDigitFilterICARUS configured\n";
150 }
151 
152 //----------------------------------------------------------------------------
153 /// Destructor.
155 {}
156 
157 //----------------------------------------------------------------------------
158 /// Reconfigure method.
159 ///
160 /// Arguments:
161 ///
162 /// pset - Fcl parameter set.
163 ///
164 void RawDigitFilterICARUS::configure(fhicl::ParameterSet const & pset)
165 {
166  fDigitModuleLabel = pset.get<std::string> ("DigitModuleLabel", "daq");
167  fDoCorrelatedNoise = pset.get<bool> ("ProcessNoise", true);
168  fDoFFTCorrection = pset.get<bool> ("FFTNoise", true);
169  fApplyBinAverage = pset.get<bool> ("ApplyBinAverage", true);
170  fApplyTopHatFilter = pset.get<bool> ("ApplyTopHatFilter", true);
171  fSmoothCorrelatedNoise = pset.get<bool> ("SmoothCorrelatedNoise", true);
172  fNumWiresToGroup = pset.get<std::vector<size_t>>("NumWiresToGroup", std::vector<size_t>() = {48, 48, 96});
173  fTruncateTicks = pset.get<bool> ("TruncateTicks", false);
174  fTruncateChannels = pset.get<bool> ("TruncateChannels", false);
175  fWindowSize = pset.get<size_t> ("WindowSize", 6400);
176  fNumTicksToDropFront = pset.get<size_t> ("NumTicksToDropFront", 2400);
177  fRmsRejectionCutHi = pset.get<std::vector<float>> ("RMSRejectionCutHi", std::vector<float>() = {25.0,25.0,25.0});
178  fRmsRejectionCutLow = pset.get<std::vector<float>> ("RMSRejectionCutLow", std::vector<float>() = {0.70,0.70,0.70});
179  fNRmsChannelReject = pset.get<std::vector<float>> ("NRMSChannelReject", std::vector<float>() = {3., 3., 3. });
180 
181  fRawDigitFilterTool = art::make_tool<caldata::IRawDigitFilter>(pset.get<fhicl::ParameterSet>("RawDigitFilterTool"));
182 
183  // Implement the tools for handling the responses
184  const fhicl::ParameterSet& filterTools = pset.get<fhicl::ParameterSet>("FilterTools");
185  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
186  for(const std::string& filterTool : filterTools.get_pset_names())
187  {
188  const fhicl::ParameterSet& filterToolParamSet = filterTools.get<fhicl::ParameterSet>(filterTool);
189  size_t planeIdx = filterToolParamSet.get<size_t>("Plane");
190  fFilterToolMap.insert(std::pair<size_t,std::unique_ptr<icarus_tool::IFilter>>(planeIdx,art::make_tool<icarus_tool::IFilter>(filterToolParamSet)));
191 
192  fFilterToolMap.at(planeIdx)->setResponse(detProp.NumberTimeSamples(),1.,1.);
193  }
194 }
195 
196 //----------------------------------------------------------------------------
197 /// Begin job method.
198 void RawDigitFilterICARUS::beginJob(art::ProcessingFrame const&)
199 {
200  // Access ART's TFileService, which will handle creating and writing
201  // histograms and n-tuples for us.
202  art::ServiceHandle<art::TFileService> tfs;
203 
206 
207  art::TFileDirectory dir = tfs->mkdir(Form("RawDigitFilter"));
208 
209  fRawDigitFilterTool->initializeHistograms(dir);
210 
211  if (fDoFFTCorrection)
212  {
213  for(const auto& filterToolPair : fFilterToolMap) filterToolPair.second->outputHistograms(dir);
214  }
215 
216  return;
217 }
218 
219 //----------------------------------------------------------------------------
220 /// Produce method.
221 ///
222 /// Arguments:
223 ///
224 /// evt - Art event.
225 ///
226 /// This is the primary method.
227 ///
228 void RawDigitFilterICARUS::produce(art::Event & event, art::ProcessingFrame const&)
229 {
230  ++fNumEvent;
231 
232  // Agreed convention is to ALWAYS output to the event store so get a pointer to our collection
233  std::unique_ptr<std::vector<raw::RawDigit> > filteredRawDigit(new std::vector<raw::RawDigit>);
234 
235  // Read in the digit List object(s).
236  art::Handle< std::vector<raw::RawDigit> > digitVecHandle;
237  event.getByLabel(fDigitModuleLabel, digitVecHandle);
238 
239  // Require a valid handle
240  if (digitVecHandle.isValid() && digitVecHandle->size()>0 )
241  {
242  unsigned int maxChannels = fGeometry->Nchannels();
243 
244  // Sadly, the RawDigits come to us in an unsorted condition which is not optimal for
245  // what we want to do here. So we make a vector of pointers to the input raw digits and sort them
246  std::vector<const raw::RawDigit*> rawDigitVec;
247 
248  // Ugliness to fill the pointer vector...
249  for(size_t idx = 0; idx < digitVecHandle->size(); idx++) rawDigitVec.push_back(&digitVecHandle->at(idx)); //art::Ptr<raw::RawDigit>(digitVecHandle, idx).get());
250 
251  // Sort (use a lambda to sort by channel id)
252  std::sort(rawDigitVec.begin(),rawDigitVec.end(),[](const raw::RawDigit* left, const raw::RawDigit* right) {return left->Channel() < right->Channel();});
253 
254  // Ok, to do the correlated noise removal we are going to need a rather impressive data structure...
255  // Because we need to unpack each wire's data, we will need to "explode" it out into a data structure
256  // here... with the good news that we'll release the memory at the end of the module so should not
257  // impact downstream processing (I hope!).
258  // What we are going to do is make a vector over planes of vectors over wires of vectors over time samples
259  //std::vector<RawDigitVector> rawDataWireTimeVec;
260  std::vector<caldata::RawDigitVector> rawDataWireTimeVec;
261  std::vector<float> truncMeanWireVec;
262  std::vector<float> truncRmsWireVec;
263  std::vector<short> meanWireVec;
264  std::vector<short> medianWireVec;
265  std::vector<short> modeWireVec;
266  std::vector<float> skewnessWireVec;
267  std::vector<float> fullRmsWireVec;
268  std::vector<short> minMaxWireVec;
269  std::vector<float> neighborRatioWireVec;
270  std::vector<float> pedCorWireVec;
271  std::vector<raw::ChannelID_t> channelWireVec;
272  caldata::GroupToDigitIdxPairMap groupToDigitIdxPairMap;
273 
274  // .. Use the handle to get a particular (0th) element of collection.
275  art::Ptr<raw::RawDigit> digitVec0(digitVecHandle, 0);
276  unsigned int fDataSize = digitVec0->Samples(); //size of raw data vectors
277  unsigned int fftSize;
278  if (fTruncateTicks) fftSize = fWindowSize;
279  else fftSize = fDataSize;
280 
281  // .. First set up the filters
282  unsigned int halfFFTSize(fftSize/2 + 1);
283 
284  if (fDoFFTCorrection)
285  {
286  for(unsigned int plne = 0; plne < 3; plne++)
287  {
288  if (fFilterVec[plne].size() != fftSize)
289  {
290  fFilterToolMap.at(plne)->setResponse(fftSize,1.,1.);
291  const icarusutil::FrequencyVec& filter = fFilterToolMap.at(plne)->getResponseVec();
292  fFilterVec[plne] = filter;
293  }
294  }
295  }
296 
297  // .. Now set up the fftw plan
298  util::LArFFTWPlan lfftwp(fftSize,"ES");
299 
300  // Declare a temporary digit holder and resize it if downsizing the waveform
301  caldata::RawDigitVector tempVec(fDataSize);
302 
303  // Commence looping over raw digits
304  //std::cout << "rawDigitVec size: " << rawDigitVec.size() << std::endl;
305  for(const auto& rawDigit : rawDigitVec)
306  {
307  raw::ChannelID_t channel = rawDigit->Channel();
308 
309  // The below try-catch block may no longer be necessary
310  // Decode the channel and make sure we have a valid one
311  std::vector<geo::WireID> wids = fGeometry->ChannelToWire(channel);
312 
313  if (channel >= maxChannels || wids.empty()) continue;
314 
315  // Recover plane and wire in the plane
316  unsigned int plane = wids[0].Plane;
317  unsigned int wire = wids[0].Wire;
318 
319  unsigned int dataSize = rawDigit->Samples();
320  unsigned int wireIdx = wire % fNumWiresToGroup[plane];
321 
322  if (dataSize < 1)
323  {
324  std::cout << "****>> Found zero length raw digit buffer, channel: " << channel << ", plane: " << plane << ", wire: " << wire << std::endl;
325  continue;
326  }else if (dataSize!=fDataSize) {
327  std::cout << "****>> DataSize has changed from " << fDataSize << " to " << dataSize
328  << " for channel: " << channel << ", plane: " << plane << ", wire: " << wire << std::endl;
329  continue;
330  }
331 
332  // Cross check that our storage arrays are the correct size
333  // (note there is a possible boundary issue here that we are going to ignore...)
334  if (rawDataWireTimeVec.size() != fNumWiresToGroup[plane])
335  {
336  // For each plane we need to presize the vector to the number of wires
337  rawDataWireTimeVec.resize(fNumWiresToGroup[plane]);
338  truncMeanWireVec.resize(fNumWiresToGroup[plane]);
339  truncRmsWireVec.resize(fNumWiresToGroup[plane]);
340  meanWireVec.resize(fNumWiresToGroup[plane]);
341  medianWireVec.resize(fNumWiresToGroup[plane]);
342  modeWireVec.resize(fNumWiresToGroup[plane]);
343  skewnessWireVec.resize(fNumWiresToGroup[plane]);
344  fullRmsWireVec.resize(fNumWiresToGroup[plane]);
345  minMaxWireVec.resize(fNumWiresToGroup[plane]);
346  neighborRatioWireVec.resize(fNumWiresToGroup[plane]);
347  pedCorWireVec.resize(fNumWiresToGroup[plane]);
348  channelWireVec.resize(fNumWiresToGroup[plane]);
349  groupToDigitIdxPairMap.clear();
350  }
351 
352  // vector holding uncompressed adc values
353  std::vector<short>& rawadc = rawDataWireTimeVec[wireIdx];
354  rawadc.resize(fftSize);
355 
356  channelWireVec[wireIdx] = channel;
357 
358  // If we are trying to truncate the incoming RawDigit collection then we need to do so when we extract from the input raw digits
359  // This causes a small division here...
360  if (fTruncateTicks)
361  {
362  raw::Uncompress(rawDigit->ADCs(), tempVec, rawDigit->Compression());
363  std::copy(tempVec.begin() + fNumTicksToDropFront, tempVec.begin() + fNumTicksToDropFront + fWindowSize, rawadc.begin());
364  }
365  else
366  {
367  raw::Uncompress(rawDigit->ADCs(), rawadc, rawDigit->Compression());
368  }
369 
370  if (fDoFFTCorrection)
371  {
372  // .. Subtract the pedestal
373  double pedestal = fPedestalRetrievalAlg.PedMean(channel);
374 
375  icarusutil::TimeVec holder(fftSize);
376 
377  std::transform(rawadc.begin(),rawadc.end(),holder.begin(),[pedestal](const auto& val){return float(float(val) - pedestal);});
378 
379  // .. Do the correction
380  Eigen::FFT<icarusutil::SigProcPrecision> eigenFFT;
381 
382  icarusutil::FrequencyVec holderFFT(rawadc.size());
383 
384  eigenFFT.fwd(holderFFT, holder);
385 
386  std::transform(fFilterVec.at(plane).begin(),fFilterVec.at(plane).end(),holderFFT.begin(),holderFFT.begin(),std::multiplies<std::complex<double>>());
387 
388  eigenFFT.inv(holder, holderFFT);
389  // .. Restore the pedestal
390  std::transform(holder.begin(), holder.end(), rawadc.begin(), [pedestal](const float& adc){return std::round(adc + pedestal);});
391  }
392 
393  // Get the kitchen sink
395  channel,
396  plane,
397  wire,
398  truncMeanWireVec[wireIdx],
399  truncRmsWireVec[wireIdx],
400  meanWireVec[wireIdx],
401  medianWireVec[wireIdx],
402  modeWireVec[wireIdx],
403  skewnessWireVec[wireIdx],
404  fullRmsWireVec[wireIdx],
405  minMaxWireVec[wireIdx],
406  neighborRatioWireVec[wireIdx],
407  pedCorWireVec[wireIdx]);
408 
409  // This allows the module to be used simply to truncate waveforms with no noise processing
410  if (!fDoCorrelatedNoise)
411  {
412  // Is this channel "quiet" and should be rejected?
413  // Note that the "max - min" range is to be compared to twice the rms cut
414  if (fTruncateChannels && minMaxWireVec[wireIdx] < 2. * fNRmsChannelReject[plane] * truncRmsWireVec[wireIdx]) continue;
415 
416  caldata::RawDigitVector pedCorrectedVec;
417 
418  pedCorrectedVec.resize(rawadc.size(),0);
419 
420  std::transform(rawadc.begin(),rawadc.end(),pedCorrectedVec.begin(),std::bind(std::minus<short>(),std::placeholders::_1,pedCorWireVec[wireIdx]));
421 
422  saveRawDigits(filteredRawDigit, channel, pedCorrectedVec, truncMeanWireVec[wireIdx], truncRmsWireVec[wireIdx]);
423 
424  continue;
425  }
426 
427  // If we are not performing noise corrections then we are done with this wire
428  // Store it and move on
430  {
431  // Filter out the very high noise wires
432  if (truncRmsWireVec[wireIdx] < fRmsRejectionCutHi[plane])
433  saveRawDigits(filteredRawDigit, channel, rawadc, truncMeanWireVec[wireIdx], truncRmsWireVec[wireIdx]);
434  else
435  {
436  // Eventually we'll interface to some sort of channel status communication mechanism.
437  // For now use the log file
438  mf::LogInfo("RawDigitFilterICARUS") << "--> Rejecting channel for large rms, channel: " << channel
439  << ", rmsVal: " << pedCorWireVec[wireIdx] << ", truncMean: " << truncMeanWireVec[wireIdx]
440  << ", pedestal: " << pedCorWireVec[wireIdx] << std::endl;
441  }
442 
443  continue;
444  }
445 
446  // Add this wire to the map and try to do some classification here
447  if (!fCharacterizationAlg.classifyRawDigitVec(rawadc, plane, wire, truncRmsWireVec[wireIdx], minMaxWireVec[wireIdx],
448  meanWireVec[wireIdx],skewnessWireVec[wireIdx], neighborRatioWireVec[wireIdx], groupToDigitIdxPairMap))
449  {
450  // If the waveform was not classified then we need to baseline correct...
451  std::transform(rawadc.begin(),rawadc.end(),rawadc.begin(),std::bind(std::minus<short>(),std::placeholders::_1,pedCorWireVec[wireIdx]));
452  }
453 
454  // Are we at the correct boundary for dealing with the noise?
455  if (!((wireIdx + 1) % fNumWiresToGroup[plane]))
456  {
457  int baseWireIdx = wire - wire % fNumWiresToGroup[plane];
458 
459  // Now go through the groups to remove correlated noise in those groups
460  for(auto& groupToDigitIdxPair : groupToDigitIdxPairMap)
461  {
462  fCorCorrectAlg.removeCorrelatedNoise(groupToDigitIdxPair.second,
463  plane,
464  truncMeanWireVec,
465  truncRmsWireVec,
466  minMaxWireVec,
467  meanWireVec,
468  skewnessWireVec,
469  neighborRatioWireVec,
470  pedCorWireVec,
471  fftSize, halfFFTSize, lfftwp.fPlan, lfftwp.rPlan);
472  }
473 
474  // One more pass through to store the good channels
475  for (size_t locWireIdx = 0; locWireIdx < fNumWiresToGroup[plane]; locWireIdx++)
476  {
477  // Try baseline correction?
478  if (fApplyTopHatFilter && plane != 2 && skewnessWireVec[locWireIdx] > 0.)
479  {
480  //doAdaptiveFilter(rawDataWireTimeVec[locWireIdx]);
481  fRawDigitFilterTool->FilterWaveform(rawDataWireTimeVec[locWireIdx], baseWireIdx + locWireIdx, plane);
482  }
483 
484  // recalculate rms for the output
485  float rmsVal = 0.;
486  float pedestal = truncMeanWireVec[locWireIdx];
487  float pedCor = pedCorWireVec[locWireIdx];
488  float deltaPed = pedestal - pedCor;
489 
490  caldata::RawDigitVector& rawDataVec = rawDataWireTimeVec[locWireIdx];
491 
492  fCharacterizationAlg.getTruncatedRMS(rawDataVec, deltaPed, rmsVal);
493 
494  // The ultra high noise channels are simply zapped
495  if (rmsVal < fRmsRejectionCutHi[plane]) // && ImAGoodWire(plane,baseWireIdx + locWireIdx))
496  {
497  saveRawDigits(filteredRawDigit, channelWireVec[locWireIdx], rawDataVec, pedestal, rmsVal);
498  }
499  else
500  {
501  mf::LogInfo("RawDigitFilterICARUS") << "--> Rejecting channel for large rms, channel: "
502  << channelWireVec[locWireIdx] << ", rmsVal: " << rmsVal << ", truncMean: "
503  << pedestal << ", pedestal: " << pedCor << std::endl;
504  }
505  }
506 
507  groupToDigitIdxPairMap.clear();
508  }
509  }
510 
511  }
512 
513  // Add tracks and associations to event.
514  event.put(std::move(filteredRawDigit));
515 }
516 
517 void RawDigitFilterICARUS::saveRawDigits(std::unique_ptr<std::vector<raw::RawDigit> >& filteredRawDigit,
518  raw::ChannelID_t& channel,
519  caldata::RawDigitVector& rawDigitVec,
520  float pedestal,
521  float rms)
522 {
523  //filteredRawDigit->emplace_back(raw::RawDigit(channel, rawDigitVec.size(), rawDigitVec, raw::kNone));
524  filteredRawDigit->emplace_back(channel, rawDigitVec.size(), rawDigitVec, raw::kNone);
525  filteredRawDigit->back().SetPedestal(pedestal,rms);
526 
527  return;
528 }
529 
530 //----------------------------------------------------------------------------
531 /// End job method.
532 void RawDigitFilterICARUS::endJob(art::ProcessingFrame const&)
533 {
534  mf::LogInfo("RawDigitFilterICARUS") << "Looked at " << fNumEvent << " events" << std::endl;
535 }
caldata::RawDigitCorrelatedCorrectionAlg fCorCorrectAlg
bool fTruncateChannels
If true then we drop channels with &quot;no signal&quot;.
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
static constexpr Sample_t transform(Sample_t sample)
void saveRawDigits(std::unique_ptr< std::vector< raw::RawDigit > > &, raw::ChannelID_t &, caldata::RawDigitVector &, float, float)
bool fApplyBinAverage
Do bin averaging to get rid of high frequency noise.
bool fTruncateTicks
If true then drop ticks off ends of wires.
T::provider_type const * providerFrom()
Returns a constant pointer to the provider of specified service.
Definition: ServiceUtil.h:77
walls no right
Definition: selectors.fcl:105
bool classifyRawDigitVec(RawDigitVector &rawWaveform, unsigned int viewIdx, unsigned int wire, float truncRms, short minMax, short mean, float skewness, float neighborRatio, GroupToDigitIdxPairMap &groupToDigitIdxPairMap) const
virtual void produce(art::Event &e, art::ProcessingFrame const &frame)
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
raw::RawDigit::ADCvector_t RawDigitVector
bool fDoFFTCorrection
Run the FFT noise correction.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Definition of basic raw digits.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
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
std::map< size_t, icarusutil::FrequencyVec > fFilterVec
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
std::map< size_t, RawDigitAdcIdxPair > GroupToDigitIdxPairMap
int fNumEvent
Number of events seen.
void removeCorrelatedNoise(RawDigitAdcIdxPair &digitIdxPair, unsigned int viewIdx, std::vector< float > &truncMeanWireVec, std::vector< float > &truncRmsWireVec, std::vector< short > &minMaxWireVec, std::vector< short > &meanWireVec, std::vector< float > &skewnessWireVec, std::vector< float > &neighborRatioWireVec, std::vector< float > &pedCorWireVec, unsigned int &fftSize, unsigned int &halfFFTSize, void *fplan, void *rplan) const
bool fSmoothCorrelatedNoise
Should we smooth the noise?
Collect all the RawData header files together.
std::vector< SigProcPrecision > TimeVec
bool fApplyTopHatFilter
Apply the top hat filter.
void initializeHists(art::ServiceHandle< art::TFileService > &)
Begin job method.
unsigned int fNumTicksToDropFront
ticks to drop from front of waveform
walls no left
Definition: selectors.fcl:105
virtual void beginJob(art::ProcessingFrame const &frame)
Begin job method.
std::map< size_t, std::vector< std::complex< double > > > fFilterVec
Description of geometry of one entire detector.
This is the interface class for a tool to handle a filter for the overall response.
virtual float PedMean(raw::ChannelID_t ch) const =0
Retrieve pedestal information.
void getTruncatedRMS(const RawDigitVector &rawWaveform, float &pedestal, float &truncRms) const
tuple dir
Definition: dropbox.py:28
std::vector< float > fRmsRejectionCutLow
Minimum rms to consider channel &quot;alive&quot;.
virtual void configure(fhicl::ParameterSet const &pset)
physics filters filter
virtual ~RawDigitFilterICARUS()
Destructor.
std::unique_ptr< caldata::IRawDigitFilter > fRawDigitFilterTool
This provides an interface for tools which are tasked with filtering input waveforms.
virtual void endJob(art::ProcessingFrame const &frame)
End job method.
caldata::RawDigitBinAverageAlg fBinAverageAlg
Interface for experiment-specific channel quality info provider.
do i e
T copy(T const &v)
geo::GeometryCore const * fGeometry
pointer to Geometry service
art::ServiceHandle< art::TFileService > tfs
RawDigitFilterICARUS(fhicl::ParameterSet const &pset, art::ProcessingFrame const &frame)
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.
Interface for experiment-specific service for channel quality info.
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 initializeHists(art::ServiceHandle< art::TFileService > &)
Begin job method.
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
art framework interface to geometry description
BEGIN_PROLOG could also be cout
auto const detProp