Typedefs | Functions
test_DuneDeconvolutionService.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/AdcDeconvolutionService.h"
#include "lardata/DetectorInfoServices/DetectorClocksService.h"
#include <cassert>

Go to the source code of this file.

Typedefs

typedef vector< unsigned int > IndexVector
 

Functions

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

Typedef Documentation

typedef vector<unsigned int> IndexVector

Definition at line 36 of file test_DuneDeconvolutionService.cxx.

Function Documentation

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

Definition at line 115 of file test_DuneDeconvolutionService.cxx.

115  {
116  const string myname = "main: ";
117  int a_LogLevel = 1;
118  if ( argc > 1 ) {
119  istringstream ssarg(argv[1]);
120  ssarg >> a_LogLevel;
121  }
122  int rstat = test_DuneDeconvolutionService(a_LogLevel);
123  cout << myname << "Exiting." << endl;
124  return rstat;
125 }
int test_DuneDeconvolutionService(int a_LogLevel=-1)
QTextStream & endl(QTextStream &s)
int test_DuneDeconvolutionService ( int  a_LogLevel = -1)

Definition at line 40 of file test_DuneDeconvolutionService.cxx.

40  {
41  const string myname = "test_DuneDeconvolutionService: ";
42 #ifdef NDEBUG
43  cout << myname << "NDEBUG must be off." << endl;
44  abort();
45 #endif
46  string line = "-----------------------------";
47 
48  if ( a_LogLevel < 0 ) {
49  cout << myname << "Skipping test while we wat for resolution of larsoft issue 10618" << endl;
50  return 0;
51  }
52 
53  cout << myname << line << endl;
54  cout << myname << "Create top-level FCL." << endl;
55 
56  std::ostringstream oss;
57  oss << "#include \"services_dune.fcl\"" << endl;
58  oss << "services: @local::dune35t_services_legacy" << endl;
59  oss << "services.AdcDeconvolutionService: {" << endl;
60  oss << " service_provider: DuneDeconvolutionService" << endl;
61  oss << " LogLevel: " << a_LogLevel << endl;
62  oss << "}" << endl;
64 
65  const unsigned int nsig = 100;
66  AdcChannelData acd;
67  acd.setChannelInfo(100);
68  for ( unsigned int isig=0; isig<nsig; ++isig ) {
69  acd.samples.push_back(0);
70  acd.flags.push_back(AdcGood);
71  }
72  acd.samples[50] = 100000.0;
73  AdcSignalVector& sigs = acd.samples;
74  AdcSignalVector sigsin = sigs;
75 
76  cout << myname << "Fetch FFT service." << endl;
78  unsigned int fftsize = hfft->FFTSize();
79  cout << myname << "Resizing signal vector to FFT size " << fftsize
80  << " as required for convolution." << endl;
81  sigs.resize(fftsize, 0.0);
82 
83  cout << myname << "Fetch shaping service." << endl;
85 
86  cout << myname << "Convolute." << endl;
87  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
88  hsss->Convolute(clockData, acd.channel(), sigs);
89  AdcSignalVector sigsco = sigs;
90 
91  cout << myname << "Fetch deconvolution service." << endl;
93  hdco->print();
94 
95  cout << myname << line << endl;
96  cout << myname << "Deconvolute." << endl;
97  assert( hdco->update(clockData, acd) == 0 );
98  cout << myname << "Output vector size: " << sigs.size() << endl;
99  assert( sigs.size() == sigsco.size() );
100  for ( unsigned int isig=0; isig<nsig; ++isig ) {
101  cout << setw(4) << isig << ": "
102  << fixed << setprecision(1) << setw(8) << sigsin[isig]
103  << fixed << setprecision(1) << setw(10) << sigsco[isig]
104  << fixed << setprecision(1) << setw(10) << sigs[isig]
105  << endl;
106  //assert( sigs[isig] == sigsexp[isig] );
107  }
108 
109  cout << myname << "Done." << endl;
110  return 0;
111 }
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)
int FFTSize() const
Definition: LArFFT.h:69
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
Channel channel() const
void Convolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
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
Definition: AdcTypes.h:22
virtual int update(detinfo::DetectorClocksData const &clockData, AdcChannelData &data) const =0
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags