Typedefs | Functions
test_FclIndexVectorMapTool.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "dunecore/DuneInterface/Tool/IndexVectorMapTool.h"
#include "TH1F.h"
#include <cassert>

Go to the source code of this file.

Typedefs

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 

Functions

int test_FclIndexVectorMapTool (bool useExistingFcl=false, Index runin=0)
 
int main (int argc, char *argv[])
 

Typedef Documentation

using Index = unsigned int

Definition at line 25 of file test_FclIndexVectorMapTool.cxx.

Definition at line 26 of file test_FclIndexVectorMapTool.cxx.

Function Documentation

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

Definition at line 95 of file test_FclIndexVectorMapTool.cxx.

95  {
96  bool useExistingFcl = false;
97  Index run = 0;
98  if ( argc > 1 ) {
99  string sarg(argv[1]);
100  if ( sarg == "-h" ) {
101  cout << "Usage: " << argv[0] << " [keepFCL] [RUN]" << endl;
102  cout << " If keepFCL = true, existing FCL file is used." << endl;
103  cout << " If RUN is nonzero, the data for that run are displayed." << endl;
104  return 0;
105  }
106  useExistingFcl = sarg == "true" || sarg == "1";
107  }
108  if ( argc > 2 ) {
109  string sarg(argv[2]);
110  istringstream ssarg(argv[2]);
111  ssarg >> run;
112  }
113  return test_FclIndexVectorMapTool(useExistingFcl, run);
114 }
int test_FclIndexVectorMapTool(bool useExistingFcl=false, Index runin=0)
unsigned int Index
QTextStream & endl(QTextStream &s)
int test_FclIndexVectorMapTool ( bool  useExistingFcl = false,
Index  runin = 0 
)

Definition at line 30 of file test_FclIndexVectorMapTool.cxx.

30  {
31  const string myname = "test_FclIndexVectorMapTool: ";
32 #ifdef NDEBUG
33  cout << myname << "NDEBUG must be off." << endl;
34  abort();
35 #endif
36  string line = "-----------------------------";
37 
38  cout << myname << line << endl;
39  string fclfile = "test_FclIndexVectorMapTool.fcl";
40  if ( ! useExistingFcl ) {
41  cout << myname << "Creating top-level FCL." << endl;
42  ofstream fout(fclfile.c_str());
43  if ( runin == 0 ) {
44  fout << "tools: {" << endl;
45  fout << " mytool: {" << endl;
46  fout << " tool_type: FclIndexVectorMapTool" << endl;
47  fout << " LogLevel: 3" << endl;
48  fout << " Entries: [ [100, 2, 3], [101, 12] ]" << endl;
49  fout << " }" << endl;
50  fout << "}" << endl;
51  }
52  fout.close();
53  } else {
54  cout << myname << "Using existing top-level FCL." << endl;
55  }
56 
57  cout << myname << line << endl;
58  cout << myname << "Fetching tool manager." << endl;
60  assert ( ptm != nullptr );
61  DuneToolManager& tm = *ptm;
62  tm.print();
63  assert( tm.toolNames().size() >= 1 );
64 
65  cout << myname << line << endl;
66  cout << myname << "Fetching tool." << endl;
67  auto pvm = ptm->getPrivate<IndexVectorMapTool>("mytool");
68  assert( pvm != nullptr );
69 
70  cout << myname << line << endl;
71  cout << myname << "Check get." << endl;
72  const IndexVector& vec0 = pvm->get(100);
73  assert( vec0.size() == 2 );
74  const IndexVector& vec1 = pvm->get(101);
75  assert( vec1.size() == 1 );
76  const IndexVector& vec2 = pvm->get(102);
77  assert( vec2.size() == 0 );
78 
79  cout << myname << line << endl;
80  cout << myname << "Check contains." << endl;
81  assert( pvm->contains(100, 2) );
82  assert( pvm->contains(100, 3) );
83  assert( ! pvm->contains(100, 4) );
84  assert( pvm->contains(101, 12) );
85  assert( ! pvm->contains(101, 4) );
86  assert( ! pvm->contains(102, 4) );
87 
88  cout << myname << line << endl;
89  cout << myname << "Done." << endl;
90  return 0;
91 }
std::vector< Index > IndexVector
const std::vector< std::string > & toolNames() const
void print() const
tm
Definition: demo.py:21
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)