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

#include <AdcRangeSampleScaler.h>

Inheritance diagram for AdcRangeSampleScaler:
TpcDataTool

Public Member Functions

 AdcRangeSampleScaler (fhicl::ParameterSet const &ps)
 
 ~AdcRangeSampleScaler () override=default
 
DataMap update (AdcChannelData &acd) const override
 

Private Types

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 
using FloatVector = std::vector< float >
 
- Private Types inherited from AdcChannelTool
using Index = unsigned int
 

Private Attributes

int m_LogLevel
 
IndexVector m_RangeLimits
 
Index m_RangeModulus
 
FloatVector m_ScaleFactors
 

Additional Inherited Members

- Private Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Private Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap view (const AdcChannelData &acd) const
 
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)
 
- Static Private Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 24 of file AdcRangeSampleScaler.h.

Member Typedef Documentation

Definition at line 38 of file AdcRangeSampleScaler.h.

using AdcRangeSampleScaler::Index = unsigned int
private

Definition at line 36 of file AdcRangeSampleScaler.h.

Definition at line 37 of file AdcRangeSampleScaler.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file AdcRangeSampleScaler_tool.cc.

17 : m_LogLevel(ps.get<int>("LogLevel")),
18  m_RangeLimits(ps.get<IndexVector>("RangeLimits")),
19  m_RangeModulus(ps.get<Index>("RangeModulus")),
20  m_ScaleFactors(ps.get<FloatVector>("ScaleFactors")) {
21  const string myname = "AdcRangeSampleScaler::ctor: ";
22  if ( m_LogLevel >= 1 ) {
23  cout << myname << "Parameters:" << endl;
24  cout << myname << " LogLevel: " << m_LogLevel << endl;
25  Index imin = 0;
26  cout << myname << " Modulus: " << m_RangeModulus << endl;
27  cout << myname << " Range: Scale: " << endl;
28  Index imod = m_RangeModulus;
29  for ( Index iran=0; ; ++iran ) {
30  // No more ranges.
31  // Unless protected with a modulus, we need one more scale factor.
32  Index imax = 0;
33  bool haveMax = true;
34  if ( iran >= m_RangeLimits.size() ) {
35  if ( imod && imin >= imod ) {
36  break;
37  }
38  haveMax = false;
39  } else {
40  imax = m_RangeLimits[iran];
41  if ( imod > 0 && imax >= imod ) {
42  cout << myname << "WARNING: Index exceeds modulus: " << imax << " >= " << imod << endl;
43  break;
44  }
45  }
46  if ( m_ScaleFactors.size() < iran + 1 ) {
47  cout << myname << "ERROR: Too few scale factors." << endl;
48  break;
49  }
50  float sfac = m_ScaleFactors[iran];
51  cout << myname << " [" << imin << ", ";
52  if ( haveMax ) cout << imax;
53  else cout << "...";
54  cout << "): " << sfac << endl;
55  if ( haveMax ) imin = imax;
56  else break;
57  }
58 
59  }
60 }
std::vector< Index > IndexVector
unsigned int Index
static constexpr double ps
Definition: Units.h:99
int imax
Definition: tracks.py:195
Dft::FloatVector FloatVector
QTextStream & endl(QTextStream &s)
AdcRangeSampleScaler::~AdcRangeSampleScaler ( )
overridedefault

Member Function Documentation

DataMap AdcRangeSampleScaler::update ( AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 64 of file AdcRangeSampleScaler_tool.cc.

64  {
65  const string myname = "AdcRangeSampleScaler::update: ";
66  if ( m_LogLevel >= 2 ) cout << "Processing run " << acd.run() << " event " << acd.event()
67  << " channel " << acd.channel() << endl;
68  DataMap ret;
69 
70  // Find the index for the scale factor.
71  if ( acd.channel() == AdcChannelData::badIndex() ) {
72  cout << myname << "ERROR: Invalid channel." << endl;
73  return ret.setStatus(1);
74  }
75  Index icha = acd.channel();
76  Index ichaMod = m_RangeModulus ? icha%m_RangeModulus : icha;
77  Index iran = 0;
78  for ( iran=0; iran<m_RangeLimits.size(); ++iran ) {
79  Index imax = m_RangeLimits[iran];
80  if ( ichaMod < imax ) {
81  break;
82  }
83  }
84 
85  if ( iran >= m_ScaleFactors.size() ) {
86  cout << myname << "ERROR: No scale factor for channel " << icha;
87  if ( ichaMod != icha ) cout << " (" << ichaMod << ")";
88  cout << endl;
89  return ret.setStatus(2);
90  }
91  float sfac = m_ScaleFactors[iran];
92 
93  // Scale samples.
94  for ( float& sam : acd.samples ) sam *= sfac;
95 
96  ret.setFloat("arssScaleFactor", sfac);
97 
98  return ret;
99 }
void setFloat(Name name, float val)
Definition: DataMap.h:133
DataMap & setStatus(int stat)
Definition: DataMap.h:130
unsigned int Index
AdcIndex run() const
AdcIndex event() const
Channel channel() const
int imax
Definition: tracks.py:195
static Index badIndex()
AdcSignalVector samples
QTextStream & endl(QTextStream &s)

Member Data Documentation

int AdcRangeSampleScaler::m_LogLevel
private

Definition at line 41 of file AdcRangeSampleScaler.h.

IndexVector AdcRangeSampleScaler::m_RangeLimits
private

Definition at line 42 of file AdcRangeSampleScaler.h.

Index AdcRangeSampleScaler::m_RangeModulus
private

Definition at line 43 of file AdcRangeSampleScaler.h.

FloatVector AdcRangeSampleScaler::m_ScaleFactors
private

Definition at line 44 of file AdcRangeSampleScaler.h.


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