26 const string myname =
"test_AdcSampleFiller: ";
28 cout << myname <<
"NDEBUG must be off." <<
endl;
31 string line =
"-----------------------------";
33 cout << myname << line <<
endl;
34 string fclfile =
"test_AdcSampleFiller.fcl";
35 if ( ! useExistingFcl ) {
36 cout << myname <<
"Creating top-level FCL." <<
endl;
37 ofstream
fout(fclfile.c_str());
40 fout <<
" tool_type: AdcSampleFiller" <<
endl;
43 fout <<
" AdcOverflow: 4095" <<
endl;
48 cout << myname <<
"Using existing top-level FCL." <<
endl;
51 cout << myname << line <<
endl;
52 cout << myname <<
"Fetching tool manager." <<
endl;
54 assert ( ptm !=
nullptr );
59 cout << myname << line <<
endl;
60 cout << myname <<
"Fetching tool." <<
endl;
62 assert( pasf !=
nullptr );
64 assert( pasfmod !=
nullptr );
66 cout << myname << line <<
endl;
67 cout << myname <<
"Create data and call tool." <<
endl;
69 for (
AdcIndex itic=0; itic<60; ++itic ) {
71 data.
raw.push_back(adc);
73 assert( data.
raw.size() == 60 );
74 assert( data.
samples.size() == 0 );
75 assert( data.
signal.size() == 0 );
76 assert( data.
rois.size() == 0 );
78 cout << myname << line <<
endl;
79 cout << myname <<
"Running tool without pedestal." <<
endl;
80 DataMap resmodBad = pasfmod->update(data);
82 assert( resmodBad != 0 );
84 cout << myname << line <<
endl;
85 cout << myname <<
"Running tool." <<
endl;
87 DataMap resmod = pasfmod->update(data);
90 cout << myname << line <<
endl;
91 cout << myname <<
"Checking results." <<
endl;
92 assert( resmod == 0 );
94 assert( resmod.
getInt(
"nUnderflow") == 1 );
95 assert( resmod.
getInt(
"nOverflow") == 19 );
96 assert( resmod.
getInt(
"nOutOfRange") == 19 );
97 assert( data.
raw.size() == 60 );
98 assert( data.
samples.size() == 60 );
99 assert( data.
signal.size() == 0 );
101 cout << myname << line <<
endl;
102 cout << myname <<
"Done." <<
endl;
109 bool useExistingFcl =
false;
111 string sarg(argv[1]);
112 if ( sarg ==
"-h" ) {
113 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
114 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
117 useExistingFcl = sarg ==
"true" || sarg ==
"1";
void print(std::ostream *pout) const
int main(int argc, char *argv[])
int test_AdcSampleFiller(bool useExistingFcl=false)
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)