23 using std::ostringstream;
33 const string myname =
"test_AdcChannelTrimmer: ";
35 cout << myname <<
"NDEBUG must be off." <<
endl;
38 string line =
"-----------------------------";
40 cout << myname << line <<
endl;
41 string fclfile =
"test_AdcChannelTrimmer.fcl";
42 if ( ! useExistingFcl ) {
43 cout << myname <<
"Creating top-level FCL." <<
endl;
44 ofstream
fout(fclfile.c_str());
45 fout <<
"#include \"dataprep_tools.fcl\"" <<
endl;
47 fout <<
" tool_type: AdcChannelTrimmer" <<
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;
70 cout << myname << line <<
endl;
71 cout << myname <<
"Create data." <<
endl;
78 acd.
samples[isam] = 1.0 + 0.01*isam;
80 assert( acd.
samples.size() == 15 );
82 cout << myname << line <<
endl;
83 cout << myname <<
"Call tool view." <<
endl;
87 assert( dmv.
getInt(
"trimAction") == -1 );
88 assert( dmv.
getInt(
"trimLength") == -5 );
89 assert( acd.
samples.size() == 15 );
91 cout << myname << line <<
endl;
92 cout << myname <<
"Call tool update." <<
endl;
94 DataMap dmu = ptoo->update(acd);
98 assert( dmu.
getInt(
"trimAction") == 1 );
99 assert( dmu.
getInt(
"trimLength") == -5 );
100 assert( len1 == 15 );
101 assert( len2 == 20 );
102 for (
Index isam=len1; isam<len2; ++isam ) {
103 float qsam = acd.
samples[isam];
104 float qchk = acd.
samples[isam-len1];
105 assert( fabs(qsam-qchk) < 1.
e-6 );
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";
int main(int argc, char *argv[])
void print(std::ostream *pout) const
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
int test_AdcChannelTrimmer(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)