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

#include <ChannelStatusConfigTool.h>

Inheritance diagram for ChannelStatusConfigTool:
IndexMapTool

Public Types

using Index = IndexMapTool::Index
 
using IndexVector = std::vector< Index >
 
using IndexVectorVector = std::vector< IndexVector >
 
- Public Types inherited from IndexMapTool
using Index = unsigned int
 

Public Member Functions

 ChannelStatusConfigTool (fhicl::ParameterSet const &ps)
 
 ~ChannelStatusConfigTool () override=default
 
Index get (Index icha) const override
 
- Public Member Functions inherited from IndexMapTool
virtual ~IndexMapTool ()=default
 

Private Attributes

Index m_LogLevel
 
Index m_DefaultIndex
 
IndexVectorVector m_IndexVectors
 
IndexVector m_vals
 

Additional Inherited Members

- Static Public Member Functions inherited from IndexMapTool
static Index badIndex ()
 

Detailed Description

Definition at line 37 of file ChannelStatusConfigTool.h.

Member Typedef Documentation

Definition at line 41 of file ChannelStatusConfigTool.h.

Definition at line 42 of file ChannelStatusConfigTool.h.

Definition at line 43 of file ChannelStatusConfigTool.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file ChannelStatusConfigTool_tool.cc.

22 : m_LogLevel(ps.get<Index>("LogLevel")),
23  m_DefaultIndex(ps.get<Index>("DefaultIndex")),
24  m_IndexVectors(ps.get<IndexVectorVector>("IndexVectors")) {
25  const Name myname = "ChannelStatusConfigTool::ctor: ";
26  if ( m_LogLevel >= 1 ) {
27  cout << myname << " LogLevel: " << m_LogLevel << endl;
28  Index nidx = m_IndexVectors.size();
29  Index nsho = 0;
30  for ( Index iidx=0; iidx<nidx; ++iidx ) {
31  const IndexVector& vals = m_IndexVectors[iidx];
32  Index nval = vals.size();
33  if ( nval == 0 ) continue;
34  if ( nsho == 0 ) {
35  cout << myname << " Index Count" << endl;
36  }
37  ++nsho;
38  cout << myname << setw(7) << iidx << setw(7) << nval << endl;
39  }
40  }
41  // Build the map.
42  Index idxSize = 0;
43  for ( const IndexVector& vec : m_IndexVectors ) {
44  for ( Index idx : vec ) {
45  if ( idx >= idxSize ) idxSize = idx + 1;
46  }
47  }
48  m_vals.resize(idxSize, m_DefaultIndex);
49  Index ivec = m_IndexVectors.size();
50  IndexVector counts(idxSize, 0);
51  while ( ivec ) {
52  const IndexVector& vec = m_IndexVectors[--ivec];
53  for ( Index idx : vec ) {
54  m_vals[idx] = ivec;
55  ++counts[idx];
56  }
57  }
58  if ( m_LogLevel == 2 ) {
59  Index ndup = 0;
60  for ( Index idx=0; idx<idxSize; ++idx ) {
61  if ( counts[idx] > 1 ) {
62  if ( ndup >= 20 ) {
63  cout << ", ...";
64  break;
65  }
66  if ( ndup == 0 ) {
67  cout << myname << "Found indices with duplicate entries: ";
68  } else {
69  cout << ", ";
70  }
71  cout << idx;
72  ++ndup;
73  }
74  }
75  if ( ndup == 0 ) {
76  cout << myname << "No duplicate entries.";
77  }
78  cout << endl;
79  }
80 }
std::vector< Index > IndexVector
std::vector< IndexVector > IndexVectorVector
ChannelGroupService::Name Name
unsigned int Index
counts_as<> counts
Number of ADC counts, represented by signed short int.
Definition: electronics.h:116
static constexpr double ps
Definition: Units.h:99
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
QTextStream & endl(QTextStream &s)
ChannelStatusConfigTool::~ChannelStatusConfigTool ( )
overridedefault

Member Function Documentation

Index ChannelStatusConfigTool::get ( Index  icha) const
overridevirtual

Implements IndexMapTool.

Definition at line 84 of file ChannelStatusConfigTool_tool.cc.

84  {
85  const Name myname = "ChannelStatusConfigTool::get: ";
86  if ( icha < m_vals.size() ) return m_vals[icha];
87  return m_DefaultIndex;
88 }
ChannelGroupService::Name Name

Member Data Documentation

Index ChannelStatusConfigTool::m_DefaultIndex
private

Definition at line 58 of file ChannelStatusConfigTool.h.

IndexVectorVector ChannelStatusConfigTool::m_IndexVectors
private

Definition at line 59 of file ChannelStatusConfigTool.h.

Index ChannelStatusConfigTool::m_LogLevel
private

Definition at line 57 of file ChannelStatusConfigTool.h.

IndexVector ChannelStatusConfigTool::m_vals
private

Definition at line 62 of file ChannelStatusConfigTool.h.


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