Functions
test_AdcRoiShifter.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include "dunecore/DuneInterface/Tool/TpcDataTool.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include <cassert>

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 93 of file test_AdcRoiShifter.cxx.

93  {
94  bool useExistingFcl = false;
95  if ( argc > 1 ) {
96  string sarg(argv[1]);
97  if ( sarg == "-h" ) {
98  cout << "Usage: " << argv[0] << " [ARG]" << endl;
99  cout << " If ARG = true, existing FCL file is used." << endl;
100  return 0;
101  }
102  useExistingFcl = sarg == "true" || sarg == "1";
103  }
104  return test_AdcRoiShifter(useExistingFcl);
105 }
int test_AdcRoiShifter(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)
int test_AdcRoiShifter ( bool  useExistingFcl = false)

Definition at line 26 of file test_AdcRoiShifter.cxx.

26  {
27  const string myname = "test_AdcRoiShifter: ";
28 #ifdef NDEBUG
29  cout << myname << "NDEBUG must be off." << endl;
30  abort();
31 #endif
32  string line = "-----------------------------";
33 
34  cout << myname << line << endl;
35  string fclfile = "test_AdcRoiShifter.fcl";
36  if ( ! useExistingFcl ) {
37  cout << myname << "Creating top-level FCL." << endl;
38  ofstream fout(fclfile.c_str());
39  fout << "tools: {" << endl;
40  fout << " mytool: {" << endl;
41  fout << " tool_type: AdcRoiShifter" << endl;
42  fout << " LogLevel: 1" << endl;
43  fout << " BinOffset: 3" << endl;
44  fout << " }" << endl;
45  fout << "}" << endl;
46  fout.close();
47  } else {
48  cout << myname << "Using existing top-level FCL." << endl;
49  }
50 
51  cout << myname << line << endl;
52  cout << myname << "Fetching tool manager." << endl;
54  assert ( ptm != nullptr );
55  DuneToolManager& tm = *ptm;
56  tm.print();
57  assert( tm.toolNames().size() == 1 );
58 
59  cout << myname << line << endl;
60  cout << myname << "Fetching tool." << endl;
61  auto psgf = tm.getPrivate<TpcDataTool>("mytool");
62  assert( psgf != nullptr );
63  auto psgfmod = tm.getPrivate<TpcDataTool>("mytool");
64  assert( psgfmod != nullptr );
65 
66  cout << myname << line << endl;
67  cout << myname << "Create data and call tool." << endl;
69  vector<bool> sigdat = {false, true, false, false, true, false, false, false, true};
70  vector<bool> sigchk = {false, false, false, false, true, false, false, true, false};
71  data.signal = sigdat;
72  assert( data.signal == sigdat );
73  assert( data.signal != sigchk );
74 
75  cout << myname << line << endl;
76  cout << myname << "Running tool." << endl;
77  DataMap resmod = psgfmod->update(data);
78  resmod.print();
79 
80  cout << myname << line << endl;
81  cout << myname << "Checking results." << endl;
82  assert( resmod == 0 );
83  assert( data.signal != sigdat );
84  assert( data.signal == sigchk );
85 
86  cout << myname << line << endl;
87  cout << myname << "Done." << endl;
88  return 0;
89 }
const std::vector< std::string > & toolNames() const
void print() const
void print(std::ostream *pout) const
Definition: DataMap.h:245
tm
Definition: demo.py:21
std::unique_ptr< T > getPrivate(std::string name)
AdcFilterVector signal
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)