26 const string myname =
"test_AdcNoiseSignalFinder: ";
28 cout << myname <<
"NDEBUG must be off." <<
endl;
31 string line =
"-----------------------------";
33 cout << myname << line <<
endl;
34 string fclfile =
"test_AdcNoiseSignalFinder.fcl";
35 if ( ! useExistingFcl ) {
36 cout << myname <<
"Creating top-level FCL." <<
endl;
37 ofstream
fout(fclfile.c_str());
40 fout <<
" tool_type: AdcNoiseSignalFinder" <<
endl;
44 fout <<
" ThresholdRatio: 5" <<
endl;
45 fout <<
" ThresholdRatioTol: 0.1" <<
endl;
49 fout <<
" FlagPositive: true" <<
endl;
50 fout <<
" FlagNegative: true" <<
endl;
55 cout << myname <<
"Using existing top-level FCL." <<
endl;
58 cout << myname << line <<
endl;
59 cout << myname <<
"Fetching tool manager." <<
endl;
61 assert ( ptm !=
nullptr );
66 cout << myname << line <<
endl;
67 cout << myname <<
"Fetching tool." <<
endl;
69 assert( psgf !=
nullptr );
71 assert( psgfmod !=
nullptr );
73 cout << myname << line <<
endl;
74 cout << myname <<
"Create data and call tool." <<
endl;
77 float signoi = wnoi/sqrt(12.0);
79 for (
AdcIndex itic=0; itic<100; ++itic ) {
80 float xadc = rand()%wnoi - 0.5*wnoi;
84 assert( data.
signal.size() == 0 );
85 assert( data.
rois.size() == 0 );
86 assert( data.
samples[30] = 150 );
88 cout << myname << line <<
endl;
89 cout << myname <<
"Running tool." <<
endl;
90 DataMap resmod = psgfmod->update(data);
93 cout << myname << line <<
endl;
94 cout << myname <<
"Checking results." <<
endl;
95 assert( resmod == 0 );
96 assert( resmod.
getInt(
"nsfLoopCount") > 1 );
97 assert( resmod.
getInt(
"nsfRoiCount") == 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 == 40 );
103 assert( mdNoise > 0.9*signoi );
104 assert( mdNoise < 1.1*signoi );
106 int mdNsig =
int(100*mdSigFrac + 0.1);
107 assert( mdNsig == 16 );
109 float expThresh = 5.0*signoi;
110 assert( mdThresh > 0.9*expThresh );
111 assert( mdThresh < 1.1*expThresh );
113 cout << myname << line <<
endl;
114 cout << myname <<
"Done." <<
endl;
void print(std::ostream *pout) const
float getMetadata(Name mname, float def=0.0) const
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)