Typedefs | Functions
test_KeepAllRoiBuildingService.cxx File Reference
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "dunecore/ArtSupport/ArtServiceHelper.h"
#include "dunecore/DuneInterface/Service/AdcRoiBuildingService.h"
#include <cassert>

Go to the source code of this file.

Typedefs

typedef vector< unsigned int > IndexVector
 

Functions

int test_KeepAllRoiBuildingService (int a_LogLevel=1, bool explicitFcl=true)
 
int main (int argc, char *argv[])
 

Typedef Documentation

typedef vector<unsigned int> IndexVector

Definition at line 32 of file test_KeepAllRoiBuildingService.cxx.

Function Documentation

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

Definition at line 122 of file test_KeepAllRoiBuildingService.cxx.

122  {
123  int a_LogLevel = -1;
124  bool explicitFcl = 1;
125  if ( argc > 1 ) {
126  istringstream ssarg(argv[1]);
127  ssarg >> a_LogLevel;
128  }
129  if ( argc > 2 ) {
130  string sarg(argv[2]);
131  explicitFcl = sarg=="1" || sarg == "true";
132  }
133  cout << " LogLevel: " << a_LogLevel << endl;
134  cout << " explicitFcl: " << explicitFcl << endl;
135  return test_KeepAllRoiBuildingService(a_LogLevel, explicitFcl);
136 }
int test_KeepAllRoiBuildingService(int a_LogLevel=1, bool explicitFcl=true)
QTextStream & endl(QTextStream &s)
int test_KeepAllRoiBuildingService ( int  a_LogLevel = 1,
bool  explicitFcl = true 
)

Definition at line 36 of file test_KeepAllRoiBuildingService.cxx.

36  {
37  const string myname = "test_KeepAllRoiBuildingService: ";
38 #ifdef NDEBUG
39  cout << myname << "NDEBUG must be off." << endl;
40  abort();
41 #endif
42  string line = "-----------------------------";
43 
44  cout << myname << line << endl;
45  cout << myname << "Arguments: " << endl;
46  cout << myname << " LogLevel: " << a_LogLevel << endl;
47  cout << myname << " explicitFcl: " << explicitFcl << endl;
48 
49  cout << myname << line << endl;
50  cout << myname << "Create top-level FCL." << endl;
51  std::ostringstream fout;
52  fout << "#include \"services_dune.fcl\"" << endl;
53  fout << "services: @local::dune35t_services_legacy" << endl;
54  if ( explicitFcl ) {
55  fout << "services.AdcRoiBuildingService: {" << endl;
56  fout << " service_provider: KeepAllRoiBuildingService" << endl;
57  fout << " LogLevel: " << a_LogLevel << endl;
58  fout << "}" << endl;
59  } else {
60  fout << "services.AdcRoiBuildingService: @local::adcroi_keepall" << endl;
61  }
63 
64  const unsigned int nsig = 100;
65  AdcChannelData acd;
66  acd.setChannelInfo(100);
67  for ( unsigned int isig=0; isig<nsig; ++isig ) {
68  acd.samples.push_back(0);
69  acd.flags.push_back(AdcGood);
70  }
71  acd.samples[10] = 3.0;
72  acd.samples[29] = 2.0;
73  acd.samples[30] = 8.0;
74  acd.samples[31] = 10.0;
75  acd.samples[32] = 8.0;
76  acd.samples[33] = 4.0;
77  acd.samples[34] = 2.0;
78  acd.samples[35] = 0.5;
79  acd.samples[60] = 20.0;
80  acd.samples[70] = 20.0;
81  acd.samples[90] = 20.0;
82  AdcSignalVector& sigs = acd.samples;
83  AdcSignalVector sigsin = sigs;
84 
85  cout << myname << line << endl;
86  cout << myname << "Fetch ROI building service." << endl;
88  hroi->print(cout, myname);
89 
90  cout << myname << line << endl;
91  cout << myname << "Build ROIs." << endl;
92  hroi->build(acd);
93  cout << myname << "Samples size: " << acd.samples.size() << endl;
94  cout << myname << "Output ROIS size: " << acd.rois.size() << endl;
95  assert( sigs.size() == nsig );
96  for ( unsigned int isig=0; isig<nsig; ++isig ) {
97  cout << myname << setw(4) << isig << ": "
98  << fixed << setprecision(1) << setw(10) << sigsin[isig]
99  << fixed << setprecision(1) << setw(10) << sigs[isig]
100  << endl;
101  assert( sigs[isig] == sigsin[isig] );
102  }
103  cout << myname << line << endl;
104  cout << myname << "ROIS:" << endl;
105  for ( AdcRoi roi : acd.rois ) {
106  cout << setw(6) << roi.first << setw(6) << roi.second << endl;
107  }
108 
109  cout << myname << line << endl;
110  cout << myname << "Check ROIs." << endl;
111  assert( acd.rois.size() == 1 );
112  assert( acd.rois[0].first == 0 );
113  assert( acd.rois[0].second == 99 );
114 
115  cout << myname << line << endl;
116  cout << myname << "Done." << endl;
117  return 0;
118 }
virtual int build(AdcChannelData &data) const =0
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
std::pair< AdcIndex, AdcIndex > AdcRoi
Definition: AdcTypes.h:54
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)
AdcRoiVector rois
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags