Public Types | Public Member Functions | Private Attributes | List of all members
AdcChannelTrimmer Class Reference

#include <AdcChannelTrimmer.h>

Inheritance diagram for AdcChannelTrimmer:
TpcDataTool AdcChannelTool

Public Types

using Index = unsigned int
 
- Public Types inherited from AdcChannelTool
using Index = unsigned int
 

Public Member Functions

 AdcChannelTrimmer (fhicl::ParameterSet const &ps)
 
 ~AdcChannelTrimmer () override=default
 
DataMap view (const AdcChannelData &acd) const override
 
DataMap update (AdcChannelData &acd) const override
 
- Public Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Public Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap updateMap (AdcChannelDataMap &acds) const
 
virtual DataMap viewMap (const AdcChannelDataMap &acds) const
 
virtual bool updateWithView () const
 
virtual bool viewWithUpdate () const
 
virtual DataMap beginEvent (const DuneEventInfo &) const
 
virtual DataMap endEvent (const DuneEventInfo &) const
 
virtual DataMap close (const DataMap *dmin=nullptr)
 

Private Attributes

int m_LogLevel
 
Index m_Length
 
Index m_MaxTrim
 

Additional Inherited Members

- Static Public Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 39 of file AdcChannelTrimmer.h.

Member Typedef Documentation

using AdcChannelTrimmer::Index = unsigned int

Definition at line 43 of file AdcChannelTrimmer.h.

Constructor & Destructor Documentation

AdcChannelTrimmer::AdcChannelTrimmer ( fhicl::ParameterSet const &  ps)

Definition at line 15 of file AdcChannelTrimmer_tool.cc.

16 : m_LogLevel(ps.get<int>("LogLevel")),
17  m_Length(ps.get<Index>("Length")),
18  m_MaxTrim(ps.get<Index>("MaxTrim")) {
19  const string myname = "AdcChannelTrimmer::ctor: ";
20  // Display the configuration.
21  if ( m_LogLevel >= 1 ) {
22  cout << myname << "Configuration: " << endl;
23  cout << myname << " LogLevel: " << m_LogLevel << endl;
24  cout << myname << " Length: " << m_Length << endl;
25  cout << myname << " MaxTrim: " << m_MaxTrim << endl;
26  }
27 }
unsigned int Index
static constexpr double ps
Definition: Units.h:99
QTextStream & endl(QTextStream &s)
AdcChannelTrimmer::~AdcChannelTrimmer ( )
overridedefault

Member Function Documentation

DataMap AdcChannelTrimmer::update ( AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 63 of file AdcChannelTrimmer_tool.cc.

63  {
64  const string myname = "AdcChannelTrimmer::update: ";
65  DataMap ret = view(acd);
66  int action = ret.getInt("trimAction");
67  if ( action != -1 ) return ret;
68  Index nsam = acd.samples.size();
69  acd.samples.resize(m_Length);
70  Index jsam = 0;
71  for ( Index isam=nsam; isam<m_Length; ++isam ) {
72  acd.samples[isam] = acd.samples[jsam++];
73  }
74  ret.setInt("trimAction", 1);
75  return ret;
76 }
unsigned int Index
void setInt(Name name, int val)
Definition: DataMap.h:131
int getInt(Name name, int def=0) const
Definition: DataMap.h:218
DataMap view(const AdcChannelData &acd) const override
AdcSignalVector samples
DataMap AdcChannelTrimmer::view ( const AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 31 of file AdcChannelTrimmer_tool.cc.

31  {
32  const string myname = "AdcChannelTrimmer::view: ";
33  DataMap ret;
34  Index nsam = acd.samples.size();
35  if ( nsam == m_Length ) {
36  ret.setInt("trimAction", 0);
37  if ( m_LogLevel >= 3 ) cout << "Samples have requested length of "
38  << m_Length << "." << endl;
39  return ret;
40  }
41  if ( nsam == 0 ) {
42  ret.setInt("trimAction", 3);
43  if ( m_LogLevel >= 3 ) cout << "WARNING: No samples found." << endl;
44  return ret;
45  }
46  int idsam = nsam < m_Length ? -int(m_Length - nsam) : int(nsam - m_Length);
47  Index udsam = idsam < 0 ? -idsam : idsam;
48  ret.setInt("trimLength", idsam);
49  if ( m_MaxTrim && udsam > m_MaxTrim ) {
50  ret.setInt("trimAction", 2);
51  cout << myname << "ERROR: Channel " << acd.channel() << " sample length " << nsam
52  << " is outside of trim range " << m_MaxTrim << "." << endl;
53  } else {
54  ret.setInt("trimAction", -1);
55  if ( m_LogLevel >= 2 ) cout << myname << "Trimming channel " << acd.channel() << " from "
56  << nsam << " to " << m_Length << " samples." << endl;
57  }
58  return ret;
59 }
unsigned int Index
void setInt(Name name, int val)
Definition: DataMap.h:131
Channel channel() const
AdcSignalVector samples
QTextStream & endl(QTextStream &s)

Member Data Documentation

Index AdcChannelTrimmer::m_Length
private

Definition at line 57 of file AdcChannelTrimmer.h.

int AdcChannelTrimmer::m_LogLevel
private

Definition at line 56 of file AdcChannelTrimmer.h.

Index AdcChannelTrimmer::m_MaxTrim
private

Definition at line 58 of file AdcChannelTrimmer.h.


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