34 const string myname =
"test_MultiChannelNoiseRemovalService: ";
36 cout << myname <<
"NDEBUG must be off." <<
endl;
39 string line =
"-----------------------------";
41 cout << myname << line <<
endl;
42 cout << myname <<
"Create top-level FCL." <<
endl;
44 std::ostringstream oss;
45 oss <<
"services.AdcChannelNoiseRemovalService: {" <<
endl;
46 oss <<
" service_provider: ThresholdNoiseRemovalService" <<
endl;
47 oss <<
" Threshold: " << threshold <<
endl;
48 oss <<
" LogLevel: " << a_LogLevel <<
endl;
50 oss <<
"services.AdcNoiseRemovalService: {" <<
endl;
51 oss <<
" service_provider: MultiChannelNoiseRemovalService" <<
endl;
52 oss <<
" LogLevel: " << a_LogLevel <<
endl;
56 cout << myname << line <<
endl;
57 cout << myname <<
"Create samples." <<
endl;
58 const unsigned int nchan = 5;
59 double f[nchan] = {0.11, 0.22, 0.33, 0.44, 0.55};
60 const unsigned int nsig = 100;
62 vector<AdcSignalVector> sigsin(nchan);
63 vector<AdcSignalVector> sigsexp(nchan);
64 for (
unsigned int icha=0; icha<nchan; ++icha ) {
71 for (
unsigned int isig=0; isig<nsig; ++isig ) {
72 acd.
samples.push_back(20*sin(f[icha]*isig));
79 for (
AdcSignal& sig : exp )
if ( fabs(sig) < threshold ) sig = 0.0;
82 cout << myname << line <<
endl;
83 cout << myname <<
"Fetch the noise removal." <<
endl;
85 hanr->
print(cout, myname);
87 cout << myname << line <<
endl;
88 cout << myname <<
"Remove noise." <<
endl;
89 assert( hanr->
update(acdmap) == 0 );
90 for (
unsigned int icha=0; icha<nchan; ++icha ) {
94 cout << myname <<
"-------" <<
endl;
95 cout << myname <<
"Channel " << chan <<
endl;
96 for (
unsigned int isig=0; isig<nsig; ++isig ) {
97 cout << myname <<
setw(4) << isig <<
": " 101 assert( sigs[isig] == sigsexp[icha][isig] );
105 cout << myname << line <<
endl;
106 cout << myname <<
"Done." <<
endl;
static void load_services(std::string const &config)
Q_EXPORT QTSManip setprecision(int p)
void setChannelInfo(ChannelInfoPtr pchi)
virtual int update(AdcChannelDataMap &datamap) const =0
Q_EXPORT QTSManip setw(int w)
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
QTextStream & endl(QTextStream &s)