AcdWireReader_tool.cc
Go to the documentation of this file.
1 // AcdWireReader_tool.cc
2 
3 #include "AcdWireReader.h"
4 #include <iostream>
6 
7 using std::string;
8 using std::cout;
9 using std::endl;
10 using raw::RawDigit;
11 using recob::Wire;
12 
13 //**********************************************************************
14 
16 : m_LogLevel(ps.get<int>("LogLevel")) {
17  const string myname = "AcdWireReader::ctor: ";
18  if ( m_LogLevel > 0 ) {
19  cout << myname << " LogLevel: " << m_LogLevel << endl;
20  }
21 }
22 
23 //**********************************************************************
24 
26  const string myname = "AcdWireReader::update: ";
27  // Take the wire from the channel data.
28  const Wire* pwir = acd.wire;
29  if ( pwir == nullptr ) {
30  cout << myname << "ERROR: Wire is null." << endl;
31  return DataMap(1);
32  }
33  const Wire& wir = *pwir;
34  // Check the input data is empty.
35  if ( acd.samples.size() ) {
36  cout << myname << "ERROR: ADC channel has prepared data." << endl;
37  return DataMap(2);
38  }
39  // Check the signal flags record is empty.
40  if ( acd.signal.size() ) {
41  cout << myname << "ERROR: ADC channel has signal flags." << endl;
42  return DataMap(3);
43  }
44  // Check the ROI data is empty.
45  if ( acd.rois.size() ) {
46  cout << myname << "ERROR: ADC channel has ROIs." << endl;
47  return DataMap(4);
48  }
49  // Set or check the wire index.
50  if ( acd.wireIndex != AdcChannelData::badIndex() ) {
51  cout << myname << "ERROR: ADC channel has a wire index." << endl;
52  return DataMap(5);
53  }
54  // Set or check the channel.
55  if ( acd.channel() == AdcChannelData::badChannel() ) {
56  acd.setChannelInfo(wir.Channel());
57  } else {
58  if ( acd.channel() != wir.Channel() ) {
59  cout << myname << "ERROR: Wire has inconsistent channel number." << endl;
60  return DataMap(6);
61  }
62  }
63  // Resize the signal array.
64  unsigned int nsig = pwir->NSignal();
65  // Loop over ROIs and fetch the samples and signals.
66  acd.samples.resize(nsig, 0.0);
67  acd.signal.resize(nsig, false);
68  const lar::sparse_vector<float>& inRois = pwir->SignalROI();
69  for ( const lar::sparse_vector<double>::datarange_t& range : inRois.get_ranges()) {
70  unsigned int isig1 = range.begin_index();
71  unsigned int isig2 = isig1 + range.size();
72  for ( unsigned int isig=isig1; isig<isig2; ++isig ) {
73  acd.samples[isig] = inRois[isig];
74  acd.signal[isig] = true;
75  }
76  }
77  acd.roisFromSignal(); // Fill in the channel data ROIs
78 
79  return DataMap(0);
80 }
81 
82 //**********************************************************************
83 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
size_type size() const
Returns the size of the vector.
std::string string
Definition: nybbler.cc:12
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
DataMap update(AdcChannelData &acd) const override
const recob::Wire * wire
void setChannelInfo(ChannelInfoPtr pchi)
AdcRoiVector rois
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:231
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Definition: Wire.h:228
static constexpr double ps
Definition: Units.h:99
Channel channel() const
AdcFilterVector signal
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
Range class, with range and data.
Declaration of basic channel signal object.
static Index badChannel()
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
AdcIndex wireIndex
static Index badIndex()
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AcdWireReader(fhicl::ParameterSet const &ps)
std::size_t NSignal() const
Returns the number of time ticks, or samples, in the channel.
Definition: Wire.h:229