26 const string myname =
"test_AdcThresholdSignalFinder: ";
28 cout << myname <<
"NDEBUG must be off." <<
endl;
31 string line =
"-----------------------------";
33 cout << myname << line <<
endl;
34 string fclfile =
"test_AdcThresholdSignalFinder.fcl";
35 if ( ! useExistingFcl ) {
36 cout << myname <<
"Creating top-level FCL." <<
endl;
37 ofstream
fout(fclfile.c_str());
40 fout <<
" tool_type: AdcThresholdSignalFinder" <<
endl;
42 fout <<
" Threshold: \"100*[gain]/14.0\"" <<
endl;
45 fout <<
" FlagPositive: true" <<
endl;
46 fout <<
" FlagNegative: true" <<
endl;
49 fout <<
" tool_type: FclRunDataTool" <<
endl;
51 fout <<
" FileNames: [\"rundata.fcl\"]" <<
endl;
55 ofstream fout2(
"rundata.fcl");
56 fout2 <<
"run: 123" <<
endl;
57 fout2 <<
"gain: 14.0" <<
endl;
58 fout2 <<
"shaping: 2.0" <<
endl;
62 cout << myname <<
"Using existing top-level FCL." <<
endl;
65 cout << myname << line <<
endl;
66 cout << myname <<
"Fetching tool manager." <<
endl;
68 assert ( ptm !=
nullptr );
73 cout << myname << line <<
endl;
74 cout << myname <<
"Fetching tool." <<
endl;
76 assert( psgf !=
nullptr );
78 assert( psgfmod !=
nullptr );
80 cout << myname << line <<
endl;
81 cout << myname <<
"Create data and call tool." <<
endl;
83 for (
AdcIndex itic=0; itic<100; ++itic ) {
84 float xadc = rand()%20 - 10.0;
88 assert( data.
signal.size() == 0 );
89 assert( data.
rois.size() == 0 );
90 assert( data.
samples[30] = 150 );
92 cout << myname << line <<
endl;
93 cout << myname <<
"Running tool." <<
endl;
94 DataMap resmod = psgfmod->update(data);
97 cout << myname << line <<
endl;
98 cout << myname <<
"Checking results." <<
endl;
99 assert( resmod == 0 );
100 assert( fabs(resmod.
getFloat(
"threshold") - 100) < 0.1 );
101 assert( resmod.
getInt(
"nThresholdBins") == 1 );
102 assert( resmod.
getInt(
"nroi") == 1 );
103 assert( data.
signal.size() == 100 );
104 assert( data.
rois.size() == 1 );
105 assert( data.
rois[0].first == 25 );
106 assert( data.
rois[0].second == 40 );
108 cout << myname << line <<
endl;
109 cout << myname <<
"Done." <<
endl;
116 bool useExistingFcl =
false;
118 string sarg(argv[1]);
119 if ( sarg ==
"-h" ) {
120 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
121 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
124 useExistingFcl = sarg ==
"true" || sarg ==
"1";
void print(std::ostream *pout) const
int test_AdcThresholdSignalFinder(bool useExistingFcl=false)
Float getFloat(Name name, 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)
int main(int argc, char *argv[])