Typedefs | Functions
test_ConfigurableAdcChannelDataCopyService.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/AdcChannelDataCopyService.h"
#include <cassert>

Go to the source code of this file.

Typedefs

typedef vector< unsigned int > IndexVector
 

Functions

int test_ConfigurableAdcChannelDataCopyService (int a_LogLevel=1, int a_MaxConsecutiveFlag=0)
 
int main (int argc, char *argv[])
 

Typedef Documentation

typedef vector<unsigned int> IndexVector

Function Documentation

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

Definition at line 113 of file test_ConfigurableAdcChannelDataCopyService.cxx.

113  {
114  int a_LogLevel = 1;
115  int a_MaxConsecutiveFlag = 0;
116  if ( argc > 1 ) {
117  istringstream ssarg(argv[1]);
118  ssarg >> a_LogLevel;
119  }
120  if ( argc > 2 ) {
121  istringstream ssarg(argv[1]);
122  ssarg >> a_MaxConsecutiveFlag;
123  }
124  return test_ConfigurableAdcChannelDataCopyService(a_LogLevel, a_MaxConsecutiveFlag);
125 }
int test_ConfigurableAdcChannelDataCopyService(int a_LogLevel=1, int a_MaxConsecutiveFlag=0)
int test_ConfigurableAdcChannelDataCopyService ( int  a_LogLevel = 1,
int  a_MaxConsecutiveFlag = 0 
)

Definition at line 35 of file test_ConfigurableAdcChannelDataCopyService.cxx.

35  {
36  const string myname = "test_ConfigurableAdcChannelDataCopyService: ";
37 #ifdef NDEBUG
38  cout << myname << "NDEBUG must be off." << endl;
39  abort();
40 #endif
41  string line = "-----------------------------";
42 
43  cout << myname << line << endl;
44  cout << myname << "Create top-level FCL." << endl;
45  std::ostringstream oss;
46  oss << "services.AdcChannelDataCopyService: {" << endl;
47  oss << " service_provider: ConfigurableAdcChannelDataCopyService" << endl;
48  oss << " LogLevel: " << a_LogLevel << endl;
49  oss << " CopyChannel: true" << endl;
50  oss << " CopyPedestal: true" << endl;
51  oss << " CopySamples: true" << endl;
52  oss << "}" << endl;
54 
55  AdcChannel channel = 123;
56  AdcSignal pedestal = 123.45;
57  const unsigned int nsig = 50;
58  AdcChannelData acd1;
59  for ( unsigned int isig=0; isig<50; ++isig ) {
60  acd1.samples.push_back(10+isig);
61  acd1.flags.push_back(AdcGood);
62  }
63  AdcSignalVector& sigs = acd1.samples;
64  acd1.setChannelInfo(channel);
65  acd1.pedestal = pedestal;
66 
67  cout << myname << line << endl;
68  cout << myname << "Check original." << endl;
69  assert( acd1.channel() == channel );
70  assert( acd1.pedestal == pedestal );
71  assert( acd1.raw.size() == 0);
72  assert( acd1.samples == sigs );
73  assert( acd1.flags.size() == nsig );
74  assert( acd1.raw.size() == 0 );
75  assert( acd1.signal.size() == 0 );
76  assert( acd1.rois.size() == 0 );
77  assert( acd1.digit == nullptr );
78  assert( acd1.wire == nullptr );
79  assert( acd1.digitIndex == AdcChannelData::badIndex() );
80  assert( acd1.wireIndex == AdcChannelData::badIndex() );
81 
82  cout << myname << line << endl;
83  cout << myname << "Fetch service." << endl;
85 
86  cout << myname << line << endl;
87  cout << myname << "Copy." << endl;
88  AdcChannelData acd2;
89  hcop->copy(acd1, acd2);
90 
91  cout << myname << line << endl;
92  cout << myname << "Check copy." << endl;
93  assert( acd2.channel() == channel );
94  assert( acd2.pedestal == pedestal );
95  assert( acd2.raw.size() == 0);
96  assert( acd2.samples == sigs );
97  assert( acd2.flags.size() == 0 );
98  assert( acd2.raw.size() == 0 );
99  assert( acd2.signal.size() == 0 );
100  assert( acd2.rois.size() == 0 );
101  assert( acd2.digit == nullptr );
102  assert( acd2.wire == nullptr );
103  assert( acd2.digitIndex == AdcChannelData::badIndex() );
104  assert( acd2.wireIndex == AdcChannelData::badIndex() );
105 
106  cout << myname << line << endl;
107  cout << myname << "Done." << endl;
108  return 0;
109 }
float AdcSignal
Definition: AdcTypes.h:21
uint8_t channel
Definition: CRTFragment.hh:201
const recob::Wire * wire
const raw::RawDigit * digit
static void load_services(std::string const &config)
const AdcFlag AdcGood
Definition: AdcTypes.h:32
void setChannelInfo(ChannelInfoPtr pchi)
virtual int copy(const AdcChannelData &oldacd, AdcChannelData &newacd) const =0
AdcRoiVector rois
AdcCountVector raw
Channel channel() const
AdcSignal pedestal
AdcFilterVector signal
unsigned int AdcChannel
Definition: AdcTypes.h:50
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
AdcIndex digitIndex
AdcIndex wireIndex
static Index badIndex()
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags