AdcRoiShifter_tool.cc
Go to the documentation of this file.
1 // AdcRoiShifter_tool.cc
2 
3 #include "AdcRoiShifter.h"
4 #include <iostream>
5 
6 using std::string;
7 using std::cout;
8 using std::endl;
9 
10 //**********************************************************************
11 // Class methods.
12 //**********************************************************************
13 
15 : m_LogLevel(ps.get<int>("LogLevel")),
16  m_BinOffset(ps.get<int>("BinOffset")) {
17  const string myname = "AdcRoiShifter::ctor: ";
18  if ( m_LogLevel >= 1 ) {
19  cout << myname << "Configuration parameters:" << endl;
20  cout << myname << " LogLevel: " << m_LogLevel << endl;
21  cout << myname << " BinOffset: " << m_BinOffset<< endl;
22  }
23 }
24 
25 //**********************************************************************
26 
28  const string myname = "AdcRoiShifter::update: ";
29  DataMap ret;
30  AdcIndex nsam = acd.signal.size();
31  if ( nsam ==0 || m_BinOffset == 0 ) {
32  return ret;
33  } else if ( m_BinOffset > 0 ) {
34  AdcIndex shift = m_BinOffset;
35  for ( AdcIndex isam=nsam-1; isam>=shift; --isam ) {
36  acd.signal[isam] = acd.signal[isam-shift];
37  }
38  for ( AdcIndex isam=0; isam<shift; ++isam ) {
39  acd.signal[isam] = false;
40  }
41  } else {
42  AdcIndex shift = -m_BinOffset;
43  for ( AdcIndex isam=0; isam<nsam-shift; ++isam ) {
44  acd.signal[isam] = acd.signal[isam+shift];
45  }
46  for ( AdcIndex isam=nsam-shift; isam<nsam; ++isam ) {
47  acd.signal[isam] = false;
48  }
49  }
50  acd.roisFromSignal();
51  if ( m_LogLevel >= 3 ) {
52  cout << myname << " # ROI: " << acd.rois.size() << endl;
53  }
54  ret.setInt("nroi", acd.rois.size());
55  return ret;
56 }
57 
58 //**********************************************************************
59 
61  AdcChannelData acdtmp;
62  acdtmp.signal = acd.signal;
63  return update(acdtmp);
64 }
65 
66 //**********************************************************************
67 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
std::string string
Definition: nybbler.cc:12
AdcRoiShifter(fhicl::ParameterSet const &ps)
DataMap view(const AdcChannelData &acd) const override
AdcRoiVector rois
void setInt(Name name, int val)
Definition: DataMap.h:131
static constexpr double ps
Definition: Units.h:99
unsigned int AdcIndex
Definition: AdcTypes.h:15
DataMap update(AdcChannelData &acd) const override
AdcFilterVector signal
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
QTextStream & endl(QTextStream &s)