FclIndexRangeTool_tool.cc
Go to the documentation of this file.
1 // FclIndexRangeTool_tool.cc
2 
3 #include "FclIndexRangeTool.h"
6 #include <iostream>
7 #include <iomanip>
8 
9 using std::cout;
10 using std::endl;
11 using std::string;
12 using std::setw;
14 
15 //**********************************************************************
16 
18 : m_LogLevel(ps.get<Index>("LogLevel")) {
19  const Name myname = "FclIndexRangeTool::ctor: ";
20  Index namSize = 0;
21  Index labSize = 0;
22  for ( string rnam : ps.get_pset_names() ) {
23  if ( rnam == "LogLevel" ) continue;
24  cout << myname << " " << rnam << endl;
26  if ( m_Ranges.find(rnam) != m_Ranges.end() ) {
27  cout << myname << "Overwriting duplicate range: " << rnam << endl;
28  }
29  IndexRange& ran = m_Ranges[rnam];
30  ran.name = rnam;
31  ran.labels = psr.get<NameVector>("labels");
32  ran.begin = psr.get<Index>("begin");
33  ran.end = psr.get<Index>("end");
34  if ( ran.name.size() > namSize ) namSize = ran.name.size();
35  if ( ran.label().size() > labSize ) labSize = ran.label().size();
36  }
37  if ( m_LogLevel >= 1 ) {
38  cout << myname << " LogLevel: " << m_LogLevel << endl;
39  cout << myname << " Range count: " << m_Ranges.size() << endl;
40  if ( m_LogLevel >= 2 ) {
41  for ( IndexRangeMap::value_type iran : m_Ranges ) {
42  const IndexRange& ran = iran.second;
43  cout << myname << setw(namSize+2) << ran.name
44  << setw(6) << ran.begin
45  << setw(6) << ran.end
46  << setw(labSize+1) << ran.label() << endl;
47  }
48  }
49  }
50 }
51 
52 //**********************************************************************
53 
55  const Name myname = "FclIndexRangeTool::runData: ";
56  IndexRangeMap::const_iterator iran = m_Ranges.find(nam);
57  if ( iran == m_Ranges.end() ) return IndexRange();
58  return iran->second;
59 }
60 
61 //**********************************************************************
62 
IndexRange get(Name nam) const override
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
NameVector labels
Definition: IndexRange.h:33
std::string string
Definition: nybbler.cc:12
Index begin
Definition: IndexRange.h:34
intermediate_table::const_iterator const_iterator
Index end
Definition: IndexRange.h:35
Name name
Definition: IndexRange.h:32
std::vector< Name > NameVector
Definition: IndexRange.h:29
std::vector< std::string > get_pset_names() const
FclIndexRangeTool(fhicl::ParameterSet const &ps)
T get(std::string const &key) const
Definition: ParameterSet.h:271
IndexRange::Name Name
static constexpr double ps
Definition: Units.h:99
Name label(Index ilab=0) const
Definition: IndexRange.h:106
IndexRangeMap m_Ranges
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::vector< string > NameVector
IndexRange::Index Index
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
QTextStream & endl(QTextStream &s)