Functions
pdChannelRange.cxx File Reference
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "dunecore/DuneInterface/Tool/IndexRangeTool.h"
#include "dunecore/DuneInterface/Tool/IndexRangeGroupTool.h"
#include <string>
#include <iostream>
#include <vector>
#include <sstream>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file pdChannelRange.cxx.

25  {
26  const string myname = "pdChannelRange: ";
27  bool help = false;
28  string crname;
29  string tnameRange = "channelRanges";
30  string tnameGroup = "channelGroups";
31  int iarg = 1;
32  string sdet = "protodune";
33  while ( iarg < argc ) {
34  string arg = argv[iarg++];
35  if ( arg[0] == '-' ) {
36  if ( arg == "-h" ) {
37  help = true;
38  } else if ( arg == "-d" ) {
39  if ( iarg < argc ) sdet = argv[iarg++];
40  } else {
41  cout << "ERROR: Invalid flag: " << arg << endl;
42  help = true;
43  }
44  } else {
45  crname = arg;
46  }
47  }
48  string fclfile = sdet + "_tools_dune.fcl";
49  if ( help ) {
50  cout << "Usage: " << argv[0] << " [-d DET] NAME" << endl;
51  cout << " Displays the range names group for channel group NAME" << endl;
52  cout << " or the range for channel range NAME." << endl;
53  cout << " DET = protodune (default), apa7, iceberg, vdcb or any value for which\n"
54  << " DET_tools_dune.fcl provides definitions for\n"
55  << " channelRanges and channelGroups." << endl;
56  if ( sdet == "protodune" ) {
57  cout << " Protodune channel group names include:" << endl;
58  cout << " apas - APAs." << endl;
59  cout << " tpss - TPC sets." << endl;
60  cout << " apaus, apavs, apazs, apacs - APA planes with install naming." << endl;
61  cout << " tppus, tppvs, tppzs, tppcs - APA planes with offline naming." << endl;
62  cout << " Protodune channel range names include:" << endl;
63  cout << " apa1 - apa6: APA with APA numbering." << endl;
64  cout << " tps0 - tps5: APA (TPC set) with offline numbering." << endl;
65  cout << " apa0u, apa0v, apa0z, apa0c, ..., apa5c: APA plane with install numbering." << endl;
66  cout << " tpp0u, tpp0v, tpp0z, tpp0c, ..., tpp5c: APA plane with offline numbering." << endl;
67  cout << " (u and v are induction, z is TPC-side collection, c is cryostat side." << endl;
68  cout << " femb101u, femb102u, ..., femb620u: FEMB u channels (same for v and x)." << endl;
69  } else if ( sdet == "apa7" ) {
70  cout << " CERN coldbox channel range names include:" << endl;
71  cout << " apa7: same as all." << endl;
72  cout << " apa7u, apa7v, apa7z, apa7c: APA plane." << endl;
73  cout << " tpp7u, tpp7v, tpp7z, tpp07: APA plane." << endl;
74  cout << " (u and v are induction, z is TPC-side collection, c is cryostat side." << endl;
75  cout << " femb701u, femb702u, ..., femb720u: FEMB u channels (same for v and x)." << endl;
76  } else if ( sdet == "iceberg" ) {
77  cout << " Iceberg channel range names include:" << endl;
78  cout << " apa: same as all." << endl;
79  cout << " apau, apav, apaz1, apaz2: APA plane." << endl;
80  cout << " tppu, tppv, tppz1, apaz2: APA plane." << endl;
81  cout << " (u and v are induction, z is TPC-side collection, c is cryostat side." << endl;
82  cout << " femb701u, femb702u, ..., femb720u: FEMB u channels (same for v and x)." << endl;
83  cout << " apai: Induction channels." << endl;
84  cout << " apaz or apax: Collection channels." << endl;
85  }
86  return 0;
87  }
88 
89  DuneToolManager* ptm = DuneToolManager::instance(fclfile, 0);
90  assert ( ptm != nullptr );
91  DuneToolManager& tm = *ptm;
92  //tm.print();
93  assert( tm.toolNames().size() >= 1 );
94 
95  IndexRangeGroupTool* pcgt = tm.getShared<IndexRangeGroupTool>(tnameGroup);
96  IndexRangeTool* pcrt = tm.getShared<IndexRangeTool>(tnameRange);
97 
98  int warnGroup = 0;
99  int warnRange = 0;
100  // If user provides name, exit after displaying result.
101  bool exitLoop = crname.size();
102  while ( true ) {
103  if ( crname.size() == 0 ) {
104  cout << "Group or range name> ";
105  cout.flush();
106  std::getline(cin, crname);
107  }
108  if ( crname.size() == 0 || crname == "q" ) return 0;
109  IndexRangeGroup cg;
110  if ( pcgt == nullptr ) {
111  if ( ! warnGroup++ ) cout << "WARNING: Channel group tool not found: " << tnameGroup << endl;
112  } else {
113  cg = pcgt->get(crname);
114  }
115  if ( cg.isValid() ) {
116  cout << cg << endl;
117  } else if ( pcrt == nullptr ) {
118  if ( ! warnRange ) cout << "WARNING: Channel range tool not found: " << tnameRange << endl;
119  } else {
120  IndexRange cr = pcrt->get(crname);
121  if ( cr.isValid() ) {
122  cout << cr << endl;
123  } else {
124  cout << "ERROR: " << crname << " is not a valid channel group or range." << endl;
125  }
126  }
127  if ( warnGroup && warnRange ) return 1;
128  if ( exitLoop ) return 0;
129  crname = "";
130  }
131  return 0;
132 }
const std::vector< std::string > & toolNames() const
bool isValid() const
Definition: IndexRange.h:94
tm
Definition: demo.py:21
bool isValid() const
static DuneToolManager * instance(std::string fclname="", int dbg=1)
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)