ProtoDuneChannelGroups_tool.cc
Go to the documentation of this file.
1 // ProtoDuneChannelGroups_tool.cc
2 
6 #include <iostream>
7 #include <sstream>
8 #include <iomanip>
9 
10 using std::cout;
11 using std::endl;
12 using std::string;
13 using std::ostringstream;
14 using std::istringstream;
15 using std::setw;
16 using std::setfill;
18 using NameVector = std::vector<Name>;
20 using IndexVector = std::vector<Index>;
21 
22 //**********************************************************************
23 
25 : m_LogLevel(ps.get<Index>("LogLevel")),
26  m_IndexRangeTool(ps.get<Name>("IndexRangeTool")) {
27  const Name myname = "ProtoDuneChannelGroups::ctor: ";
28  if ( m_IndexRangeTool.size() ) {
31  if ( m_pIndexRangeTool == nullptr ) {
32  cout << myname << "WARNING: Index range tool not found: " << m_IndexRangeTool << endl;
33  }
34  } else {
35  cout << myname << "WARNING: No Index range tool name." << endl;
36  }
37  Index napa = 6;
38  m_labels["tpss"].push_back("TPC sets");
39  m_labels["apas"].push_back("APAs");
40  NameVector soris = {"z", "c", "x", "u", "v", "i"};
41  for ( Name sori : soris ) {
42  m_labels["tpp" + sori + "s"].push_back(sori + " planes");
43  m_labels["apa" + sori + "s"].push_back(sori + " planes");
44  }
45  for ( Index itps=0; itps<napa; ++itps ) {
46  ostringstream sstps;
47  sstps << itps;
48  Name stps = sstps.str();
49  Index iapa = itps + 1;
50  ostringstream ssapa;
51  ssapa << iapa;
52  Name sapa = ssapa.str();
53  m_groups["tpss"].push_back("tps" + stps);
54  m_groups["apas"].push_back("apa" + sapa);
55  for ( Name sori : soris ) {
56  m_groups["tpp" + sori + "s"].push_back("tpp" + stps + sori);
57  m_groups["apa" + sori + "s"].push_back("apa" + sapa + sori);
58  }
59  }
60  Index nfmb = 20;
61  for ( Index iapa=1; iapa<=napa; ++iapa ) {
62  for ( Index ifmb=1; ifmb<=nfmb; ++ifmb ) {
63  ostringstream ssgrp;
64  ssgrp << "femb" << iapa;
65  if ( ifmb < 10 ) ssgrp << "0";
66  ssgrp << ifmb;
67  Name sgrp = ssgrp.str();
68  m_groups[sgrp].push_back(sgrp + "u");
69  m_groups[sgrp].push_back(sgrp + "v");
70  m_groups[sgrp].push_back(sgrp + "x");
71  Name slab = "FEMB " + sgrp.substr(4);
72  m_labels[sgrp].push_back(slab);
73  }
74  }
75  if ( m_LogLevel >= 1 ) {
76  cout << myname << " LogLevel: " << m_LogLevel << endl;
77  }
78 }
79 
80 //**********************************************************************
81 
83  const Name myname = "ProtoDuneChannelGroups::get: ";
84  if ( m_pIndexRangeTool == nullptr ) {
85  if ( m_LogLevel >= 2 ) cout << myname << "No IndexRangeTool." << endl;
86  return IndexRangeGroup();
87  }
88  GroupMap::const_iterator igrp = m_groups.find(nam);
89  if ( igrp == m_groups.end() ) {
90  if ( m_LogLevel >= 2 ) cout << myname << "Invalid group name: " << nam << endl;
91  return IndexRangeGroup();
92  }
94  for ( Name rnam : igrp->second ) {
95  rans.push_back(m_pIndexRangeTool->get(rnam));
96  }
97  NameVector labs;
98  GroupMap::const_iterator ilabs = m_labels.find(nam);
99  if ( ilabs == m_labels.end() ) return IndexRangeGroup(nam, rans);
100  return IndexRangeGroup(nam, ilabs->second, rans);
101 }
102 
103 //**********************************************************************
104 
std::vector< Name > NameVector
std::vector< Index > IndexVector
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
IndexRangeGroup get(Name nam) const override
std::string string
Definition: nybbler.cc:12
std::vector< IndexRange > RangeVector
ChannelGroupService::Name Name
intermediate_table::const_iterator const_iterator
unsigned int Index
static constexpr double ps
Definition: Units.h:99
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
IndexRangeGroup::Index Index
const IndexRangeTool * m_pIndexRangeTool
ProtoDuneChannelGroups(fhicl::ParameterSet const &ps)
std::vector< string > NameVector
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337
IndexRangeGroup::Name Name
static DuneToolManager * instance(std::string fclname="", int dbg=1)
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)
virtual IndexRange get(Name nam) const =0