33 const string myname =
"test_AdcRangeSampleScaler: ";
35 cout << myname <<
"NDEBUG must be off." <<
endl;
38 string line =
"-----------------------------";
40 cout << myname << line <<
endl;
41 string fclfile =
"test_AdcRangeSampleScaler.fcl";
42 Index chaMod = useMod ? 30 : 0;
43 if ( ! useExistingFcl ) {
44 cout << myname <<
"Creating top-level FCL." <<
endl;
45 ofstream
fout(fclfile.c_str());
48 fout <<
" tool_type: AdcRangeSampleScaler" <<
endl;
50 fout <<
" RangeLimits: [10, 20]" <<
endl;
51 fout <<
" RangeModulus: " << chaMod <<
endl;
52 fout <<
" ScaleFactors: [2, 4, 8]" <<
endl;
57 cout << myname <<
"Using existing top-level FCL." <<
endl;
60 cout << myname << line <<
endl;
61 cout << myname <<
"Fetching tool manager." <<
endl;
63 assert ( ptm !=
nullptr );
68 cout << myname << line <<
endl;
69 cout << myname <<
"Fetching tool." <<
endl;
71 assert( ptoo !=
nullptr );
73 cout << myname << line <<
endl;
74 cout << myname <<
"Create data." <<
endl;
78 for (
Index icha=0; icha<ncha; ++icha ) {
86 cout << myname << line <<
endl;
87 cout << myname <<
"Create expected data." <<
endl;
89 for (
Index icha=0; icha<ncha; ++icha ) {
90 Index ichaMod = useMod ? icha%chaMod : icha;
91 if ( ichaMod >= 20 ) qexps[icha] = 80;
92 else if ( ichaMod >= 10 ) qexps[icha] = 40;
93 else qexps[icha] = 20;
96 cout << myname << line <<
endl;
97 cout << myname <<
"Call tool." <<
endl;
98 DataMap ret = ptoo->updateMap(acds);
101 cout << myname << line <<
endl;
102 cout << myname <<
"Check samples." <<
endl;
103 for (
const AdcChannelDataMap::value_type& iacd : acds ) {
104 Index icha = iacd.first;
106 assert( acd.
channel() == icha );
107 assert( acd.
samples.size() == nsam );
109 float qexp = qexps[icha];
110 float qdif = fabs(qsam - qexp);
111 cout << myname <<
setw(4) << icha <<
":" <<
setw(10) << qexp <<
setw(10) << qsam <<
endl;
112 assert( qdif < 1.
e-5 );
113 for (
float qchk : acd.
samples ) {
114 assert( qchk == qsam );
118 cout << myname << line <<
endl;
119 cout << myname <<
"Done." <<
endl;
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
QTextStream & endl(QTextStream &s)