Functions
test_ThresholdNoiseRemovalService.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "dunecore/ArtSupport/ArtServiceHelper.h"
#include "dunecore/DuneInterface/Service/AdcChannelNoiseRemovalService.h"
#include <cassert>

Go to the source code of this file.

Functions

int test_ThresholdNoiseRemovalService (int a_LogLevel=1)
 
int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 87 of file test_ThresholdNoiseRemovalService.cxx.

87  {
88  int a_LogLevel = -1;
89  if ( argc > 1 ) {
90  istringstream ssarg(argv[1]);
91  ssarg >> a_LogLevel;
92  }
93  return test_ThresholdNoiseRemovalService(a_LogLevel);
94 }
int test_ThresholdNoiseRemovalService(int a_LogLevel=1)
int test_ThresholdNoiseRemovalService ( int  a_LogLevel = 1)

Definition at line 33 of file test_ThresholdNoiseRemovalService.cxx.

33  {
34  const string myname = "test_ThresholdNoiseRemovalService: ";
35 #ifdef NDEBUG
36  cout << myname << "NDEBUG must be off." << endl;
37  abort();
38 #endif
39  string line = "-----------------------------";
40 
41  cout << myname << line << endl;
42  cout << myname << "Create top-level FCL." << endl;
43  AdcSignal threshold = 4.0;
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;
49  oss << "}" << endl;
51 
52  const unsigned int nsig = 100;
53  AdcChannelData acd;
54  acd.setChannelInfo(100);
55  for ( unsigned int isig=0; isig<nsig; ++isig ) {
56  acd.samples.push_back(20*sin(0.47*isig));
57  acd.flags.push_back(AdcGood);
58  }
59  AdcSignalVector& sigs = acd.samples;
60  AdcSignalVector sigsin = sigs;
61  AdcSignalVector sigsexp = sigs;
62  for ( AdcSignal& sig : sigsexp ) if ( fabs(sig) < threshold ) sig = 0.0;
63 
64  cout << myname << line << endl;
65  cout << myname << "Fetch the noise removal." << endl;
67  hanr->print(cout, myname);
68 
69  cout << myname << line << endl;
70  cout << myname << "Remove noise." << endl;
71  assert( hanr->update(acd) == 0 );
72  for ( unsigned int isig=0; isig<nsig; ++isig ) {
73  cout << myname << setw(4) << isig << ": "
74  << fixed << setprecision(1) << setw(10) << sigsin[isig]
75  << fixed << setprecision(1) << setw(10) << sigs[isig]
76  << endl;
77  assert( sigs[isig] == sigsexp[isig] );
78  }
79 
80  cout << myname << line << endl;
81  cout << myname << "Done." << endl;
82  return 0;
83 }
float AdcSignal
Definition: AdcTypes.h:21
static void load_services(std::string const &config)
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
const AdcFlag AdcGood
Definition: AdcTypes.h:32
void setChannelInfo(ChannelInfoPtr pchi)
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
void line(double t, double *p, double &x, double &y, double &z)
virtual int update(AdcChannelData &data) const =0
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags