Classes | Typedefs | Functions
test_TpcDataTool.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include "dunecore/DuneInterface/Tool/TpcDataTool.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include <cassert>

Go to the source code of this file.

Classes

class  TpcDataTool_update
 

Typedefs

using Index = unsigned int
 

Functions

void fillAdcData (AdcChannelDataMap *pacm, Index ncha=10)
 
int test_TpcDataTool_default ()
 
int test_TpcDataTool_update ()
 
int main (int argc, char *argv[])
 

Typedef Documentation

using Index = unsigned int

Definition at line 26 of file test_TpcDataTool.cxx.

Function Documentation

void fillAdcData ( AdcChannelDataMap pacm,
Index  ncha = 10 
)

Definition at line 30 of file test_TpcDataTool.cxx.

30  {
31  for ( Index icha=0; icha<10; ++icha ) {
32  (*pacm)[icha].setChannelInfo(icha, icha%4);
33  }
34 }
unsigned int Index
int main ( int  argc,
char *  argv[] 
)

Definition at line 181 of file test_TpcDataTool.cxx.

181  {
184  return 0;
185 }
int test_TpcDataTool_default()
int test_TpcDataTool_update()
int test_TpcDataTool_default ( )

Definition at line 62 of file test_TpcDataTool.cxx.

62  {
63  const string myname = "test_TpcDataTool_default: ";
64 #ifdef NDEBUG
65  cout << myname << "NDEBUG must be off." << endl;
66  abort();
67 #endif
68  string line = "-----------------------------";
69 
70  cout << endl;
71  cout << myname << line << endl;
72  cout << myname << "Instantiate tool." << endl;
73  TpcDataTool act;
74 
75  cout << endl;
76  cout << myname << line << endl;
77  cout << myname << "Create data." << endl;
78  TpcData tpd;
80  assert( pacm->size() == 0 );
81  Index ncha = 10;
82  fillAdcData(pacm.get(), ncha);
83  assert( pacm->size() == ncha );
84  AdcChannelData acd = (*pacm)[1];
85 
86  DataMap ret(111);
87 
88  cout << myname << line << endl;
89  cout << myname << "Call update." << endl;
90  ret = act.update(acd);
91  assert( ret == act.interfaceNotImplemented() );
92  ret.print();
93 
94  cout << myname << line << endl;
95  cout << myname << "Call view." << endl;
96  ret = act.view(acd);
97  assert( ret == act.interfaceNotImplemented() );
98  ret.print();
99 
100  cout << myname << line << endl;
101  cout << myname << "Call update TPC." << endl;
102  ret = act.updateTpcData(tpd);
103  assert( ret == act.interfaceNotImplemented() );
104  ret.print();
105 
106  cout << myname << line << endl;
107  cout << myname << "Call view TPC." << endl;
108  ret = act.viewTpcData(tpd);
109  assert( ret == act.interfaceNotImplemented() );
110  ret.print();
111 
112  cout << myname << line << endl;
113  cout << myname << "Test complete." << endl;
114 
115  return 0;
116 }
static int interfaceNotImplemented()
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
Definition: TpcData.h:35
unsigned int Index
virtual DataMap viewTpcData(const TpcData &) const
Definition: TpcDataTool.h:55
void print(std::ostream *pout) const
Definition: DataMap.h:245
virtual DataMap view(const AdcChannelData &acd) const
virtual DataMap update(AdcChannelData &) const
void fillAdcData(AdcChannelDataMap *pacm, Index ncha=10)
virtual DataMap updateTpcData(TpcData &) const
Definition: TpcDataTool.h:39
void line(double t, double *p, double &x, double &y, double &z)
AdcDataPtr createAdcData(bool updateParent=true)
Definition: TpcData.cxx:99
QTextStream & endl(QTextStream &s)
int test_TpcDataTool_update ( )

Definition at line 122 of file test_TpcDataTool.cxx.

122  {
123  const string myname = "test_TpcDataTool_update: ";
124 #ifdef NDEBUG
125  cout << myname << "NDEBUG must be off." << endl;
126  abort();
127 #endif
128  string line = "-----------------------------";
129 
130  cout << endl;
131  cout << myname << line << endl;
132  cout << myname << "Instantiate tool." << endl;
133  TpcDataTool_update act;
134 
135  cout << endl;
136  cout << myname << line << endl;
137  cout << myname << "Create data." << endl;
138  TpcData tpd;
139  TpcData::AdcDataPtr pacm = tpd.createAdcData();
140  assert( pacm->size() == 0 );
141  Index ncha = 10;
142  fillAdcData(pacm.get(), ncha);
143  assert( pacm->size() == ncha );
144  AdcChannelData acd = (*pacm)[1];
145 
146  cout << myname << line << endl;
147  cout << myname << "Call update TPC." << endl;
148  DataMap ret(111);
149  ret = act.updateTpcData(tpd);
150  ret.print();
151  assert( ! ret );
152  assert( tpd.getAdcData().size() == 1 );
153  for ( const auto& iacd : *tpd.getAdcData()[0] ) {
154  Index icha = iacd.first;
155  const AdcChannelData& acd = iacd.second;
156  cout << myname << " icha, femb = " << acd.channel() << ", " << acd.fembID() << endl;
157  assert(acd.channel() == icha);
158  assert(acd.fembID() == 100 + acd.channel());
159  }
160 
161  cout << myname << line << endl;
162  cout << myname << "Call view TPC." << endl;
163  for ( auto& iacd : *tpd.getAdcData()[0] ) iacd.second.setChannelInfo(iacd.second.channel(), 200);
164  ret = act.viewTpcData(tpd);
165  ret.print();
166  assert( ! ret );
167  for ( const auto& iacd : *tpd.getAdcData()[0] ) {
168  Index icha = iacd.first;
169  const AdcChannelData& acd = iacd.second;
170  cout << myname << " icha, femb = " << acd.channel() << ", " << acd.fembID() << endl;
171  assert(acd.channel() == icha);
172  assert(acd.fembID() == 200);
173  }
174  cout << myname << line << endl;
175  cout << myname << "Test complete." << endl;
176  return 0;
177 }
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
Definition: TpcData.h:35
unsigned int Index
virtual DataMap viewTpcData(const TpcData &) const
Definition: TpcDataTool.h:55
void print(std::ostream *pout) const
Definition: DataMap.h:245
Index fembID() const
AdcDataVector & getAdcData()
Definition: TpcData.h:55
void fillAdcData(AdcChannelDataMap *pacm, Index ncha=10)
virtual DataMap updateTpcData(TpcData &) const
Definition: TpcDataTool.h:39
Channel channel() const
void line(double t, double *p, double &x, double &y, double &z)
AdcDataPtr createAdcData(bool updateParent=true)
Definition: TpcData.cxx:99
QTextStream & endl(QTextStream &s)