FclIndexVectorMapTool_tool.cc
Go to the documentation of this file.
1 // FclIndexVectorMapTool_tool.cc
2 
6 #include <iostream>
7 #include <iomanip>
8 
9 using std::cout;
10 using std::endl;
11 using std::string;
12 using std::setw;
13 using Name = std::string;
14 
15 //**********************************************************************
16 
18 : m_LogLevel(ps.get<Index>("LogLevel")),
19  m_Entries(ps.get<IndexVectorVector>("Entries")) {
20  const Name myname = "FclIndexVectorMapTool::ctor: ";
21  for ( const IndexVector ent : m_Entries ) {
22  if ( ent.size() == 0 ) continue;
23  Index ient = ent.front();
24  IndexVector& vals = m_entryMap[ient];
25  vals.insert(vals.end(), ++ent.begin(), ent.end());
26  }
27  Index vecCount = m_entryMap.size();
28  Index valCount = 0;
29  for ( const IndexVectorMap::value_type& ent : m_entryMap ) valCount += ent.second.size();
30  if ( m_LogLevel >= 1 ) {
31  cout << myname << " LogLevel: " << m_LogLevel << endl;
32  cout << myname << " Entries: " << vecCount << " vectors with "
33  << valCount << " values";
34  if ( m_LogLevel > 1 ) {
35  cout << ":" << endl;
36  for ( const IndexVectorMap::value_type& ent : m_entryMap ) {
37  cout << myname << " " << ent.first << ": [";
38  bool first = true;
39  for ( Index val : ent.second ) {
40  if ( first ) first = false;
41  else cout << ", ";
42  cout << val;
43  }
44  cout << "]" << endl;
45  }
46  } else {
47  cout << "." << endl;
48  }
49  }
50 }
51 
52 //**********************************************************************
53 
55  const Name myname = "FclIndexVectorMapTool::get: ";
57  static const IndexVector empty;
58  if ( ient == m_entryMap.end() ) return empty;
59  return ient->second;
60 }
61 
62 //**********************************************************************
63 
std::vector< Index > IndexVector
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
std::string string
Definition: nybbler.cc:12
FclIndexVectorMapTool(fhicl::ParameterSet const &ps)
ChannelGroupService::Name Name
intermediate_table::const_iterator const_iterator
IndexVectorMapTool::Index Index
std::vector< Index > IndexVector
static constexpr double ps
Definition: Units.h:99
IndexVector get(Index ient) const override
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
IndexVectorVector m_Entries
std::vector< IndexVector > IndexVectorVector
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
QTextStream & endl(QTextStream &s)