All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Attributes | List of all members
daq::TPCDecoderFilter2D Class Reference

TPCDecoderFilter2D class definiton. More...

Inheritance diagram for daq::TPCDecoderFilter2D:
daq::IDecoderFilter

Public Member Functions

 TPCDecoderFilter2D (fhicl::ParameterSet const &pset)
 Constructor. More...
 
 ~TPCDecoderFilter2D ()
 Destructor. More...
 
virtual void configure (const fhicl::ParameterSet &) override
 Interface for configuring the particular algorithm tool. More...
 
virtual void process_fragment (detinfo::DetectorClocksData const &, const artdaq::Fragment &) override
 Given a set of recob hits, run DBscan to form 3D clusters. More...
 
const
icarus_signal_processing::VectorInt 
getChannelIDs () const override
 Recover the channels for the processed fragment. More...
 
const
icarus_signal_processing::ArrayBool 
getSelectionVals () const override
 Recover the selection values. More...
 
const
icarus_signal_processing::ArrayBool 
getROIVals () const override
 Recover the ROI values. More...
 
const
icarus_signal_processing::ArrayFloat 
getRawWaveforms () const override
 Recover the pedestal subtracted waveforms. More...
 
const
icarus_signal_processing::ArrayFloat 
getPedCorWaveforms () const override
 Recover the pedestal subtracted waveforms. More...
 
const
icarus_signal_processing::ArrayFloat 
getIntrinsicRMS () const override
 Recover the "intrinsic" RMS. More...
 
const
icarus_signal_processing::ArrayFloat 
getCorrectedMedians () const override
 Recover the correction median values. More...
 
const
icarus_signal_processing::ArrayFloat 
getWaveLessCoherent () const override
 Recover the waveforms less coherent noise. More...
 
const
icarus_signal_processing::ArrayFloat 
getMorphedWaveforms () const override
 Recover the morphological filter waveforms. More...
 
const
icarus_signal_processing::VectorFloat 
getPedestalVals () const override
 Recover the pedestals for each channel. More...
 
const
icarus_signal_processing::VectorFloat 
getFullRMSVals () const override
 Recover the full RMS before coherent noise. More...
 
const
icarus_signal_processing::VectorFloat 
getTruncRMSVals () const override
 Recover the truncated RMS noise. More...
 
const
icarus_signal_processing::VectorInt 
getNumTruncBins () const override
 Recover the number of bins after truncation. More...
 
- Public Member Functions inherited from daq::IDecoderFilter
virtual ~IDecoderFilter () noexcept=default
 Virtual Destructor. More...
 

Private Types

using FragmentIDPair = std::pair< unsigned int, unsigned int >
 
using FragmentIDVec = std::vector< FragmentIDPair >
 
using FragmentIDMap = std::map< unsigned int, unsigned int >
 

Private Attributes

uint32_t fFragment_id_offset
 
float fSigmaForTruncation
 
size_t fCoherentNoiseGrouping
 
size_t fCoherentNoiseOffset
 
std::vector< size_t > fStructuringElement
 
size_t fMorphWindow
 
std::vector< float > fThreshold
 
bool fDiagnosticOutput
 
std::vector< char > fFilterModeVec
 
FragmentIDMap fFragmentIDMap
 
icarus_signal_processing::VectorInt fChannelIDVec
 
icarus_signal_processing::ArrayBool fSelectVals
 
icarus_signal_processing::ArrayBool fROIVals
 
icarus_signal_processing::ArrayFloat fRawWaveforms
 
icarus_signal_processing::ArrayFloat fPedCorWaveforms
 
icarus_signal_processing::ArrayFloat fIntrinsicRMS
 
icarus_signal_processing::ArrayFloat fCorrectedMedians
 
icarus_signal_processing::ArrayFloat fWaveLessCoherent
 
icarus_signal_processing::ArrayFloat fMorphedWaveforms
 
icarus_signal_processing::VectorFloat fPedestalVals
 
icarus_signal_processing::VectorFloat fFullRMSVals
 
icarus_signal_processing::VectorFloat fTruncRMSVals
 
icarus_signal_processing::VectorInt fNumTruncBins
 
icarus_signal_processing::VectorInt fRangeBins
 
icarus_signal_processing::VectorFloat fThresholdVec
 
std::vector< unsigned int > fPlaneVec
 
const geo::GeometryfGeometry
 
const icarusDB::IICARUSChannelMapfChannelMap
 
icarus_signal_processing::FFTFilterFunctionVec fFFTFilterFunctionVec
 

Detailed Description

TPCDecoderFilter2D class definiton.

Definition at line 44 of file TPCDecoderFilter2D_tool.cc.

Member Typedef Documentation

using daq::TPCDecoderFilter2D::FragmentIDMap = std::map<unsigned int, unsigned int>
private

Definition at line 154 of file TPCDecoderFilter2D_tool.cc.

using daq::TPCDecoderFilter2D::FragmentIDPair = std::pair<unsigned int, unsigned int>
private

Definition at line 152 of file TPCDecoderFilter2D_tool.cc.

Definition at line 153 of file TPCDecoderFilter2D_tool.cc.

Constructor & Destructor Documentation

daq::TPCDecoderFilter2D::TPCDecoderFilter2D ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Parameters
pset

Definition at line 187 of file TPCDecoderFilter2D_tool.cc.

188 {
189  this->configure(pset);
190 
191  fSelectVals.clear();
192  fROIVals.clear();
193  fRawWaveforms.clear();
194  fPedCorWaveforms.clear();
195  fIntrinsicRMS.clear();
196  fCorrectedMedians.clear();
197  fWaveLessCoherent.clear();
198  fMorphedWaveforms.clear();
199 
200  fPedestalVals.clear();
201  fFullRMSVals.clear();
202  fTruncRMSVals.clear();
203  fNumTruncBins.clear();
204  fRangeBins.clear();
205 
206  return;
207 }
icarus_signal_processing::ArrayFloat fPedCorWaveforms
icarus_signal_processing::VectorFloat fFullRMSVals
icarus_signal_processing::VectorFloat fTruncRMSVals
icarus_signal_processing::VectorInt fRangeBins
icarus_signal_processing::VectorInt fNumTruncBins
icarus_signal_processing::ArrayFloat fMorphedWaveforms
icarus_signal_processing::ArrayFloat fIntrinsicRMS
icarus_signal_processing::VectorFloat fPedestalVals
icarus_signal_processing::ArrayBool fROIVals
virtual void configure(const fhicl::ParameterSet &) override
Interface for configuring the particular algorithm tool.
icarus_signal_processing::ArrayFloat fWaveLessCoherent
icarus_signal_processing::ArrayFloat fCorrectedMedians
icarus_signal_processing::ArrayFloat fRawWaveforms
icarus_signal_processing::ArrayBool fSelectVals
daq::TPCDecoderFilter2D::~TPCDecoderFilter2D ( )

Destructor.

Definition at line 211 of file TPCDecoderFilter2D_tool.cc.

212 {
213 }

Member Function Documentation

void daq::TPCDecoderFilter2D::configure ( const fhicl::ParameterSet &  pset)
overridevirtual

Interface for configuring the particular algorithm tool.

Parameters
ParameterSetThe input set of parameters for configuration

Implements daq::IDecoderFilter.

Definition at line 216 of file TPCDecoderFilter2D_tool.cc.

217 {
218  fFragment_id_offset = pset.get<uint32_t >("fragment_id_offset" );
219  fSigmaForTruncation = pset.get<float >("NSigmaForTrucation", 3.5);
220  fCoherentNoiseGrouping = pset.get<size_t >("CoherentGrouping", 64);
221  fCoherentNoiseOffset = pset.get<size_t >("CoherentOffset", 0);
222  fStructuringElement = pset.get<std::vector<size_t>>("StructuringElement", std::vector<size_t>()={8,16});
223  fMorphWindow = pset.get<size_t >("FilterWindow", 10);
224  fThreshold = pset.get<std::vector<float> >("Threshold", std::vector<float>()={5.0,3.5,3.5});
225  fDiagnosticOutput = pset.get<bool >("DiagnosticOutput", false);
226  fFilterModeVec = pset.get<std::vector<char> >("FilterModeVec", std::vector<char>()={'g','g','d'}); //{'d','e','g'});
227 
228  FragmentIDVec tempIDVec = pset.get< FragmentIDVec >("FragmentIDVec", FragmentIDVec());
229 
230  for(const auto& idPair : tempIDVec) fFragmentIDMap[idPair.first] = idPair.second;
231 
232  fGeometry = art::ServiceHandle<geo::Geometry const>{}.get();
233  fChannelMap = art::ServiceHandle<icarusDB::IICARUSChannelMap const>{}.get();
234 
235 // std::vector<double> highPassSigma = {3.5, 3.5, 0.5};
236 // std::vector<double> highPassCutoff = {12., 12., 2.};
237 // So we build a filter kernel for convolution with the waveform working in "tick" space.
238 // For translation, each "tick" is approximately 0.61 kHz... the frequency response functions all
239 // are essentially zero by 500 kHz which is like 800 "ticks".
240  std::vector<std::pair<double,double>> windowSigma = {{1.5,20.}, {1.5,20.}, {2.0,20.}};
241  std::vector<std::pair<double,double>> windowCutoff = {{8.,800.}, {8.,800.}, {3.0,800.}};
242 
243 
244  for(int plane = 0; plane < 3; plane++)
245  {
246  fFFTFilterFunctionVec.emplace_back(std::make_unique<icarus_signal_processing::WindowFFTFilter>(windowSigma[plane], windowCutoff[plane]));
247  }
248 
249  return;
250 }
const geo::Geometry * fGeometry
std::vector< char > fFilterModeVec
const icarusDB::IICARUSChannelMap * fChannelMap
icarus_signal_processing::FFTFilterFunctionVec fFFTFilterFunctionVec
std::vector< FragmentIDPair > FragmentIDVec
std::vector< size_t > fStructuringElement
const icarus_signal_processing::VectorInt daq::TPCDecoderFilter2D::getChannelIDs ( ) const
inlineoverridevirtual

Recover the channels for the processed fragment.

Implements daq::IDecoderFilter.

Definition at line 77 of file TPCDecoderFilter2D_tool.cc.

77 {return fChannelIDVec;}
icarus_signal_processing::VectorInt fChannelIDVec
const icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::getCorrectedMedians ( ) const
inlineoverridevirtual

Recover the correction median values.

Implements daq::IDecoderFilter.

Definition at line 107 of file TPCDecoderFilter2D_tool.cc.

107 {return fCorrectedMedians;};
icarus_signal_processing::ArrayFloat fCorrectedMedians
const icarus_signal_processing::VectorFloat daq::TPCDecoderFilter2D::getFullRMSVals ( ) const
inlineoverridevirtual

Recover the full RMS before coherent noise.

Implements daq::IDecoderFilter.

Definition at line 127 of file TPCDecoderFilter2D_tool.cc.

127 {return fFullRMSVals;};
icarus_signal_processing::VectorFloat fFullRMSVals
const icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::getIntrinsicRMS ( ) const
inlineoverridevirtual

Recover the "intrinsic" RMS.

Implements daq::IDecoderFilter.

Definition at line 102 of file TPCDecoderFilter2D_tool.cc.

102 {return fIntrinsicRMS;};
icarus_signal_processing::ArrayFloat fIntrinsicRMS
const icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::getMorphedWaveforms ( ) const
inlineoverridevirtual

Recover the morphological filter waveforms.

Implements daq::IDecoderFilter.

Definition at line 117 of file TPCDecoderFilter2D_tool.cc.

117 {return fMorphedWaveforms;};
icarus_signal_processing::ArrayFloat fMorphedWaveforms
const icarus_signal_processing::VectorInt daq::TPCDecoderFilter2D::getNumTruncBins ( ) const
inlineoverridevirtual

Recover the number of bins after truncation.

Implements daq::IDecoderFilter.

Definition at line 137 of file TPCDecoderFilter2D_tool.cc.

137 {return fNumTruncBins;};
icarus_signal_processing::VectorInt fNumTruncBins
const icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::getPedCorWaveforms ( ) const
inlineoverridevirtual

Recover the pedestal subtracted waveforms.

Implements daq::IDecoderFilter.

Definition at line 97 of file TPCDecoderFilter2D_tool.cc.

97 {return fPedCorWaveforms;};
icarus_signal_processing::ArrayFloat fPedCorWaveforms
const icarus_signal_processing::VectorFloat daq::TPCDecoderFilter2D::getPedestalVals ( ) const
inlineoverridevirtual

Recover the pedestals for each channel.

Implements daq::IDecoderFilter.

Definition at line 122 of file TPCDecoderFilter2D_tool.cc.

122 {return fPedestalVals;};
icarus_signal_processing::VectorFloat fPedestalVals
const icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::getRawWaveforms ( ) const
inlineoverridevirtual

Recover the pedestal subtracted waveforms.

Implements daq::IDecoderFilter.

Definition at line 92 of file TPCDecoderFilter2D_tool.cc.

92 {return fRawWaveforms;};
icarus_signal_processing::ArrayFloat fRawWaveforms
const icarus_signal_processing::ArrayBool daq::TPCDecoderFilter2D::getROIVals ( ) const
inlineoverridevirtual

Recover the ROI values.

Implements daq::IDecoderFilter.

Definition at line 87 of file TPCDecoderFilter2D_tool.cc.

87 {return fROIVals;};
icarus_signal_processing::ArrayBool fROIVals
const icarus_signal_processing::ArrayBool daq::TPCDecoderFilter2D::getSelectionVals ( ) const
inlineoverridevirtual

Recover the selection values.

Implements daq::IDecoderFilter.

Definition at line 82 of file TPCDecoderFilter2D_tool.cc.

82 {return fSelectVals;};
icarus_signal_processing::ArrayBool fSelectVals
const icarus_signal_processing::VectorFloat daq::TPCDecoderFilter2D::getTruncRMSVals ( ) const
inlineoverridevirtual

Recover the truncated RMS noise.

Implements daq::IDecoderFilter.

Definition at line 132 of file TPCDecoderFilter2D_tool.cc.

132 {return fTruncRMSVals;};
icarus_signal_processing::VectorFloat fTruncRMSVals
const icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::getWaveLessCoherent ( ) const
inlineoverridevirtual

Recover the waveforms less coherent noise.

Implements daq::IDecoderFilter.

Definition at line 112 of file TPCDecoderFilter2D_tool.cc.

112 {return fWaveLessCoherent;};
icarus_signal_processing::ArrayFloat fWaveLessCoherent
void daq::TPCDecoderFilter2D::process_fragment ( detinfo::DetectorClocksData const &  ,
const artdaq::Fragment &  fragment 
)
overridevirtual

Given a set of recob hits, run DBscan to form 3D clusters.

Parameters
fragmentThe artdaq fragment to process

Implements daq::IDecoderFilter.

Definition at line 252 of file TPCDecoderFilter2D_tool.cc.

254 {
255  cet::cpu_timer theClockTotal;
256 
257  theClockTotal.start();
258 
259  // convert fragment to Nevis fragment
260  icarus::PhysCrateFragment physCrateFragment(fragment);
261 
262  size_t nBoardsPerFragment = physCrateFragment.nBoards();
263  size_t nChannelsPerBoard = physCrateFragment.nChannelsPerBoard();
264  size_t nSamplesPerChannel = physCrateFragment.nSamplesPerChannel();
265 // size_t nChannelsPerFragment = nBoardsPerFragment * nChannelsPerBoard;
266 
267  // Recover the Fragment id:
268  artdaq::detail::RawFragmentHeader::fragment_id_t fragmentID = fragment.fragmentID();
269 
270  if (fDiagnosticOutput) std::cout << "==> Recovered fragmentID: " << std::hex << fragmentID << std::dec << " ";
271 
272  // Look for special case of diagnostic running
273  if (!fChannelMap->hasFragmentID(fragmentID))
274  {
275  if (fFragmentIDMap.find(fragmentID) == fFragmentIDMap.end()) //throw std::runtime_error("You can't save yourself");
276  {
277  theClockTotal.stop();
278  if (fDiagnosticOutput) std::cout << " **** no match found ****" << std::endl;
279 
280  return;
281  }
282 
283  if (fDiagnosticOutput) std::cout << "No match, use fhicl list? Have fragmentID: " << fragmentID << ", make it: " << std::hex << fFragmentIDMap[fragmentID] << std::dec << std::endl;
284 
285  fragmentID = fFragmentIDMap[fragmentID];
286 
287  if (!fChannelMap->hasFragmentID(fragmentID))
288  {
289  if (fDiagnosticOutput) std::cout << "WTF? This really can't happen, right?" << std::endl;
290  return;
291  }
292 
293  }
294 
295  if (fDiagnosticOutput) std::cout << std::endl;
296 
297  // Recover the crate name for this fragment
298  const std::string& crateName = fChannelMap->getCrateName(fragmentID);
299 
300  // Get the board ids for this fragment
301  const icarusDB::ReadoutIDVec& readoutIDVec = fChannelMap->getReadoutBoardVec(fragmentID);
302 
303  icarusDB::ReadoutIDVec boardIDVec(readoutIDVec.size());
304 
305  // Note we want these to be in "slot" order...
306  for(const auto& boardID : readoutIDVec)
307  {
308  // Look up the channels associated to this board
309  if (!fChannelMap->hasBoardID(boardID))
310  {
311  if (fDiagnosticOutput)
312  {
313  std::cout << "*** COULD NOT FIND BOARD ***" << std::endl;
314  std::cout << " - boardID: " << std::hex << boardID << ", board map size: " << readoutIDVec.size() << ", nBoardsPerFragment: " << nBoardsPerFragment << std::endl;
315  }
316 
317  return;
318  }
319 
320  unsigned int boardSlot = fChannelMap->getBoardSlot(boardID);
321 
322  boardIDVec[boardSlot] = boardID;
323  }
324 
325  if (fDiagnosticOutput)
326  {
327  std::cout << " - # boards: " << boardIDVec.size() << ", boards: ";
328  for(const auto& id : boardIDVec) std::cout << id << " ";
329  std::cout << std::endl;
330  }
331 
332  // Make sure these always get defined to be as large as can be
333  const size_t maxChannelsPerFragment(576);
334 
335  if (fSelectVals.empty()) fSelectVals = icarus_signal_processing::ArrayBool(maxChannelsPerFragment, icarus_signal_processing::VectorBool(nSamplesPerChannel));
336  if (fROIVals.empty()) fROIVals = icarus_signal_processing::ArrayBool(maxChannelsPerFragment, icarus_signal_processing::VectorBool(nSamplesPerChannel));
337  if (fRawWaveforms.empty()) fRawWaveforms = icarus_signal_processing::ArrayFloat(maxChannelsPerFragment, icarus_signal_processing::VectorFloat(nSamplesPerChannel));
338  if (fPedCorWaveforms.empty()) fPedCorWaveforms = icarus_signal_processing::ArrayFloat(maxChannelsPerFragment, icarus_signal_processing::VectorFloat(nSamplesPerChannel));
339  if (fIntrinsicRMS.empty()) fIntrinsicRMS = icarus_signal_processing::ArrayFloat(maxChannelsPerFragment, icarus_signal_processing::VectorFloat(nSamplesPerChannel));
340  if (fCorrectedMedians.empty()) fCorrectedMedians = icarus_signal_processing::ArrayFloat(maxChannelsPerFragment, icarus_signal_processing::VectorFloat(nSamplesPerChannel));
341  if (fWaveLessCoherent.empty()) fWaveLessCoherent = icarus_signal_processing::ArrayFloat(maxChannelsPerFragment, icarus_signal_processing::VectorFloat(nSamplesPerChannel));
342  if (fMorphedWaveforms.empty()) fMorphedWaveforms = icarus_signal_processing::ArrayFloat(maxChannelsPerFragment, icarus_signal_processing::VectorFloat(nSamplesPerChannel));
343 
344  if (fChannelIDVec.empty()) fChannelIDVec = icarus_signal_processing::VectorInt(maxChannelsPerFragment);
345  if (fPedestalVals.empty()) fPedestalVals = icarus_signal_processing::VectorFloat(maxChannelsPerFragment);
346  if (fFullRMSVals.empty()) fFullRMSVals = icarus_signal_processing::VectorFloat(maxChannelsPerFragment);
347  if (fTruncRMSVals.empty()) fTruncRMSVals = icarus_signal_processing::VectorFloat(maxChannelsPerFragment);
348  if (fNumTruncBins.empty()) fNumTruncBins = icarus_signal_processing::VectorInt(maxChannelsPerFragment);
349  if (fRangeBins.empty()) fRangeBins = icarus_signal_processing::VectorInt(maxChannelsPerFragment);
350 
351  if (fThresholdVec.empty()) fThresholdVec = icarus_signal_processing::VectorFloat(maxChannelsPerFragment);
352 
353  if (fPlaneVec.empty()) fPlaneVec.resize(nChannelsPerBoard,0);
354 
355  // Allocate the de-noising object
356 // icarus_signal_processing::Denoiser2D_Hough denoiser;
357  icarus_signal_processing::WaveformTools<float> waveformTools;
358 
359  cet::cpu_timer theClockPedestal;
360 
361  theClockPedestal.start();
362 
363  // The first task is to recover the data from the board data block, determine and subtract the pedestals
364  // and store into vectors useful for the next steps
365  for(size_t board = 0; board < boardIDVec.size(); board++)
366  {
367  const icarusDB::ChannelPlanePairVec& channelPlanePairVec = fChannelMap->getChannelPlanePair(boardIDVec[board]);
368 
369  uint32_t boardSlot = physCrateFragment.DataTileHeader(board)->StatusReg_SlotID();
370 
371  if (fDiagnosticOutput)
372  {
373  std::cout << "********************************************************************************" << std::endl;
374  std::cout << "FragmentID: " << std::hex << fragmentID << ", Crate: " << crateName << std::dec << ", boardID: " << boardSlot << "/" << nBoardsPerFragment << ", size " << channelPlanePairVec.size() << "/" << nChannelsPerBoard << ", ";
375  std::cout << std::endl;
376  }
377 
378  // This is where we would recover the base channel for the board from database/module
379  size_t boardOffset = nChannelsPerBoard * board;
380 
381  // Get the pointer to the start of this board's block of data
382  const icarus::A2795DataBlock::data_t* dataBlock = physCrateFragment.BoardData(board);
383 
384  // Copy to input data array
385  for(size_t chanIdx = 0; chanIdx < nChannelsPerBoard; chanIdx++)
386  {
387  // Get the channel number on the Fragment
388  size_t channelOnBoard = boardOffset + chanIdx;
389 
390  icarus_signal_processing::VectorFloat& rawDataVec = fRawWaveforms[channelOnBoard];
391 
392  for(size_t tick = 0; tick < nSamplesPerChannel; tick++)
393  rawDataVec[tick] = -dataBlock[chanIdx + tick * nChannelsPerBoard];
394 
395  icarus_signal_processing::VectorFloat& pedCorDataVec = fPedCorWaveforms[channelOnBoard];
396 
397  // Keep track of the channel
398  fChannelIDVec[channelOnBoard] = channelPlanePairVec[chanIdx].first;
399 
400  // Handle the filter function to use for this channel
401  unsigned int plane = channelPlanePairVec[chanIdx].second;
402 
403  fPlaneVec[chanIdx] = plane;
404 
405  // Set the threshold for this channel
406  fThresholdVec[channelOnBoard] = fThreshold[plane];
407 
408  // Now determine the pedestal and correct for it
409  waveformTools.getPedestalCorrectedWaveform(rawDataVec,
410  pedCorDataVec,
412  fPedestalVals[channelOnBoard],
413  fFullRMSVals[channelOnBoard],
414  fTruncRMSVals[channelOnBoard],
415  fNumTruncBins[channelOnBoard],
416  fRangeBins[channelOnBoard]);
417 
418  // Convolve with a filter function
419  (*fFFTFilterFunctionVec[plane])(pedCorDataVec);
420 
421  if (fDiagnosticOutput)
422  {
423  std::vector<geo::WireID> widVec = fGeometry->ChannelToWire(channelPlanePairVec[chanIdx].first);
424 
425  if (widVec.empty()) std::cout << channelPlanePairVec[chanIdx].first << "/" << chanIdx << "=" << fFullRMSVals[channelOnBoard] << " * ";
426  else std::cout << fChannelIDVec[channelOnBoard] << "-" << widVec[0].Cryostat << "/" << widVec[0].TPC << "/" << widVec[0].Plane << "/" << widVec[0].Wire << "=" << fFullRMSVals[channelOnBoard] << " * ";
427  }
428  }
429 
430  if (fDiagnosticOutput) std::cout << std::endl;
431 
432  // The assumption is that channels map to planes in a continuous manner.
433  // For the first induction all the channels on a board should map to the same plane
434  // For middle induction and collection you map to two planes where one group of 32 will go to one plane, the other group to the other plane.
435  // So we need to go through the planeVec to understand how to break this up...
436  unsigned int startChannel(0);
437 
438  while(startChannel < fPlaneVec.size())
439  {
440  unsigned int stopChannel = startChannel;
441  unsigned int plane = fPlaneVec[startChannel];
442 
443  while(stopChannel < fPlaneVec.size() && fPlaneVec[stopChannel] == plane) stopChannel++;
444 
445  size_t deltaChannels = stopChannel - startChannel;
446 
447  std::cout << "==> Board Offset: " << boardOffset << ", start: " << startChannel << ", stop: " << stopChannel << ", delta: " << deltaChannels << std::endl;
448 
449  if (deltaChannels >= 32) // How can we handle this?
450  {
451  // Filter function
452  std::unique_ptr<icarus_signal_processing::IMorphologicalFunctions2D> filterFunctionPtr;
453 
454  switch(fFilterModeVec[plane])
455  {
456  case 'd' :
457  filterFunctionPtr = std::make_unique<icarus_signal_processing::Dilation2D>(fStructuringElement[0],fStructuringElement[1]);
458  break;
459  case 'e' :
460  filterFunctionPtr = std::make_unique<icarus_signal_processing::Erosion2D>(fStructuringElement[0],fStructuringElement[1]);
461  break;
462  case 'g' :
463  filterFunctionPtr = std::make_unique<icarus_signal_processing::Gradient2D>(fStructuringElement[0],fStructuringElement[1]);
464  break;
465  case 'a' :
466  filterFunctionPtr = std::make_unique<icarus_signal_processing::Average2D>(fStructuringElement[0],fStructuringElement[1]);
467  break;
468  case 'm' :
469  filterFunctionPtr = std::make_unique<icarus_signal_processing::Median2D>(fStructuringElement[0],fStructuringElement[1],0);
470  break;
471  default:
472  std::cout << "***** FOUND NO MATCH FOR TYPE: " << fFilterModeVec[plane] << ", plane " << plane << " DURING INITIALIZATION OF FILTER FUNCTIONS IN TPCDecoderFilter2D" << std::endl;
473  break;
474  }
475 
476  if (boardOffset + startChannel + deltaChannels > fWaveLessCoherent.size())
477  {
478  std::cout << "*** Attempting to write past end of array, boardOffset: " << boardOffset << ", startChannel: " << startChannel << ", deltaChannels: " << deltaChannels << ", array size:" << fWaveLessCoherent.size() << std::endl;
479  startChannel = stopChannel;
480  continue;
481  }
482 
483  icarus_signal_processing::Denoiser2D_Hough denoiser(filterFunctionPtr.get(), fThresholdVec, fCoherentNoiseGrouping, fCoherentNoiseOffset, fMorphWindow);
484 
485  // Run the coherent filter
486  denoiser(fWaveLessCoherent.begin() + boardOffset + startChannel,
487  fPedCorWaveforms.begin() + boardOffset + startChannel,
488  fMorphedWaveforms.begin() + boardOffset + startChannel,
489  fIntrinsicRMS.begin() + boardOffset + startChannel,
490  fSelectVals.begin() + boardOffset + startChannel,
491  fROIVals.begin() + boardOffset + startChannel,
492  fCorrectedMedians.begin() + boardOffset + startChannel,
493  deltaChannels);
494 
495  }
496 
497  startChannel = stopChannel;
498  }
499 
500  }
501 
502  // We need to make sure the channelID information is not preserved when less than 9 boards in the fragment
503  if (boardIDVec.size() < 9)
504  {
505  std::fill(fChannelIDVec.begin() + boardIDVec.size() * nChannelsPerBoard, fChannelIDVec.end(), -1);
506  }
507 
508  theClockPedestal.stop();
509 
510  double pedestalTime = theClockPedestal.accumulated_real_time();
511 
512  cet::cpu_timer theClockDenoise;
513 
514  theClockDenoise.start();
515 
516  theClockDenoise.stop();
517 
518  double denoiseTime = theClockDenoise.accumulated_real_time();
519 
520  theClockDenoise.start();
521 
522  theClockDenoise.stop();
523 
524  double cohPedSubTime = theClockDenoise.accumulated_real_time() - denoiseTime;
525 
526 
527  theClockTotal.stop();
528 
529  double totalTime = theClockTotal.accumulated_real_time();
530 
531  mf::LogInfo("TPCDecoderFilter2D") << " *totalTime: " << totalTime << ", pedestal: " << pedestalTime << ", noise: " << denoiseTime << ", ped cor: " << cohPedSubTime << std::endl;
532 
533  return;
534 }
icarus_signal_processing::ArrayFloat fPedCorWaveforms
icarus_signal_processing::VectorFloat fFullRMSVals
std::vector< ChannelPlanePair > ChannelPlanePairVec
std::vector< unsigned int > fPlaneVec
const geo::Geometry * fGeometry
icarus_signal_processing::VectorFloat fTruncRMSVals
std::vector< unsigned int > ReadoutIDVec
virtual const ReadoutIDVec & getReadoutBoardVec(const unsigned int) const =0
icarus_signal_processing::VectorInt fChannelIDVec
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
icarus_signal_processing::VectorInt fRangeBins
std::vector< char > fFilterModeVec
virtual const std::string & getCrateName(const unsigned int) const =0
icarus_signal_processing::VectorInt fNumTruncBins
virtual bool hasBoardID(const unsigned int) const =0
icarus_signal_processing::ArrayFloat fMorphedWaveforms
icarus_signal_processing::ArrayFloat fIntrinsicRMS
const icarusDB::IICARUSChannelMap * fChannelMap
icarus_signal_processing::FFTFilterFunctionVec fFFTFilterFunctionVec
icarus_signal_processing::VectorFloat fThresholdVec
virtual const ChannelPlanePairVec & getChannelPlanePair(const unsigned int) const =0
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
virtual bool hasFragmentID(const unsigned int) const =0
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
icarus_signal_processing::VectorFloat fPedestalVals
icarus_signal_processing::ArrayBool fROIVals
std::vector< size_t > fStructuringElement
icarus_signal_processing::ArrayFloat fWaveLessCoherent
icarus_signal_processing::ArrayFloat fCorrectedMedians
virtual unsigned int getBoardSlot(const unsigned int) const =0
icarus_signal_processing::ArrayFloat fRawWaveforms
icarus_signal_processing::ArrayBool fSelectVals
BEGIN_PROLOG could also be cout

Member Data Documentation

icarus_signal_processing::VectorInt daq::TPCDecoderFilter2D::fChannelIDVec
private

Definition at line 159 of file TPCDecoderFilter2D_tool.cc.

const icarusDB::IICARUSChannelMap* daq::TPCDecoderFilter2D::fChannelMap
private

Definition at line 180 of file TPCDecoderFilter2D_tool.cc.

size_t daq::TPCDecoderFilter2D::fCoherentNoiseGrouping
private

Definition at line 143 of file TPCDecoderFilter2D_tool.cc.

size_t daq::TPCDecoderFilter2D::fCoherentNoiseOffset
private

Definition at line 144 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::fCorrectedMedians
private

Definition at line 165 of file TPCDecoderFilter2D_tool.cc.

bool daq::TPCDecoderFilter2D::fDiagnosticOutput
private

Definition at line 148 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::FFTFilterFunctionVec daq::TPCDecoderFilter2D::fFFTFilterFunctionVec
private

Definition at line 183 of file TPCDecoderFilter2D_tool.cc.

std::vector<char> daq::TPCDecoderFilter2D::fFilterModeVec
private

Definition at line 150 of file TPCDecoderFilter2D_tool.cc.

uint32_t daq::TPCDecoderFilter2D::fFragment_id_offset
private

Definition at line 137 of file TPCDecoderFilter2D_tool.cc.

FragmentIDMap daq::TPCDecoderFilter2D::fFragmentIDMap
private

Definition at line 156 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::VectorFloat daq::TPCDecoderFilter2D::fFullRMSVals
private

Definition at line 170 of file TPCDecoderFilter2D_tool.cc.

const geo::Geometry* daq::TPCDecoderFilter2D::fGeometry
private

Definition at line 179 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::fIntrinsicRMS
private

Definition at line 164 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::fMorphedWaveforms
private

Definition at line 167 of file TPCDecoderFilter2D_tool.cc.

size_t daq::TPCDecoderFilter2D::fMorphWindow
private

Definition at line 146 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::VectorInt daq::TPCDecoderFilter2D::fNumTruncBins
private

Definition at line 172 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::fPedCorWaveforms
private

Definition at line 163 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::VectorFloat daq::TPCDecoderFilter2D::fPedestalVals
private

Definition at line 169 of file TPCDecoderFilter2D_tool.cc.

std::vector<unsigned int> daq::TPCDecoderFilter2D::fPlaneVec
private

Definition at line 177 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::VectorInt daq::TPCDecoderFilter2D::fRangeBins
private

Definition at line 173 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::fRawWaveforms
private

Definition at line 162 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayBool daq::TPCDecoderFilter2D::fROIVals
private

Definition at line 161 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayBool daq::TPCDecoderFilter2D::fSelectVals
private

Definition at line 160 of file TPCDecoderFilter2D_tool.cc.

float daq::TPCDecoderFilter2D::fSigmaForTruncation
private

Definition at line 142 of file TPCDecoderFilter2D_tool.cc.

std::vector<size_t> daq::TPCDecoderFilter2D::fStructuringElement
private

Definition at line 145 of file TPCDecoderFilter2D_tool.cc.

std::vector<float> daq::TPCDecoderFilter2D::fThreshold
private

Definition at line 147 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::VectorFloat daq::TPCDecoderFilter2D::fThresholdVec
private

Definition at line 175 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::VectorFloat daq::TPCDecoderFilter2D::fTruncRMSVals
private

Definition at line 171 of file TPCDecoderFilter2D_tool.cc.

icarus_signal_processing::ArrayFloat daq::TPCDecoderFilter2D::fWaveLessCoherent
private

Definition at line 166 of file TPCDecoderFilter2D_tool.cc.


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