Functions
test_AdcKeepAllSignalFinder.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_AdcKeepAllSignalFinder (bool useExistingFcl=false)
 
int main (int argc, char *argv[])
 

Function Documentation

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

Definition at line 98 of file test_AdcKeepAllSignalFinder.cxx.

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

Definition at line 25 of file test_AdcKeepAllSignalFinder.cxx.

25  {
26  const string myname = "test_AdcKeepAllSignalFinder: ";
27 #ifdef NDEBUG
28  cout << myname << "NDEBUG must be off." << endl;
29  abort();
30 #endif
31  string line = "-----------------------------";
32 
33  cout << myname << line << endl;
34  string fclfile = "test_AdcKeepAllSignalFinder.fcl";
35  if ( ! useExistingFcl ) {
36  cout << myname << "Creating top-level FCL." << endl;
37  ofstream fout(fclfile.c_str());
38  fout << "tools: {" << endl;
39  fout << " mytool: {" << endl;
40  fout << " tool_type: AdcKeepAllSignalFinder" << endl;
41  fout << " LogLevel: 1" << endl;
42  fout << " DataPath: \"\"" << endl;
43  fout << " }" << endl;
44  fout << "}" << endl;
45  fout.close();
46  } else {
47  cout << myname << "Using existing top-level FCL." << endl;
48  }
49 
50  cout << myname << line << endl;
51  cout << myname << "Fetching tool manager." << endl;
53  assert ( ptm != nullptr );
54  DuneToolManager& tm = *ptm;
55  tm.print();
56  assert( tm.toolNames().size() == 1 );
57 
58  cout << myname << line << endl;
59  cout << myname << "Fetching tool." << endl;
60  auto psgf = tm.getPrivate<TpcDataTool>("mytool");
61  assert( psgf != nullptr );
62  auto psgfmod = tm.getPrivate<TpcDataTool>("mytool");
63  assert( psgfmod != nullptr );
64 
65  cout << myname << line << endl;
66  cout << myname << "Create data and call tool." << endl;
68  for ( AdcIndex itic=0; itic<100; ++itic ) {
69  float xadc = rand()%20 - 10.0;
70  data.samples.push_back(xadc);
71  }
72  data.samples[30] = 150.0;
73  assert( data.signal.size() == 0 );
74  assert( data.rois.size() == 0 );
75  assert( data.samples[30] = 150 );
76 
77  cout << myname << line << endl;
78  cout << myname << "Running tool." << endl;
79  DataMap resmod = psgfmod->update(data);
80  resmod.print();
81 
82  cout << myname << line << endl;
83  cout << myname << "Checking results." << endl;
84  assert( resmod == 0 );
85  assert( resmod.getInt("nroi") == 1 );
86  assert( data.signal.size() == 100 );
87  assert( data.rois.size() == 1 );
88  assert( data.rois[0].first == 0 );
89  assert( data.rois[0].second == 99 );
90 
91  cout << myname << line << endl;
92  cout << myname << "Done." << endl;
93  return 0;
94 }
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
AdcRoiVector rois
unsigned int AdcIndex
Definition: AdcTypes.h:15
std::unique_ptr< T > getPrivate(std::string name)
AdcFilterVector signal
int getInt(Name name, int def=0) const
Definition: DataMap.h:218
void line(double t, double *p, double &x, double &y, double &z)
static DuneToolManager * instance(std::string fclname="", int dbg=1)
AdcSignalVector samples
QTextStream & endl(QTextStream &s)