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

Classes

class  multiThreadFragmentProcessing
 

Public Types

using RawDigitCollection = std::vector< raw::RawDigit >
 
using RawDigitCollectionPtr = std::unique_ptr< RawDigitCollection >
 
using ConcurrentRawDigitCol = tbb::concurrent_vector< raw::RawDigit >
 

Public Member Functions

 FilterNoiseICARUS (fhicl::ParameterSet const &pset, art::ProcessingFrame const &frame)
 
virtual ~FilterNoiseICARUS ()
 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 processSingleFragment (size_t, detinfo::DetectorClocksData const &clockData, art::Handle< artdaq::Fragments >, ConcurrentRawDigitCol &, ConcurrentRawDigitCol &, ConcurrentRawDigitCol &) const
 

Private Member Functions

void saveRawDigits (const icarus_signal_processing::ArrayFloat &, const icarus_signal_processing::VectorFloat &, const icarus_signal_processing::VectorFloat &, const icarus_signal_processing::VectorInt &, ConcurrentRawDigitCol &) const
 

Private Attributes

std::vector< std::unique_ptr
< IDecoderFilter > > 
fDecoderToolVec
 Decoder tools. More...
 
art::InputTag fFragmentsLabel
 The input artdaq fragment label. More...
 
bool fOutputPedestalCor
 Should we output pedestal corrected (not noise filtered)? More...
 
bool fOutputCorrection
 Should we output the coherent noise correction vectors? More...
 
std::string fOutputPedCorPath
 Path to assign to the output if asked for. More...
 
std::string fOutputCoherentPath
 Path to assign to the output if asked for. More...
 
unsigned int fPlaneToSimulate
 Use to get fragment offset. More...
 
int fNumEvent
 Number of events seen. More...
 
size_t fFragmentOffset
 The fragment offset to set channel numbering. More...
 
geo::GeometryCore const * fGeometry
 pointer to Geometry service More...
 

Detailed Description

Definition at line 56 of file FilterNoiseICARUS_module.cc.

Member Typedef Documentation

Definition at line 73 of file FilterNoiseICARUS_module.cc.

Definition at line 71 of file FilterNoiseICARUS_module.cc.

Definition at line 72 of file FilterNoiseICARUS_module.cc.

Constructor & Destructor Documentation

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

Constructor.

Arguments:

pset - Fcl parameters.

Definition at line 149 of file FilterNoiseICARUS_module.cc.

149  :
150  art::ReplicatedProducer(pset, frame),
151  fNumEvent(0)
152 {
153  fGeometry = lar::providerFrom<geo::Geometry>();
154 
155  configure(pset);
156 
157  // Check the concurrency
158  int max_concurrency = tbb::this_task_arena::max_concurrency();
159 
160  mf::LogDebug("FilterNoiseICARUS") << " ==> concurrency: " << max_concurrency << std::endl;
161 
162  // Recover the vector of fhicl parameters for the ROI tools
163  const fhicl::ParameterSet& decoderToolParams = pset.get<fhicl::ParameterSet>("DecoderTool");
164 
165  fDecoderToolVec.resize(max_concurrency);
166 
167  for(auto& decoderTool : fDecoderToolVec)
168  {
169  // Get instance of tool
170  decoderTool = art::make_tool<IDecoderFilter>(decoderToolParams);
171  }
172 
173  // Compute the fragment offset from the channel number for the desired plane
174  // Get a base channel number for the plane we want
175  mf::LogDebug("FilterNoiseICARUS") << "ICARUS has " << fGeometry->Nchannels() << " in total with " << fGeometry->Views().size() << " views" << std::endl;
176 
177  geo::WireID wireID(0, 0, fPlaneToSimulate, 0);
178 
179  mf::LogDebug("FilterNoiseICARUS") << "WireID: " << wireID << std::endl;
180 
182 
183  mf::LogDebug("FilterNoiseICARUS") << "From geo, first WireID: " << firstWireID << std::endl;
184 
185  raw::ChannelID_t channel = fGeometry->PlaneWireToChannel(wireID);
186 
187  mf::LogDebug("FilterNoiseICARUS") << "Channel: " << channel << std::endl;
188 
189  for(size_t thePlane = 0; thePlane < 3; thePlane++)
190  {
191  geo::WireID tempWireID(0, 0, thePlane, 0);
192  geo::PlaneID tempPlaneID = tempWireID.planeID();
193 
194  mf::LogDebug("FilterNoiseICARUS") << "thePlane: " << thePlane << ", WireID: " << tempWireID << ", channel: " <<
195  fGeometry->PlaneWireToChannel(tempWireID) << ", view: " << fGeometry->View(tempPlaneID) << std::endl;
196  }
197 
198  fFragmentOffset = channel / 576;
199 
200  produces<std::vector<raw::RawDigit>>();
201 
202  if (fOutputPedestalCor)
203  produces<std::vector<raw::RawDigit>>(fOutputPedCorPath);
204 
205  if (fOutputCorrection)
206  produces<std::vector<raw::RawDigit>>(fOutputCoherentPath);
207 
208  // Report.
209  mf::LogInfo("FilterNoiseICARUS") << "FilterNoiseICARUS configured\n";
210 }
std::string fOutputCoherentPath
Path to assign to the output if asked for.
std::vector< std::unique_ptr< IDecoderFilter > > fDecoderToolVec
Decoder tools.
std::set< geo::View_t > const & Views() const
Returns a list of possible views in the detector.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
size_t fFragmentOffset
The fragment offset to set channel numbering.
int fNumEvent
Number of events seen.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
unsigned int fPlaneToSimulate
Use to get fragment offset.
bool fOutputPedestalCor
Should we output pedestal corrected (not noise filtered)?
std::string fOutputPedCorPath
Path to assign to the output if asked for.
geo::GeometryCore const * fGeometry
pointer to Geometry service
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
bool fOutputCorrection
Should we output the coherent noise correction vectors?
virtual void configure(fhicl::ParameterSet const &pset)
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
geo::WireID GetBeginWireID(geo::CryostatID const &id) const
Returns the ID of the first wire in the specified cryostat.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
daq::FilterNoiseICARUS::~FilterNoiseICARUS ( )
virtual

Destructor.

Definition at line 214 of file FilterNoiseICARUS_module.cc.

215 {}

Member Function Documentation

void daq::FilterNoiseICARUS::beginJob ( art::ProcessingFrame const &  frame)
virtual

Begin job method.

Definition at line 236 of file FilterNoiseICARUS_module.cc.

237 {
238  return;
239 }
void daq::FilterNoiseICARUS::configure ( fhicl::ParameterSet const &  pset)
virtual

Reconfigure method.

Arguments:

pset - Fcl parameter set.

Definition at line 224 of file FilterNoiseICARUS_module.cc.

225 {
226  fFragmentsLabel = pset.get<art::InputTag>("FragmentsLabel", "daq:PHYSCRATEDATA");
227  fOutputPedestalCor = pset.get<bool >("OutputPedestalCor", false);
228  fOutputCorrection = pset.get<bool >("OutputCorrection", false);
229  fOutputPedCorPath = pset.get<std::string >("OutputPedCorPath", "RAW");
230  fOutputCoherentPath = pset.get<std::string >("OutputCoherentPath", "Cor");
231  fPlaneToSimulate = pset.get<unsigned int >("PlaneToSimulate", 2);
232 }
std::string fOutputCoherentPath
Path to assign to the output if asked for.
art::InputTag fFragmentsLabel
The input artdaq fragment label.
unsigned int fPlaneToSimulate
Use to get fragment offset.
bool fOutputPedestalCor
Should we output pedestal corrected (not noise filtered)?
std::string fOutputPedCorPath
Path to assign to the output if asked for.
bool fOutputCorrection
Should we output the coherent noise correction vectors?
void daq::FilterNoiseICARUS::endJob ( art::ProcessingFrame const &  frame)
virtual

End job method.

Definition at line 420 of file FilterNoiseICARUS_module.cc.

421 {
422  mf::LogInfo("FilterNoiseICARUS") << "Looked at " << fNumEvent << " events" << std::endl;
423 }
int fNumEvent
Number of events seen.
void daq::FilterNoiseICARUS::processSingleFragment ( size_t  idx,
detinfo::DetectorClocksData const &  clockData,
art::Handle< artdaq::Fragments >  fragmentHandle,
ConcurrentRawDigitCol rawDigitCollection,
ConcurrentRawDigitCol rawRawDigitCollection,
ConcurrentRawDigitCol coherentCollection 
) const

Definition at line 326 of file FilterNoiseICARUS_module.cc.

332 {
333  cet::cpu_timer theClockProcess;
334 
335  theClockProcess.start();
336 
337  art::Ptr<artdaq::Fragment> fragmentPtr(fragmentHandle, idx);
338 
339  mf::LogDebug("FilterNoiseICARUS") << "--> Processing fragment ID: " << fragmentPtr->fragmentID() << std::endl;
340  mf::LogDebug("FilterNoiseICARUS") << " ==> Current thread index: " << tbb::this_task_arena::current_thread_index() << std::endl;
341 
342  // Recover pointer to the decoder needed here
343  IDecoderFilter* decoderTool = fDecoderToolVec[tbb::this_task_arena::current_thread_index()].get();
344 
345  //process_fragment(event, rawfrag, product_collection, header_collection);
346  decoderTool->process_fragment(clockData, *fragmentPtr);
347 
348  // Useful numerology
349  // convert fragment to Nevis fragment
350  icarus::PhysCrateFragment physCrateFragment(*fragmentPtr);
351 
352 // size_t nBoardsPerFragment = physCrateFragment.nBoards();
353 // size_t nChannelsPerBoard = physCrateFragment.nChannelsPerBoard();
354 
355  // Set base channel for both the board and the board/fragment
356 // size_t boardFragOffset = nChannelsPerBoard * nBoardsPerFragment * (fragmentPtr->fragmentID() + fFragmentOffset);
357 
358  theClockProcess.stop();
359 
360  double totalTime = theClockProcess.accumulated_real_time();
361 
362  // Save the filtered RawDigitsactive but for corrected raw digits pedestal is zero
363  const icarus_signal_processing::VectorFloat locPedsVec(decoderTool->getWaveLessCoherent().size(),0.);
364  const icarus_signal_processing::VectorInt& channelVec = decoderTool->getChannelIDs();
365 
366  saveRawDigits(decoderTool->getWaveLessCoherent(),locPedsVec,decoderTool->getTruncRMSVals(), channelVec, rawDigitCollection);
367 
368  // Optionally, save the pedestal corrected RawDigits
369  if (fOutputPedestalCor)
370  saveRawDigits(decoderTool->getRawWaveforms(),decoderTool->getPedestalVals(),decoderTool->getFullRMSVals(),channelVec, rawRawDigitCollection);
371 
372  // Also optional is to output the coherent corrections (note there will be many fewer of these! )
373  if (fOutputPedestalCor)
374  saveRawDigits(decoderTool->getCorrectedMedians(),decoderTool->getPedestalVals(),decoderTool->getFullRMSVals(),channelVec,coherentCollection);
375 
376  mf::LogDebug("FilterNoiseICARUS") << "--> Exiting fragment processing for thread: " << tbb::this_task_arena::current_thread_index() << ", time: " << totalTime << std::endl;
377  return;
378 }
std::vector< std::unique_ptr< IDecoderFilter > > fDecoderToolVec
Decoder tools.
bool fOutputPedestalCor
Should we output pedestal corrected (not noise filtered)?
void saveRawDigits(const icarus_signal_processing::ArrayFloat &, const icarus_signal_processing::VectorFloat &, const icarus_signal_processing::VectorFloat &, const icarus_signal_processing::VectorInt &, ConcurrentRawDigitCol &) const
void daq::FilterNoiseICARUS::produce ( art::Event &  event,
art::ProcessingFrame const &  frame 
)
virtual

Produce method.

Arguments:

evt - Art event.

This is the primary method.

Definition at line 250 of file FilterNoiseICARUS_module.cc.

251 {
252  ++fNumEvent;
253 
254  art::Handle<artdaq::Fragments> daq_handle;
255  event.getByLabel(fFragmentsLabel, daq_handle);
256 
257  mf::LogDebug("FilterNoiseICARUS") << "**** Processing raw data fragments ****" << std::endl;
258 
259  // Check the concurrency
260  int max_concurrency = tbb::this_task_arena::max_concurrency();
261 
262  mf::LogDebug("FilterNoiseICARUS") << " ==> concurrency: " << max_concurrency << std::endl;
263 
264  cet::cpu_timer theClockTotal;
265 
266  theClockTotal.start();
267 
268  ConcurrentRawDigitCol concurrentRawDigits;
269  ConcurrentRawDigitCol concurrentRawRawDigits;
270  ConcurrentRawDigitCol coherentRawDigits;
271 
272  // ... Launch multiple threads with TBB to do the deconvolution and find ROIs in parallel
273  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(event);
274  multiThreadFragmentProcessing fragmentProcessing(*this,
275  clockData,
276  daq_handle,
277  concurrentRawDigits,
278  concurrentRawRawDigits,
279  coherentRawDigits);
280 
281  tbb::parallel_for(tbb::blocked_range<size_t>(0, daq_handle->size()), fragmentProcessing);
282 
283  // Copy the raw digits from the concurrent vector to our output vector
284  RawDigitCollectionPtr rawDigitCollection = std::make_unique<std::vector<raw::RawDigit>>(std::move_iterator(concurrentRawDigits.begin()),
285  std::move_iterator(concurrentRawDigits.end()));
286 
287  // Want the RawDigits to be sorted in channel order... has to be done somewhere so why not now?
288  std::sort(rawDigitCollection->begin(),rawDigitCollection->end(),[](const auto& left,const auto&right){return left.Channel() < right.Channel();});
289 
290  // Now transfer ownership to the event store
291  event.put(std::move(rawDigitCollection));
292 
293  if (fOutputPedestalCor)
294  {
295  // Copy the raw digits from the concurrent vector to our output vector
296  RawDigitCollectionPtr rawRawDigitCollection = std::make_unique<std::vector<raw::RawDigit>>(std::move_iterator(concurrentRawRawDigits.begin()),
297  std::move_iterator(concurrentRawRawDigits.end()));
298  // Want the RawDigits to be sorted in channel order... has to be done somewhere so why not now?
299  std::sort(rawRawDigitCollection->begin(),rawRawDigitCollection->end(),[](const auto& left,const auto&right){return left.Channel() < right.Channel();});
300 
301  // Now transfer ownership to the event store
302  event.put(std::move(rawRawDigitCollection),fOutputPedCorPath);
303  }
304 
305  if (fOutputCorrection)
306  {
307  // Copy the raw digits from the concurrent vector to our output vector
308  RawDigitCollectionPtr coherentCollection = std::make_unique<std::vector<raw::RawDigit>>(std::move_iterator(coherentRawDigits.begin()),
309  std::move_iterator(coherentRawDigits.end()));
310  // Want the RawDigits to be sorted in channel order... has to be done somewhere so why not now?
311  std::sort(coherentCollection->begin(),coherentCollection->end(),[](const auto& left,const auto&right){return left.Channel() < right.Channel();});
312 
313  // Now transfer ownership to the event store
314  event.put(std::move(coherentCollection),fOutputCoherentPath);
315  }
316 
317  theClockTotal.stop();
318 
319  double totalTime = theClockTotal.accumulated_real_time();
320 
321  mf::LogInfo("FilterNoiseICARUS") << "==> FilterNoiseICARUS total time: " << totalTime << std::endl;
322 
323  return;
324 }
std::string fOutputCoherentPath
Path to assign to the output if asked for.
tbb::concurrent_vector< raw::RawDigit > ConcurrentRawDigitCol
art::InputTag fFragmentsLabel
The input artdaq fragment label.
walls no right
Definition: selectors.fcl:105
std::unique_ptr< RawDigitCollection > RawDigitCollectionPtr
int fNumEvent
Number of events seen.
bool fOutputPedestalCor
Should we output pedestal corrected (not noise filtered)?
std::string fOutputPedCorPath
Path to assign to the output if asked for.
walls no left
Definition: selectors.fcl:105
bool fOutputCorrection
Should we output the coherent noise correction vectors?
void daq::FilterNoiseICARUS::saveRawDigits ( const icarus_signal_processing::ArrayFloat &  dataArray,
const icarus_signal_processing::VectorFloat &  pedestalVec,
const icarus_signal_processing::VectorFloat &  rmsVec,
const icarus_signal_processing::VectorInt &  channelVec,
ConcurrentRawDigitCol rawDigitCol 
) const
private

Definition at line 380 of file FilterNoiseICARUS_module.cc.

385 {
386  if (!dataArray.empty())
387  {
388  cet::cpu_timer theClockSave;
389 
390  theClockSave.start();
391 
392  raw::RawDigit::ADCvector_t wvfm(dataArray[0].size());
393 
394  mf::LogDebug("FilterNoiseICARUS") << " --> saving rawdigits for " << dataArray.size() << " channels" << std::endl;
395 
396  // Loop over the channels to recover the RawDigits after filtering
397  for(size_t chanIdx = 0; chanIdx != dataArray.size(); chanIdx++)
398  {
399  const icarus_signal_processing::VectorFloat& dataVec = dataArray[chanIdx];
400 
401  // Need to convert from float to short int
402  std::transform(dataVec.begin(),dataVec.end(),wvfm.begin(),[](const auto& val){return short(std::round(val));});
403 
404  ConcurrentRawDigitCol::iterator newObjItr = rawDigitCol.emplace_back(channelVec[chanIdx],wvfm.size(),wvfm);
405  newObjItr->SetPedestal(pedestalVec[chanIdx],rmsVec[chanIdx]);
406  }//loop over channel indices
407 
408  theClockSave.stop();
409 
410  double totalTime = theClockSave.accumulated_real_time();
411 
412  mf::LogDebug("FilterNoiseICARUS") << " --> done with save, time: " << totalTime << std::endl;
413  }
414 
415  return;
416 }
static constexpr Sample_t transform(Sample_t sample)
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561

Member Data Documentation

std::vector<std::unique_ptr<IDecoderFilter> > daq::FilterNoiseICARUS::fDecoderToolVec
private

Decoder tools.

Definition at line 121 of file FilterNoiseICARUS_module.cc.

size_t daq::FilterNoiseICARUS::fFragmentOffset
private

The fragment offset to set channel numbering.

Definition at line 134 of file FilterNoiseICARUS_module.cc.

art::InputTag daq::FilterNoiseICARUS::fFragmentsLabel
private

The input artdaq fragment label.

Definition at line 124 of file FilterNoiseICARUS_module.cc.

geo::GeometryCore const* daq::FilterNoiseICARUS::fGeometry
private

pointer to Geometry service

Definition at line 137 of file FilterNoiseICARUS_module.cc.

int daq::FilterNoiseICARUS::fNumEvent
private

Number of events seen.

Definition at line 132 of file FilterNoiseICARUS_module.cc.

std::string daq::FilterNoiseICARUS::fOutputCoherentPath
private

Path to assign to the output if asked for.

Definition at line 128 of file FilterNoiseICARUS_module.cc.

bool daq::FilterNoiseICARUS::fOutputCorrection
private

Should we output the coherent noise correction vectors?

Definition at line 126 of file FilterNoiseICARUS_module.cc.

std::string daq::FilterNoiseICARUS::fOutputPedCorPath
private

Path to assign to the output if asked for.

Definition at line 127 of file FilterNoiseICARUS_module.cc.

bool daq::FilterNoiseICARUS::fOutputPedestalCor
private

Should we output pedestal corrected (not noise filtered)?

Definition at line 125 of file FilterNoiseICARUS_module.cc.

unsigned int daq::FilterNoiseICARUS::fPlaneToSimulate
private

Use to get fragment offset.

Definition at line 129 of file FilterNoiseICARUS_module.cc.


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