32 const string myname =
"test_AdcToRoi2d: ";
34 cout << myname <<
"NDEBUG must be off." <<
endl;
37 string line =
"-----------------------------";
39 cout << myname << line <<
endl;
40 string fclfile =
"test_AdcToRoi2d.fcl";
41 if ( ! useExistingFcl ) {
42 cout << myname <<
"Creating top-level FCL." <<
endl;
43 ofstream
fout(fclfile.c_str());
44 fout <<
"#include \"dataprep_tools.fcl\"" <<
endl;
46 fout <<
" tool_type: AdcToRoi2d" <<
endl;
54 cout << myname <<
"Using existing top-level FCL." <<
endl;
57 cout << myname << line <<
endl;
58 cout << myname <<
"Fetching tool manager." <<
endl;
60 assert ( ptm !=
nullptr );
65 cout << myname << line <<
endl;
66 cout << myname <<
"Create test data." <<
endl;
73 Index ntckexp = ntck + ncha - 1;
77 Tpc2dRoi exp(ncha, ntckexp, icha0, itck0);
82 for (
Index kcha=0; kcha<ncha; ++kcha, ++dtck ) {
83 Index icha = icha0 + kcha;
89 float val = 10*(kcha + 1);
92 for (
Index ktck=0; ktck<3; ++ktck, ++idxs[1] ) {
101 assert( acd.
samples.size() == ntck );
105 cout << myname << line <<
endl;
106 cout << myname <<
"Fetching tool." <<
endl;
108 assert( ptoo !=
nullptr );
110 cout << myname << line <<
endl;
111 cout << myname <<
"Call tool." <<
endl;
112 DataMap res = ptoo->updateTpcData(tpd);
114 assert( res.
status() == 0 );
116 cout << myname << line <<
endl;
117 cout << myname <<
"Check results." <<
endl;
120 assert( roi.channelSize() == ncha );
121 assert( roi.channelOffset() == icha0 );
122 assert( roi.sampleSize() == ntckexp );
123 assert( roi.sampleOffset() == itck0 );
124 Index& kcha = idxs[0];
125 Index& ktck = idxs[1];
126 for ( kcha=0; kcha<ncha; ++kcha ) {
127 Index icha = icha0 + kcha;
128 for ( ktck=0; ktck<ntckexp; ++ktck ) {
129 Index itck = itck0 + ktck;
131 float val = roi.data().value(idxs);
132 cout << myname <<
setw(5) << icha <<
setw(5) << itck <<
": " 133 <<
setw(12) << expval <<
" ?= " <<
setw(12) << val <<
endl;
134 assert( val == expval );
136 cout << myname << line <<
endl;
139 cout << myname << line <<
endl;
140 cout << myname <<
"Done." <<
endl;
147 bool useExistingFcl =
false;
149 string sarg(argv[1]);
150 if ( sarg ==
"-h" ) {
151 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
152 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
155 useExistingFcl = sarg ==
"true" || sarg ==
"1";
int test_AdcToRoi2d(bool useExistingFcl=false)
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
void print(std::ostream *pout) const
std::shared_ptr< const EventInfo > EventInfoPtr
AdcDataVector & getAdcData()
void setChannelInfo(ChannelInfoPtr pchi)
std::array< Index, 2 > IndexArray
void setEventInfo(EventInfoPtr pevi)
Float value(const IndexArray &isams, Index *pchk=nullptr) const
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
const DataArray & data() const
AdcDataPtr createAdcData(bool updateParent=true)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
int main(int argc, char *argv[])
Index setValue(const IndexArray &isams, Float val, Index *pchk=nullptr)
Tpc2dRoiVector & get2dRois()
QTextStream & endl(QTextStream &s)