24 using std::istringstream;
35 if ( sigdiff < -0.5 )
return false;
36 if ( sigdiff > 0.5 )
return false;
43 const string myname =
"test_InterpolatingAdcMitigationService: ";
45 cout << myname <<
"NDEBUG must be off." <<
endl;
48 string line =
"-----------------------------";
50 cout << myname << line <<
endl;
51 cout << myname <<
"Create top-level FCL." <<
endl;
52 std::ostringstream oss;
53 oss <<
"services.AdcMitigationService: {" <<
endl;
54 oss <<
" service_provider: InterpolatingAdcMitigationService" <<
endl;
55 oss <<
" LogLevel: " << a_LogLevel <<
endl;
56 oss <<
" SkipUnderflows: true" <<
endl;
57 oss <<
" SkipOverflows: false" <<
endl;
58 oss <<
" MaxConsecutiveSamples: 3 " <<
endl;
59 oss <<
" MaxConsecutiveFlag: " << a_MaxConsecutiveFlag <<
endl;
63 const unsigned int nsig = 50;
65 for (
unsigned int isig=0; isig<50; ++isig ) {
78 for (
unsigned int isig : isigOvers ) {
86 for (
unsigned int isig : isigUnders ) {
89 sigsexp[isig] = sigs[isig];
90 flagsexp[isig] = flags[isig];
96 for (
unsigned int isig : isigOns ) {
104 IndexVector isigOffs = {0, 1, 33, 34, 35, 36, 41, 42, 43, 44, 45, 46, nsig-1};
105 for (
unsigned int isig : isigOffs ) {
108 if ( a_MaxConsecutiveFlag == 1 ) {
112 assert( a_MaxConsecutiveFlag == 0 );
113 sigsexp[isig] = sigs[isig];
114 flagsexp[isig] = flags[isig];
122 cout << myname <<
"Fetch ADC mitigation service." <<
endl;
126 cout << myname << line <<
endl;
127 cout << myname <<
"Mitigate." <<
endl;
128 assert( hams->
update(acd) == 0 );
129 cout << myname <<
"Output vector size: " << sigs.size() <<
endl;
130 cout << myname <<
" Output flags size: " << flags.size() <<
endl;
131 assert( sigs.size() == nsig );
132 assert( flags.size() == nsig );
133 for (
unsigned int isig=0; isig<nsig; ++isig ) {
134 cout <<
setw(4) << isig <<
": " 136 <<
" [" << flagsin[isig] <<
"]" 138 <<
" [" << flags[isig] <<
"]" 139 <<
" [" << flagsexp[isig] <<
"]" 141 assert( flags[isig] == flagsexp[isig] );
142 assert( sigs[isig] == sigsexp[isig] );
152 int a_MaxConsecutiveFlag = 0;
154 istringstream ssarg(argv[1]);
158 istringstream ssarg(argv[1]);
159 ssarg >> a_MaxConsecutiveFlag;
int test_InterpolatingAdcMitigationService(int a_LogLevel=1, int a_MaxConsecutiveFlag=0)
bool sigequal(AdcSignal sig1, AdcSignal sig2)
virtual int update(AdcChannelData &data) const =0
int main(int argc, char *argv[])
std::vector< AdcFlag > AdcFlagVector
const AdcFlag AdcUnderflow
static void load_services(std::string const &config)
Q_EXPORT QTSManip setprecision(int p)
const AdcFlag AdcSetFixed
const AdcFlag AdcOverflow
Q_EXPORT QTSManip setw(int w)
const AdcFlag AdcStuckOff
const AdcFlag AdcInterpolated
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
vector< unsigned int > IndexVector
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
QTextStream & endl(QTextStream &s)