27 if ( fabs(x2 - x1) < 1.
e-5 )
return true;
28 cout <<
"isEqual: " << x1 <<
" != " << x2 <<
endl;
35 const string myname =
"test_AdcCodeMitigator: ";
37 cout << myname <<
"NDEBUG must be off." <<
endl;
40 string line =
"-----------------------------";
42 cout << myname << line <<
endl;
43 string fclfile =
"test_AdcCodeMitigator.fcl";
44 if ( ! useExistingFcl ) {
45 cout << myname <<
"Creating top-level FCL." <<
endl;
46 ofstream
fout(fclfile.c_str());
49 fout <<
" tool_type: AdcCodeMitigator" <<
endl;
53 fout <<
" InterpolateFlags: [8]" <<
endl;
56 fout <<
" InterpolateFlags: []" <<
endl;
59 fout <<
" FixedCurvThresh: 0.0" <<
endl;
64 cout << myname <<
"Using existing top-level FCL." <<
endl;
67 cout << myname << line <<
endl;
68 cout << myname <<
"Fetching tool manager." <<
endl;
70 assert ( ptm !=
nullptr );
75 cout << myname << line <<
endl;
76 cout << myname <<
"Fetching tool." <<
endl;
78 assert( pmit !=
nullptr );
80 cout << myname << line <<
endl;
81 cout << myname <<
"Create data and call tool." <<
endl;
83 AdcSignalVector inpSigs = {1000, 5, 11.0, 1000, 1000, 1000, 13, 14, 1000};
88 Index nsam = chkSigs.size();
90 for (
AdcIndex isam=0; isam<nsam; ++isam ) {
91 if ( inpFlgs[isam] != 0 ) {
100 DataMap ret = pmit->update(acd);
103 assert( ret.
getInt(
"mitCount") == 5 );
104 for (
AdcIndex isam=0; isam<nsam; ++isam ) {
105 cout << isam <<
":" <<
setw(6) << inpSigs[isam] <<
setw(6) << inpFlgs[isam]
108 assert( acd.
flags[isam] == chkFlgs[isam] );
111 cout << myname << line <<
endl;
112 cout << myname <<
"Done." <<
endl;
119 bool useExistingFcl =
false;
122 string sarg(argv[1]);
123 if ( sarg ==
"-h" ) {
124 cout <<
"Usage: " << argv[0] <<
" [ARG] [FIX]" <<
endl;
125 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
126 cout <<
" If FIX = true, fixed value is used instead of interpolation." <<
endl;
129 useExistingFcl = sarg ==
"true" || sarg ==
"1";
132 string sarg(argv[2]);
133 interp = sarg ==
"true" || sarg ==
"1";
bool isEqual(float x1, float x2)
std::vector< AdcFlag > AdcFlagVector
void print(std::ostream *pout) const
const AdcFlag AdcSetFixed
const AdcFlag AdcExtrapolated
Q_EXPORT QTSManip setw(int w)
int getInt(Name name, int def=0) const
const AdcFlag AdcInterpolated
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
int test_AdcCodeMitigator(bool useExistingFcl=false, bool interp=false)
int main(int argc, char *argv[])
QTextStream & endl(QTextStream &s)