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

#include <ApaChannelGroups.h>

Inheritance diagram for ApaChannelGroups:
IndexRangeGroupTool

Public Types

using Name = std::string
 
using NameVector = std::vector< Name >
 
using Index = IndexRangeGroup::Index
 
using IndexVector = std::vector< Index >
 
using GroupMap = std::map< Name, NameVector >
 
- Public Types inherited from IndexRangeGroupTool
using Name = IndexRangeGroup::Name
 

Public Member Functions

 ApaChannelGroups (fhicl::ParameterSet const &ps)
 
 ~ApaChannelGroups () override=default
 
IndexRangeGroup get (Name nam) const override
 
- Public Member Functions inherited from IndexRangeGroupTool
virtual ~IndexRangeGroupTool ()=default
 

Private Attributes

Index m_LogLevel
 
IndexVector m_ApaNumbers
 
Name m_IndexRangeTool
 
const IndexRangeToolm_pIndexRangeTool =nullptr
 
GroupMap m_groups
 
GroupMap m_labels
 

Detailed Description

Definition at line 47 of file ApaChannelGroups.h.

Member Typedef Documentation

Definition at line 55 of file ApaChannelGroups.h.

Definition at line 53 of file ApaChannelGroups.h.

Definition at line 54 of file ApaChannelGroups.h.

Definition at line 51 of file ApaChannelGroups.h.

Definition at line 52 of file ApaChannelGroups.h.

Constructor & Destructor Documentation

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

Definition at line 24 of file ApaChannelGroups_tool.cc.

25 : m_LogLevel(ps.get<Index>("LogLevel")),
26  m_ApaNumbers(ps.get<IndexVector>("ApaNumbers")),
27  m_IndexRangeTool(ps.get<Name>("IndexRangeTool")) {
28  const Name myname = "ApaChannelGroups::ctor: ";
29  if ( m_IndexRangeTool.size() ) {
32  if ( m_pIndexRangeTool == nullptr ) {
33  cout << myname << "WARNING: Index range tool not found: " << m_IndexRangeTool << endl;
34  }
35  } else {
36  cout << myname << "WARNING: No Index range tool name." << endl;
37  }
38  Index napa = m_ApaNumbers.size();
39  // If the APA list is empty, the detector has one unnumbered APA.
40  bool singleApa = napa == 0;
41  if ( singleApa ) {
42  napa = 1;
43  }
44  m_labels["tpss"].push_back("TPC sets");
45  m_labels["apas"].push_back("APAs");
46  NameVector soris = {"z", "c", "x", "u", "v", "i", "z1", "z2"};
47  for ( Name sori : soris ) {
48  m_labels["tpp" + sori + "s"].push_back(sori + " planes");
49  m_labels["apa" + sori + "s"].push_back(sori + " planes");
50  }
51  for ( Index itps=0; itps<napa; ++itps ) {
52  ostringstream sstps;
53  Name stps;
54  Name sapa;
55  if ( ! singleApa ) {
56  sstps << itps;
57  stps = sstps.str();
58  Index iapa = m_ApaNumbers[itps];
59  ostringstream ssapa;
60  ssapa << iapa;
61  sapa = ssapa.str();
62  }
63  m_groups["tpss"].push_back("tps" + stps);
64  m_groups["apas"].push_back("apa" + sapa);
65  for ( Name sori : soris ) {
66  m_groups["tpp" + sori + "s"].push_back("tpp" + stps + sori);
67  m_groups["apa" + sori + "s"].push_back("apa" + sapa + sori);
68  }
69  }
70  Index nfmb = 20;
71  for ( Index itps=0; itps<napa; ++itps ) {
72  Name sapa;
73  if ( ! singleApa ) {
74  Index iapa = m_ApaNumbers[itps];
75  ostringstream ssapa;
76  ssapa << iapa;
77  sapa = ssapa.str();
78  }
79  for ( Index ifmb=1; ifmb<=nfmb; ++ifmb ) {
80  ostringstream ssgrp;
81  ssgrp << "femb" << sapa;
82  if ( ifmb < 10 ) ssgrp << "0";
83  ssgrp << ifmb;
84  Name sgrp = ssgrp.str();
85  m_groups[sgrp].push_back(sgrp + "u");
86  m_groups[sgrp].push_back(sgrp + "v");
87  m_groups[sgrp].push_back(sgrp + "x");
88  Name slab = "FEMB " + sgrp.substr(4);
89  m_labels[sgrp].push_back(slab);
90  }
91  }
92  if ( m_LogLevel >= 1 ) {
93  cout << myname << " LogLevel: " << m_LogLevel << endl;
94  }
95 }
const IndexRangeTool * m_pIndexRangeTool
std::vector< Index > IndexVector
ChannelGroupService::Name Name
unsigned int Index
IndexVector m_ApaNumbers
static constexpr double ps
Definition: Units.h:99
std::vector< string > NameVector
static DuneToolManager * instance(std::string fclname="", int dbg=1)
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)
ApaChannelGroups::~ApaChannelGroups ( )
overridedefault

Member Function Documentation

IndexRangeGroup ApaChannelGroups::get ( Name  nam) const
overridevirtual

Implements IndexRangeGroupTool.

Definition at line 99 of file ApaChannelGroups_tool.cc.

99  {
100  const Name myname = "ApaChannelGroups::get: ";
101  if ( nam == "list" ) {
102  IndexVector grps;
103  cout << myname << "Available groups: ";
104  bool first = true;
105  for ( const auto& igrp : m_groups ) {
106  if ( first ) first = false;
107  else cout << ", ";
108  cout << igrp.first;
109  }
110  cout << endl;
111  return IndexRangeGroup();
112  }
113  if ( m_pIndexRangeTool == nullptr ) {
114  if ( m_LogLevel >= 2 ) cout << myname << "No IndexRangeTool." << endl;
115  return IndexRangeGroup();
116  }
117  GroupMap::const_iterator igrp = m_groups.find(nam);
118  if ( igrp == m_groups.end() ) {
119  if ( m_LogLevel >= 2 ) cout << myname << "Invalid group name: " << nam << endl;
120  return IndexRangeGroup();
121  }
123  for ( Name rnam : igrp->second ) {
124  rans.push_back(m_pIndexRangeTool->get(rnam));
125  }
126  NameVector labs;
127  GroupMap::const_iterator ilabs = m_labels.find(nam);
128  if ( ilabs == m_labels.end() ) return IndexRangeGroup(nam, rans);
129  return IndexRangeGroup(nam, ilabs->second, rans);
130 }
const IndexRangeTool * m_pIndexRangeTool
std::vector< Index > IndexVector
std::vector< IndexRange > RangeVector
ChannelGroupService::Name Name
intermediate_table::const_iterator const_iterator
std::vector< string > NameVector
QTextStream & endl(QTextStream &s)
virtual IndexRange get(Name nam) const =0

Member Data Documentation

IndexVector ApaChannelGroups::m_ApaNumbers
private

Definition at line 70 of file ApaChannelGroups.h.

GroupMap ApaChannelGroups::m_groups
private

Definition at line 75 of file ApaChannelGroups.h.

Name ApaChannelGroups::m_IndexRangeTool
private

Definition at line 71 of file ApaChannelGroups.h.

GroupMap ApaChannelGroups::m_labels
private

Definition at line 76 of file ApaChannelGroups.h.

Index ApaChannelGroups::m_LogLevel
private

Definition at line 69 of file ApaChannelGroups.h.

const IndexRangeTool* ApaChannelGroups::m_pIndexRangeTool =nullptr
private

Definition at line 74 of file ApaChannelGroups.h.


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