Typedefs | Functions
test_ChannelStatusConfigTool.cxx File Reference
#include "dunecore/DuneInterface/Data/AdcTypes.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "dunecore/DuneInterface/Tool/IndexMapTool.h"
#include "TH1F.h"
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cassert>

Go to the source code of this file.

Typedefs

using Index = unsigned int
 

Functions

int test_ChannelStatusConfigTool (bool useExistingFcl=false)
 
int main (int argc, char *argv[])
 

Typedef Documentation

using Index = unsigned int

Definition at line 29 of file test_ChannelStatusConfigTool.cxx.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 101 of file test_ChannelStatusConfigTool.cxx.

101  {
102  bool useExistingFcl = false;
103  if ( argc > 1 ) {
104  string sarg(argv[1]);
105  if ( sarg == "-h" ) {
106  cout << "Usage: " << argv[0] << " [keepFCL]" << endl;
107  cout << " If keepFCL = true, existing FCL file is used." << endl;
108  return 0;
109  }
110  useExistingFcl = sarg == "true" || sarg == "1";
111  }
112  return test_ChannelStatusConfigTool(useExistingFcl);
113 }
int test_ChannelStatusConfigTool(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)
int test_ChannelStatusConfigTool ( bool  useExistingFcl = false)

Definition at line 33 of file test_ChannelStatusConfigTool.cxx.

33  {
34  const string myname = "test_ChannelStatusConfigTool: ";
35 #ifdef NDEBUG
36  cout << myname << "NDEBUG must be off." << endl;
37  abort();
38 #endif
39  string line = "-----------------------------";
40 
41  cout << myname << line << endl;
42  string fclfile = "test_ChannelStatusConfigTool.fcl";
43  if ( ! useExistingFcl ) {
44  cout << myname << "Creating top-level FCL." << endl;
45  ofstream fout(fclfile.c_str());
46  fout << "tools: {" << endl;
47  fout << " mytool: {" << endl;
48  fout << " tool_type: ChannelStatusConfigTool" << endl;
49  fout << " LogLevel: 1" << endl;
50  fout << " DefaultIndex: 99" << endl;
51  fout << " IndexVectors: [" << endl;
52  fout << " [ 0, 1, 2]," << endl;
53  fout << " [ 10, 11, 12]," << endl;
54  fout << " [ 20, 21, 22]" << endl;
55  fout << " ]" << endl;
56  fout << " }" << endl;
57  fout << "}" << endl;
58  fout.close();
59  } else {
60  cout << myname << "Using existing top-level FCL." << endl;
61  }
62 
63  cout << myname << line << endl;
64  cout << myname << "Fetching tool manager." << endl;
66  assert ( ptm != nullptr );
67  DuneToolManager& tm = *ptm;
68  tm.print();
69  assert( tm.toolNames().size() >= 1 );
70 
71  cout << myname << line << endl;
72  cout << myname << "Fetching tool." << endl;
73  auto pcs = tm.getPrivate<IndexMapTool>("mytool");
74  assert( pcs != nullptr );
75 
76  cout << myname << line << endl;
77  cout << "Check some channels." << endl;
78  vector<Index> chks(30, 99);
79  chks[ 0] = 0;
80  chks[ 1] = 0;
81  chks[ 2] = 0;
82  chks[10] = 1;
83  chks[11] = 1;
84  chks[12] = 1;
85  chks[20] = 2;
86  chks[21] = 2;
87  chks[22] = 2;
88  for ( Index icha=0; icha<chks.size(); ++icha ) {
89  Index chanStat = pcs->get(icha);
90  cout << setw(8) << icha << ": " << setw(2) << chanStat << endl;
91  assert( chanStat == chks[icha] );
92  }
93 
94  cout << myname << line << endl;
95  cout << myname << "Done." << endl;
96  return 0;
97 }
const std::vector< std::string > & toolNames() const
void print() const
unsigned int Index
tm
Definition: demo.py:21
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::unique_ptr< T > getPrivate(std::string name)
void line(double t, double *p, double &x, double &y, double &z)
static DuneToolManager * instance(std::string fclname="", int dbg=1)
QTextStream & endl(QTextStream &s)