test_AdcSuppressSignalFindingService.cxx
Go to the documentation of this file.
1 // test_AdcSuppressSignalFindingService.cxx
2 //
3 // David Adams
4 // June 2016
5 //
6 // Test AdcSuppressSignalFindingService.
7 
8 #include <string>
9 #include <iostream>
10 #include <sstream>
11 #include <fstream>
12 #include <iomanip>
18 
19 #undef NDEBUG
20 #include <cassert>
21 
22 using std::string;
23 using std::cout;
24 using std::endl;
25 using std::istringstream;
26 using std::ofstream;
27 using std::setw;
28 using std::setprecision;
29 using std::fixed;
30 using art::ServiceHandle;
31 
32 //**********************************************************************
33 
35  const string myname = "test_AdcSuppressSignalFindingService: ";
36 #ifdef NDEBUG
37  cout << myname << "NDEBUG must be off." << endl;
38  abort();
39 #endif
40  string line = "-----------------------------";
41 
42  cout << myname << line << endl;
43  cout << myname << "Create top-level FCL." << endl;
44  std::ostringstream oss;
45  oss << "services.AdcSuppressService: {" << endl;
46  oss << " service_provider: Legacy35tZeroSuppressService" << endl;
47  oss << " AdcThreshold: 30.0" << endl;
48  oss << " TickRange: 4" << endl;
49  oss << " MinTickGap: 2" << endl;
50  oss << " SuppressStickyBits: false" << endl;
51  oss << "}" << endl;
52  oss << "services.AdcSignalFindingService: {" << endl;
53  oss << " service_provider: AdcSuppressSignalFindingService" << endl;
54  oss << "}" << endl;
56 
57  cout << myname << line << endl;
58  cout << myname << "Create data." << endl;
60  data.setChannelInfo(1234);
61  data.pedestal = 1000.0;
62  for ( unsigned int tic=0; tic<50; ++tic ) {
63  AdcSignal sig = tic%10 - 5.0;
64  if ( tic > 10 && tic < 20 ) sig += 100;
65  AdcCount cnt = sig + data.pedestal;
66  data.raw.push_back(cnt);
67  data.samples.push_back(sig);
68  data.flags.push_back(AdcGood);
69  }
70  unsigned int nsig = data.samples.size();
71 
72  cout << myname << line << endl;
73  cout << myname << "Fetch signal finding service." << endl;
75  hsfs->print();
76 
77  AdcFilterVector exp(50, false);
78  for ( unsigned int isig=7; isig<24; ++isig ) exp[isig] = true;
79 
80  cout << myname << line << endl;
81  cout << myname << "Find signal." << endl;
82  assert( hsfs->find(data) == 0 );
83  assert( data.raw.size() == nsig );
84  assert( data.samples.size() == nsig );
85  assert( data.flags.size() == nsig );
86  assert( data.signal.size() == nsig );
87  for ( unsigned int isig=0; isig<nsig; ++isig ) {
88  cout << setw(4) << isig << ": " << setw(6) << data.raw[isig]
89  << fixed << setprecision(1) << setw(8) << data.samples[isig]
90  << " " << ( data.signal[isig] ? "*" : " ") << endl;
91  assert( data.signal[isig] == exp[isig] );
92  }
93 
94  return 0;
95 }
96 
97 //**********************************************************************
98 
99 int main(int argc, char* argv[]) {
100  int logLevel = 1;
101  if ( argc > 1 ) {
102  istringstream ssarg(argv[1]);
103  ssarg >> logLevel;
104  }
106 }
107 
108 //**********************************************************************
virtual int find(AdcChannelData &data) const =0
std::string string
Definition: nybbler.cc:12
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
int main(int argc, char *argv[])
void setChannelInfo(ChannelInfoPtr pchi)
AdcCountVector raw
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
AdcSignal pedestal
AdcFilterVector signal
std::vector< bool > AdcFilterVector
Definition: AdcTypes.h:27
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)
int test_AdcSuppressSignalFindingService()
short AdcCount
Definition: AdcTypes.h:18
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags