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

#include <BlockIndexMapTool.h>

Inheritance diagram for BlockIndexMapTool:
IndexMapTool

Public Types

using Index = IndexMapTool::Index
 
- Public Types inherited from IndexMapTool
using Index = unsigned int
 

Public Member Functions

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

Private Types

using IndexVector = std::vector< Index >
 
using IndexMap = std::map< Index, Index >
 

Private Attributes

Index m_LogLevel
 
IndexVector m_Starts
 
IndexVector m_Values
 
Index m_Period
 
IndexMap m_map
 

Additional Inherited Members

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

Detailed Description

Definition at line 31 of file BlockIndexMapTool.h.

Member Typedef Documentation

Definition at line 35 of file BlockIndexMapTool.h.

using BlockIndexMapTool::IndexMap = std::map<Index, Index>
private

Definition at line 49 of file BlockIndexMapTool.h.

Definition at line 48 of file BlockIndexMapTool.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file BlockIndexMapTool_tool.cc.

18 : m_LogLevel(ps.get<Index>("LogLevel")),
19  m_Starts(ps.get<IndexVector>("Starts")),
20  m_Values(ps.get<IndexVector>("Values")),
21  m_Period(ps.get<Index>("Period")) {
22  const Name myname = "BlockIndexMapTool::ctor: ";
23  // Build teh map.
24  m_map[0] = 0;
25  for ( Index ival=0; ival<m_Starts.size(); ++ival ) {
26  Index idx = m_Starts[ival];
27  Index val = ival < m_Values.size() ? m_Values[ival] : 0;
28  m_map[idx] = val;
29  }
30  // Display the parameters.
31  if ( m_LogLevel >= 1 ) {
32  // Use largest value to set the display width for indices and values.
33  Index imax = 0;
34  for ( Index val : m_Starts ) if ( val > imax ) imax = val;
35  for ( Index val : m_Values ) if ( val > imax ) imax = val;
36  Index wid = 1;
37  Index chk = 1;
38  while ( chk < imax ) {
39  chk *=10;
40  ++wid;
41  }
42  cout << myname << " LogLevel: " << m_LogLevel << endl;
43  cout << myname << " Starts: [";
44  bool first = true;
45  for ( Index val : m_Starts ) {
46  if ( first ) first = false;
47  else cout << ", ";
48  cout << setw(wid) << val;
49  }
50  cout << "]" << endl;
51  cout << myname << " Values: [";
52  first = true;
53  for ( Index val : m_Values ) {
54  if ( first ) first = false;
55  else cout << ", ";
56  cout << setw(wid) << val;
57  }
58  cout << "]" << endl;
59  cout << myname << " Period: " << m_Period << endl;
60  }
61 }
std::vector< Index > IndexVector
ChannelGroupService::Name Name
unsigned int Index
static constexpr double ps
Definition: Units.h:99
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
int imax
Definition: tracks.py:195
QTextStream & endl(QTextStream &s)
BlockIndexMapTool::~BlockIndexMapTool ( )
overridedefault

Member Function Documentation

Index BlockIndexMapTool::get ( Index  icha) const
overridevirtual

Implements IndexMapTool.

Definition at line 65 of file BlockIndexMapTool_tool.cc.

65  {
66  const Name myname = "BlockIndexMapTool::get: ";
67  Index kcha = m_Period ? icha%m_Period : icha;
68  return (--m_map.upper_bound(kcha))->second;
69 }
ChannelGroupService::Name Name
unsigned int Index
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85

Member Data Documentation

Index BlockIndexMapTool::m_LogLevel
private

Definition at line 52 of file BlockIndexMapTool.h.

IndexMap BlockIndexMapTool::m_map
private

Definition at line 58 of file BlockIndexMapTool.h.

Index BlockIndexMapTool::m_Period
private

Definition at line 55 of file BlockIndexMapTool.h.

IndexVector BlockIndexMapTool::m_Starts
private

Definition at line 53 of file BlockIndexMapTool.h.

IndexVector BlockIndexMapTool::m_Values
private

Definition at line 54 of file BlockIndexMapTool.h.


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