29 const string myname =
"test_AdcRegularSignalFinder: ";
31 cout << myname <<
"NDEBUG must be off." <<
endl;
34 string line =
"-----------------------------";
36 cout << myname << line <<
endl;
37 string fclfile =
"test_AdcRegularSignalFinder.fcl";
38 if ( ! useExistingFcl ) {
39 cout << myname <<
"Creating top-level FCL." <<
endl;
40 ofstream
fout(fclfile.c_str());
43 fout <<
" tool_type: AdcRegularSignalFinder" <<
endl;
51 cout << myname <<
"Using existing top-level FCL." <<
endl;
54 cout << myname << line <<
endl;
55 cout << myname <<
"Fetching tool manager." <<
endl;
57 assert ( ptm !=
nullptr );
62 cout << myname << line <<
endl;
63 cout << myname <<
"Fetching tool." <<
endl;
65 assert( psgf !=
nullptr );
67 assert( psgfmod !=
nullptr );
69 cout << myname << line <<
endl;
70 cout << myname <<
"Create data and call tool." <<
endl;
73 for (
AdcIndex itic=0; itic<nsam; ++itic ) {
74 float xadc = rand()%20 - 10.0;
78 assert( data.
signal.size() == 0 );
79 assert( data.
rois.size() == 0 );
80 assert( data.
samples.size() == nsam );
81 assert( data.
samples[30] = 150 );
83 cout << myname << line <<
endl;
84 cout << myname <<
"Running tool." <<
endl;
85 DataMap resmod = psgfmod->update(data);
88 cout << myname << line <<
endl;
89 cout << myname <<
"Checking results." <<
endl;
94 assert( resmod == 0 );
95 assert( resmod.
getInt(
"roiPeriod") ==
int(per) );
96 assert( resmod.
getInt(
"roiLength") ==
int(len) );
97 assert( resmod.
getInt(
"roiCount") ==
int(nroi) );
98 assert( data.
signal.size() == nsam );
99 assert( data.
rois.size() == nroi );
100 for (
Index iroi=0; iroi<nroi; ++iroi ) {
102 cout << myname <<
"ROI " << iroi <<
": [" 104 << roi.second <<
"]" <<
endl;
105 Index isam1 = iroi*per;
106 Index isam2 = isam1 + len;
107 if ( isam2 > nsam ) isam2 = nsam;
108 Index isam3 = isam1 + per;
109 if ( isam3 > nsam ) isam3 = nsam;
110 for (
Index isam=isam1; isam<isam3; ++isam ) {
111 bool sig = data.
signal[isam];
112 string ssig = sig ?
"true" :
"false";
113 cout << myname <<
setw(4) << isam <<
": " << ssig <<
endl;
114 if ( isam < isam2 ) assert( data.
signal[isam]);
115 else assert( ! data.
signal[isam]);
117 assert( roi.first == isam1 );
118 assert( roi.second == isam2 - 1 );
120 cout << myname << line <<
endl;
121 cout << myname <<
"Done." <<
endl;
std::pair< AdcIndex, AdcIndex > AdcRoi
void print(std::ostream *pout) const
Q_EXPORT QTSManip setw(int w)
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)