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

#include <ApaChannelRanges.h>

Inheritance diagram for ApaChannelRanges:
IndexRangeTool

Public Types

using Name = std::string
 
using NameVector = std::vector< Name >
 
using Index = IndexRange::Index
 
using IndexVector = std::vector< Index >
 
using IndexRangeMap = std::map< Name, IndexRange >
 
- Public Types inherited from IndexRangeTool
using Name = IndexRange::Name
 

Public Member Functions

 ApaChannelRanges (fhicl::ParameterSet const &ps)
 
 ~ApaChannelRanges () override=default
 
IndexRange get (Name nam) const override
 
- Public Member Functions inherited from IndexRangeTool
virtual ~IndexRangeTool ()=default
 

Private Member Functions

void insertLen (Name nam, Index begin, Index len, Name lab, Name lab1="", Name lab2="")
 

Private Attributes

Index m_LogLevel
 
IndexVector m_ApaNumbers
 
NameVector m_ApaLocationNames
 
Name m_ExtraRanges
 
IndexRangeMap m_Ranges
 
const IndexRangeToolm_pExtraRanges =nullptr
 

Detailed Description

Definition at line 44 of file ApaChannelRanges.h.

Member Typedef Documentation

Definition at line 50 of file ApaChannelRanges.h.

Definition at line 52 of file ApaChannelRanges.h.

Definition at line 51 of file ApaChannelRanges.h.

Definition at line 48 of file ApaChannelRanges.h.

Definition at line 49 of file ApaChannelRanges.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file ApaChannelRanges_tool.cc.

23 : m_LogLevel(ps.get<Index>("LogLevel")),
24  m_ApaNumbers(ps.get<IndexVector>("ApaNumbers")),
25  m_ApaLocationNames(ps.get<NameVector>("ApaLocationNames")),
26  m_ExtraRanges(ps.get<Name>("ExtraRanges")) {
27  const Name myname = "ApaChannelRanges::ctor: ";
28  const Index ntps = m_ApaNumbers.size();;
29  Index nchaApa = 2560;
30  Index nfchau = 40;
31  Index nfchav = 40;
32  Index nfchax = 48;
33  Index nchau = 800;
34  Index nchav = 800;
35  Index nchaz = 480;
36  Index nchax = 2*nchaz;
37  Index nchai = nchau + nchav;
38  //Index apaIdx[ntps] = {3, 5, 2, 6, 1, 4}; // Installation order.
39  const IndexVector& apaIdx = m_ApaNumbers;
40  //string slocs[ntps] = {"US-RaS", "US-DaS", "MS-RaS", "MS-DaS", "DS-RaS", "DS-DaS"};
42  while ( slocs.size() < ntps ) slocs.push_back("");
43  insertLen("all", 0, ntps*nchaApa, "All", "", "");
44  for ( Index itps=0; itps<ntps; ++itps ) {
45  string sitps = std::to_string(itps);
46  string siapa = std::to_string(apaIdx[itps]);
47  string labTps = "TPC set " + sitps;
48  string labApa = "APA " + siapa;
49  string sloc = slocs[itps];
50  Index ch0 = itps*nchaApa;
51  string stps = "tps" + sitps;
52  string sapa = "apa" + siapa;
53  insertLen( stps, ch0, nchaApa, labTps, sloc, labApa);
54  insertLen( sapa, ch0, nchaApa, labApa, sloc);
55  string stpp = "tpp" + sitps;
56  Index chu0 = ch0;
57  Index chv0 = chu0 + nchau;
58  Index chx10 = chv0 + nchav;
59  Index chx20 = chx10 + nchaz;
60  Index chx0 = chx10;
61  bool beamRight = 2*(itps/2) == itps;
62  Index chz0 = beamRight ? chx20 : chx10;
63  Index chc0 = beamRight ? chx10 : chx20;
64  insertLen(stpp + "u", chu0, nchau, "TPC plane " + sitps + "u", sloc, labApa);
65  insertLen(sapa + "u", chu0, nchau, "APA plane " + siapa + "u", sloc);
66  insertLen(stpp + "v", chv0, nchav, "TPC plane " + sitps + "v", sloc, labApa);
67  insertLen(sapa + "v", chv0, nchav, "APA plane " + siapa + "v", sloc);
68  insertLen(stpp + "c", chc0, nchaz, "TPC plane " + sitps + "c", sloc, labApa);
69  insertLen(sapa + "c", chc0, nchaz, "APA plane " + siapa + "c", sloc);
70  insertLen(stpp + "z", chz0, nchaz, "TPC plane " + sitps + "z", sloc, labApa);
71  insertLen(sapa + "z", chz0, nchaz, "APA plane " + siapa + "z", sloc);
72  insertLen(stpp + "i", chu0, nchai, "TPC plane " + sitps + "i", sloc, labApa);
73  insertLen(sapa + "i", chu0, nchai, "APA plane " + siapa + "i", sloc);
74  insertLen(stpp + "x", chx0, nchax, "TPC plane " + sitps + "x", sloc, labApa);
75  insertLen(sapa + "x", chx0, nchax, "APA plane " + siapa + "x", sloc);
76  Index fchu0 = chu0;
77  Index fchv0 = chv0;
78  Index fchx0 = chx10;
79  Index ifmbu = 11;
80  Index ifmbv = 20;
81  Index ifmbx = 20;
82  // Loop over FEMBS in offline order.
83  for ( Index ifmbOff=0; ifmbOff<20; ++ifmbOff ) {
84  ostringstream ssnamu;
85  ssnamu << siapa << setfill('0') << setw(2) << ifmbu << "u";
86  string namu = ssnamu.str();
87  insertLen("femb" + namu, fchu0, nfchau, "FEMB block " + namu, sloc);
88  ostringstream ssnamv;
89  ssnamv << siapa << setfill('0') << setw(2) << ifmbv << "v";
90  string namv = ssnamv.str();
91  insertLen("femb" + namv, fchv0, nfchav, "FEMB block " + namv, sloc);
92  ostringstream ssnamx;
93  ssnamx << siapa << setfill('0') << setw(2) << ifmbx << "x";
94  string namx = ssnamx.str();
95  insertLen("femb" + namx, fchx0, nfchax, "FEMB block " + namx, sloc);
96  fchu0 += nfchau;
97  fchv0 += nfchav;
98  fchx0 += nfchax;
99  ifmbu += 1;
100  if ( ifmbu > 20 ) ifmbu = 1;
101  ifmbv -= 1;
102  if ( ifmbv == 0 ) ifmbv = 20;
103  if ( ifmbOff < 9 ) ifmbx -= 1;
104  else if ( ifmbOff == 9 ) ifmbx = 1;
105  else ifmbx += 1;
106 
107  }
108  }
109  if ( m_ExtraRanges.size() ) {
112  if ( m_pExtraRanges == nullptr ) {
113  cout << myname << "WARNING: Extra range tool not found: " << m_ExtraRanges << endl;
114  }
115  }
116  if ( m_LogLevel >= 1 ) {
117  cout << myname << " LogLevel: " << m_LogLevel << endl;
118  cout << myname << " Extra range tool: " << m_ExtraRanges << endl;
119  }
120 }
std::vector< Index > IndexVector
const IndexRangeTool * m_pExtraRanges
ChannelGroupService::Name Name
unsigned int Index
NameVector m_ApaLocationNames
static constexpr double ps
Definition: Units.h:99
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::vector< string > NameVector
IndexVector m_ApaNumbers
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static DuneToolManager * instance(std::string fclname="", int dbg=1)
void insertLen(Name nam, Index begin, Index len, Name lab, Name lab1="", Name lab2="")
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)
ApaChannelRanges::~ApaChannelRanges ( )
overridedefault

Member Function Documentation

IndexRange ApaChannelRanges::get ( Name  nam) const
overridevirtual

Implements IndexRangeTool.

Definition at line 124 of file ApaChannelRanges_tool.cc.

124  {
125  const Name myname = "ApaChannelRanges::runData: ";
126  if ( m_pExtraRanges != nullptr ) {
127  IndexRange rout = m_pExtraRanges->get(nam);
128  if ( rout.isValid() ) return rout;
129  }
130  // Special handling for online wire specifier fembAFFVCC
131  // We look up FEMB block fembAFFV and pick the channel corresponding to CC,
132  if ( nam.size() == 10 && nam.substr(0,4) == "femb" ) {
133  IndexRange fbran = get(nam.substr(0,8));
134  Index ifchmax = 0;
135  if ( fbran.isValid() ) {
136  char cpla = nam[7];
137  bool dirSame = true; // Is channel numbering dir same in FEMB and offline?
138  if ( cpla == 'u' ) {
139  ifchmax = 40;
140  dirSame = false;
141  } else if ( cpla == 'v' ) {
142  ifchmax = 40;
143  } else if ( cpla == 'x' || cpla == 'w') {
144  ifchmax = 48;
145  istringstream ssapa(nam.substr(4,1));
146  int iapa = 0;
147  ssapa >> iapa;
148  istringstream ssfmb(nam.substr(5,2));
149  int ifmb = 0;
150  ssfmb >> ifmb;
151  bool beamL = ifmb >= 1 && ifmb <= 10;
152  bool beamR = ifmb >= 11 && ifmb <= 20;
153  if ( beamL ) dirSame = false;
154  else if ( beamR ) dirSame = true;
155  else ifchmax = 0;
156  }
157  if ( ifchmax != fbran.size() ) {
158  cout << myname << "WARNING: FEMB block has unexpected size: "
159  << ifchmax << " != " << fbran.size() << endl;
160  ifchmax = 0;
161  }
162  string sch = nam.substr(8,2);
163  istringstream ssfch(sch);
164  Index ifch;
165  ssfch >> ifch;
166  if ( ifch > 0 && ifch <= ifchmax ) {
167  if ( dirSame ) --ifch;
168  else ifch = ifchmax - ifch;
169  Index ich = fbran.begin + ifch;
170  return IndexRange(nam, ich, ich+1, fbran.label(0) + sch, fbran.label(1));
171  }
172  }
173  }
174  IndexRangeMap::const_iterator iran = m_Ranges.find(nam);
175  if ( iran == m_Ranges.end() ) return IndexRange();
176  return iran->second;
177 }
Index begin
Definition: IndexRange.h:34
const IndexRangeTool * m_pExtraRanges
ChannelGroupService::Name Name
Index size() const
Definition: IndexRange.h:88
intermediate_table::const_iterator const_iterator
unsigned int Index
bool isValid() const
Definition: IndexRange.h:94
Name label(Index ilab=0) const
Definition: IndexRange.h:106
IndexRangeMap m_Ranges
QTextStream & endl(QTextStream &s)
virtual IndexRange get(Name nam) const =0
void ApaChannelRanges::insertLen ( Name  nam,
Index  begin,
Index  len,
Name  lab,
Name  lab1 = "",
Name  lab2 = "" 
)
private

Definition at line 182 of file ApaChannelRanges_tool.cc.

182  {
183  m_Ranges[nam] = IndexRange(nam, begin, begin+len, lab, lab1, lab2);
184 }
IndexRangeMap m_Ranges
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72

Member Data Documentation

NameVector ApaChannelRanges::m_ApaLocationNames
private

Definition at line 68 of file ApaChannelRanges.h.

IndexVector ApaChannelRanges::m_ApaNumbers
private

Definition at line 67 of file ApaChannelRanges.h.

Name ApaChannelRanges::m_ExtraRanges
private

Definition at line 69 of file ApaChannelRanges.h.

Index ApaChannelRanges::m_LogLevel
private

Definition at line 66 of file ApaChannelRanges.h.

const IndexRangeTool* ApaChannelRanges::m_pExtraRanges =nullptr
private

Definition at line 72 of file ApaChannelRanges.h.

IndexRangeMap ApaChannelRanges::m_Ranges
private

Definition at line 71 of file ApaChannelRanges.h.


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