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

Function Documentation

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

Definition at line 110 of file test_DuneAdcSignalFinder.cxx.

110  {
111  bool useExistingFcl = false;
112  if ( argc > 1 ) {
113  string sarg(argv[1]);
114  if ( sarg == "-h" ) {
115  cout << "Usage: " << argv[0] << " [ARG]" << endl;
116  cout << " If ARG = true, existing FCL file is used." << endl;
117  return 0;
118  }
119  useExistingFcl = sarg == "true" || sarg == "1";
120  }
121  return test_DuneAdcSignalFinder(useExistingFcl);
122 }
int test_DuneAdcSignalFinder(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)
int test_DuneAdcSignalFinder ( bool  useExistingFcl = false)

Definition at line 25 of file test_DuneAdcSignalFinder.cxx.

25  {
26  const string myname = "test_DuneAdcSignalFinder: ";
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_DuneAdcSignalFinder.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: DuneAdcSignalFinder" << endl;
41  fout << " LogLevel: 1" << endl;
42  fout << " NoiseSigma: 0.0" << endl;
43  fout << " NSigmaStart: 3.0" << endl;
44  fout << " NSigmaEnd: 1.0" << endl;
45  fout << " TicksAfter: 10" << endl;
46  fout << " TicksBefore: 5" << endl;
47  fout << " }" << endl;
48  fout << "}" << endl;
49  fout.close();
50  } else {
51  cout << myname << "Using existing top-level FCL." << endl;
52  }
53 
54  cout << myname << line << endl;
55  cout << myname << "Fetching tool manager." << endl;
57  assert ( ptm != nullptr );
58  DuneToolManager& tm = *ptm;
59  tm.print();
60  assert( tm.toolNames().size() == 1 );
61 
62  cout << myname << line << endl;
63  cout << myname << "Fetching tool." << endl;
64  auto psgf = tm.getPrivate<TpcDataTool>("mytool");
65  assert( psgf != nullptr );
66  auto psgfmod = tm.getPrivate<TpcDataTool>("mytool");
67  assert( psgfmod != nullptr );
68 
69  cout << myname << line << endl;
70  cout << myname << "Create data and call tool." << endl;
72  for ( AdcIndex itic=0; itic<100; ++itic ) {
73  float xadc = rand()%20 - 10.0;
74  data.samples.push_back(xadc);
75  }
76  data.sampleNoise = 40.0;
77  data.samples[30] = 150.0;
78  assert( data.signal.size() == 0 );
79  assert( data.rois.size() == 0 );
80  assert( data.samples[30] = 150 );
81  assert( data.samples[31] = 130 );
82  assert( data.samples[32] = 90 );
83  assert( data.samples[33] = 70 );
84  assert( data.samples[34] = 45 );
85  assert( data.samples[35] = 30 );
86  assert( data.samples[36] = 20 );
87  assert( data.samples[37] = 15 );
88 
89  cout << myname << line << endl;
90  cout << myname << "Running tool." << endl;
91  DataMap resmod = psgfmod->update(data);
92  resmod.print();
93 
94  cout << myname << line << endl;
95  cout << myname << "Checking results." << endl;
96  assert( resmod == 0 );
97  assert( resmod.getInt("nroi") == 1 );
98  assert( data.signal.size() == 100 );
99  assert( data.rois.size() == 1 );
100  assert( data.rois[0].first == 25 );
101  assert( data.rois[0].second == 44 );
102 
103  cout << myname << line << endl;
104  cout << myname << "Done." << endl;
105  return 0;
106 }
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
AdcSignal sampleNoise
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)