23 using std::istringstream;
33 const string myname =
"test_AdcSampleScaler: ";
35 cout << myname <<
"NDEBUG must be off." <<
endl;
38 string line =
"-----------------------------";
40 cout << myname << line <<
endl;
41 string fclfile =
"test_AdcSampleScaler.fcl";
42 if ( ! useExistingFcl ) {
43 cout << myname <<
"Creating top-level FCL." <<
endl;
44 ofstream
fout(fclfile.c_str());
47 fout <<
" tool_type: AdcSampleScaler" <<
endl;
50 fout <<
" OutputUnit: \"e\"" <<
endl;
51 fout <<
" InputUnit: \"ADC\"" <<
endl;
56 cout << myname <<
"Using existing top-level FCL." <<
endl;
59 cout << myname << line <<
endl;
60 cout << myname <<
"Fetching tool manager." <<
endl;
62 assert ( ptm !=
nullptr );
67 cout << myname << line <<
endl;
68 cout << myname <<
"Fetching tool." <<
endl;
70 assert( ptoo !=
nullptr );
72 cout << myname << line <<
endl;
73 cout << myname <<
"Create data." <<
endl;
77 for (
Index isam=0; isam<nsam; ++isam ) {
78 float qsam = 200 + isam + 0.1*(isam%10);
80 qexps[isam] = 100*qsam;
87 assert ( qsams.
size() == nsam );
89 cout << myname << line <<
endl;
90 cout << myname <<
"Call tool." <<
endl;
91 DataMap ret = ptoo->update(acd);
93 assert( ret.
getInt(
"ascUnitCheck") == 0 );
95 cout << myname << line <<
endl;
96 cout << myname <<
"Check samples." <<
endl;
97 for (
Index isam=0; isam<nsam; ++isam ) {
99 float qexp = qexps[isam];
100 float qdif = fabs(qsam - qexp);
101 assert( qdif < 1.
e-5 );
104 cout << myname << line <<
endl;
105 cout << myname <<
"Done." <<
endl;
112 bool useExistingFcl =
false;
117 string sarg(argv[1]);
118 if ( sarg ==
"-h" ) {
119 cout <<
"Usage: " << argv[0] <<
" [ARG [qsig [ped [noise]]]]" <<
endl;
120 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
123 useExistingFcl = sarg ==
"true" || sarg ==
"1";
126 string sarg(argv[2]);
127 istringstream ssarg(sarg);
131 string sarg(argv[3]);
132 istringstream ssarg(sarg);
136 string sarg(argv[4]);
137 istringstream ssarg(sarg);
int test_AdcSampleScaler(bool useExistingFcl, float qsig, float ped, float noise)
int main(int argc, char *argv[])
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
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)