Typedefs | Functions
test_DuneRoiBuildingService.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/Utilities/SignalShapingServiceDUNE.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_DuneRoiBuildingService (int a_LogLevel=1)
 
int main (int argc, char *argv[])
 

Typedef Documentation

typedef vector<unsigned int> IndexVector

Definition at line 33 of file test_DuneRoiBuildingService.cxx.

Function Documentation

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

Definition at line 133 of file test_DuneRoiBuildingService.cxx.

133  {
134  int a_LogLevel = -1;
135  if ( argc > 1 ) {
136  istringstream ssarg(argv[1]);
137  ssarg >> a_LogLevel;
138  }
139  return test_DuneRoiBuildingService(a_LogLevel);
140 }
int test_DuneRoiBuildingService(int a_LogLevel=1)
int test_DuneRoiBuildingService ( int  a_LogLevel = 1)

Definition at line 37 of file test_DuneRoiBuildingService.cxx.

37  {
38  const string myname = "test_DuneRoiBuildingService: ";
39 #ifdef NDEBUG
40  cout << myname << "NDEBUG must be off." << endl;
41  abort();
42 #endif
43  string line = "-----------------------------";
44 
45  cout << myname << line << endl;
46  cout << myname << "Create top-level FCL." << endl;
47 
48  std::ostringstream oss;
49  oss << "#include \"services_dune.fcl\"" << endl;
50  oss << "services: @local::dune35t_services_legacy" << endl;
51  oss << "services.AdcRoiBuildingService: {" << endl;
52  oss << " service_provider: DuneRoiBuildingService" << endl;
53  oss << " NSigmaStart: 4.0" << endl;
54  oss << " NSigmaEnd: 1.0" << endl;
55  oss << " PadLow: 5" << endl;
56  oss << " PadHigh: 10" << endl;
57  oss << " LogLevel: " << a_LogLevel << endl;
58  oss << "}" << endl;
60 
61  const unsigned int nsig = 100;
62  AdcChannelData acd;
63  acd.setChannelInfo(100);
64  for ( unsigned int isig=0; isig<nsig; ++isig ) {
65  acd.samples.push_back(0);
66  acd.flags.push_back(AdcGood);
67  }
68  acd.samples[10] = 3.0;
69  acd.samples[29] = 2.0;
70  acd.samples[30] = 8.0;
71  acd.samples[31] = 10.0;
72  acd.samples[32] = 8.0;
73  acd.samples[33] = 4.0;
74  acd.samples[34] = 2.0;
75  acd.samples[35] = 0.5;
76  acd.samples[60] = 20.0;
77  acd.samples[70] = 20.0;
78  acd.samples[90] = 20.0;
79  AdcSignalVector& sigs = acd.samples;
80  AdcSignalVector sigsin = sigs;
81 
82  //cout << myname << "Fetch FFT service." << endl;
83  //art::ServiceHandle<util::LArFFT> hfft;
84  //unsigned int fftsize = hfft->FFTSize();
85  //cout << myname << "Resizing signal vector to FFT size " << fftsize
86  //<< " as required for convolution." << endl;
87  //sigs.resize(fftsize, 0.0);
88  //cout << myname << "Samples size: " << acd.samples.size() << endl;
89 
90  cout << myname << "Fetch shaping service." << endl;
92  cout << myname << "Decon noise: " << hsss->GetDeconNoise(acd.channel()) << endl;
93 
94  cout << myname << "Fetch ROI building service." << endl;
96  hroi->print(cout, myname);
97 
98  cout << myname << "Build ROIs." << endl;
99  hroi->build(acd);
100  cout << myname << "Samples size: " << acd.samples.size() << endl;
101  cout << myname << "Output ROIS size: " << acd.rois.size() << endl;
102  assert( sigs.size() == nsig );
103  for ( unsigned int isig=0; isig<nsig; ++isig ) {
104  cout << myname << setw(4) << isig << ": "
105  << fixed << setprecision(1) << setw(10) << sigsin[isig]
106  << fixed << setprecision(1) << setw(10) << sigs[isig]
107  << endl;
108  assert( sigs[isig] == sigsin[isig] );
109  }
110  cout << myname << line << endl;
111  cout << myname << "ROIS:" << endl;
112  for ( AdcRoi roi : acd.rois ) {
113  cout << setw(6) << roi.first << setw(6) << roi.second << endl;
114  }
115 
116  cout << myname << line << endl;
117  cout << myname << "Check ROIs." << endl;
118  assert( acd.rois.size() == 3 );
119  assert( acd.rois[0].first == 25 );
120  assert( acd.rois[0].second == 44 );
121  assert( acd.rois[1].first == 55 );
122  assert( acd.rois[1].second == 80 );
123  assert( acd.rois[2].first == 85 );
124  assert( acd.rois[2].second == 99 );
125 
126  cout << myname << line << endl;
127  cout << myname << "Done." << endl;
128  return 0;
129 }
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
double GetDeconNoise(Channel channel) const override
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
Channel channel() const
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